Initial commit.
This commit is contained in:
100
.emacs.d/elpa/ess-20160208.453/lisp/ess-arc-d.el
Normal file
100
.emacs.d/elpa/ess-20160208.453/lisp/ess-arc-d.el
Normal file
@@ -0,0 +1,100 @@
|
||||
;;; ess-arc-d.el --- ARC customization
|
||||
|
||||
;; Copyright (C) 2000 A. J. Rossini
|
||||
;; Copyright (C) 2001--2004 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: A.J. Rossini <rossini@stat.sc.edu>
|
||||
;; Created: 30 Jun 2000
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; Keywords: languages
|
||||
|
||||
;; This file is part of ESS
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This file extends the XLispStat configuration for ARC, the extension of the
|
||||
;; R-Code.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'ess-lsp-l)
|
||||
|
||||
(autoload 'inferior-ess "ess-inf" "Run an ESS process.")
|
||||
|
||||
(defvar ARC-customize-alist
|
||||
'((ess-customize-alist . ARC-customize-alist )
|
||||
(ess-language . "XLS" )
|
||||
(ess-dialect . "ARC" )
|
||||
(ess-loop-timeout . ess-XLS-loop-timeout)
|
||||
(ess-object-name-db-file . "ess-xls-namedb.el" )
|
||||
(ess-help-sec-regex . " ")
|
||||
(ess-help-sec-keys-alist . " ")
|
||||
(inferior-ess-primary-prompt . "> ?" )
|
||||
(comint-use-prompt-regexp . t)
|
||||
(inferior-ess-program . inferior-ARC-program-name)
|
||||
(inferior-ess-help-command . "(help '%s)\n" )
|
||||
(inferior-ess-objects-command . "(variables)\n" )
|
||||
(inferior-ess-exit-command . "(exit)\n" )
|
||||
;;(inferior-ess-start-args . nil)
|
||||
(inferior-ess-start-file . nil)) ; "~/.ess-ARC")
|
||||
|
||||
"Variables to customize for ARC, a dialect of XLS.")
|
||||
|
||||
|
||||
(defun ARC-mode (&optional proc-name)
|
||||
"Major mode for editing ARC source. NOT EVEN STARTED."
|
||||
(interactive)
|
||||
(setq ess-customize-alist ARC-customize-alist)
|
||||
(lisp-mode))
|
||||
|
||||
|
||||
(defun ARC ()
|
||||
"Call 'ARC', the extend XLispStat statistical system, from Forrest Young."
|
||||
|
||||
(interactive)
|
||||
(setq ess-customize-alist ARC-customize-alist)
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "(ARC): ess-dialect=%s , buf=%s\n"
|
||||
ess-dialect (current-buffer)))
|
||||
(inferior-ess))
|
||||
|
||||
(fset 'arc 'ARC)
|
||||
|
||||
; Provide package
|
||||
|
||||
(provide 'ess-arc-d)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; outline-minor-mode: nil
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-arc-d.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-arc-d.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-arc-d.elc
Normal file
Binary file not shown.
265
.emacs.d/elpa/ess-20160208.453/lisp/ess-bugs-d.el
Normal file
265
.emacs.d/elpa/ess-20160208.453/lisp/ess-bugs-d.el
Normal file
@@ -0,0 +1,265 @@
|
||||
;;; ess-bugs-d.el --- ESS[BUGS] dialect
|
||||
|
||||
;; Copyright (C) 2008-2011 Rodney Sparapani
|
||||
|
||||
;; Author: Rodney Sparapani
|
||||
;; Created: 13 March 2008
|
||||
;; Maintainer: ESS-help <ess-help@r-project.org>
|
||||
|
||||
;; This file is part of ESS
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'ess-bugs-l)
|
||||
(require 'ess-utils)
|
||||
(require 'ess-inf)
|
||||
|
||||
(setq auto-mode-alist
|
||||
(append '(("\\.[bB][uU][gG]\\'" . ess-bugs-mode)) auto-mode-alist))
|
||||
|
||||
(defvar ess-bugs-command "OpenBUGS" "Default BUGS program in PATH.")
|
||||
(make-local-variable 'ess-bugs-command)
|
||||
|
||||
(defvar ess-bugs-monitor '("") "Default list of variables to monitor.")
|
||||
(make-local-variable 'ess-bugs-monitor)
|
||||
|
||||
(defvar ess-bugs-thin 1 "Default thinning parameter.")
|
||||
(make-local-variable 'ess-bugs-thin)
|
||||
|
||||
(defvar ess-bugs-chains 1 "Default number of chains.")
|
||||
(make-local-variable 'ess-bugs-chains)
|
||||
|
||||
(defvar ess-bugs-burnin 10000 "Default burn-in.")
|
||||
(make-local-variable 'ess-bugs-burnin)
|
||||
|
||||
(defvar ess-bugs-update 10000 "Default number of updates after burnin.")
|
||||
(make-local-variable 'ess-bugs-update)
|
||||
|
||||
(defvar ess-bugs-system nil "Default whether BUGS recognizes the system command.")
|
||||
|
||||
(defvar ess-bugs-font-lock-keywords
|
||||
(list
|
||||
;; .bug files
|
||||
(cons "#.*\n" font-lock-comment-face)
|
||||
|
||||
(cons "^[ \t]*\\(model\\|var\\)\\>"
|
||||
font-lock-keyword-face)
|
||||
|
||||
(cons (concat "\\<d\\(bern\\|beta\\|bin\\|cat\\|chisq\\|"
|
||||
"dexp\\|dirch\\|exp\\|\\(gen[.]\\)?gamma\\|hyper\\|"
|
||||
"interval\\|lnorm\\|logis\\|mnorm\\|mt\\|multi\\|"
|
||||
"negbin\\|norm\\(mix\\)?\\|par\\|pois\\|sum\\|t\\|"
|
||||
"unif\\|weib\\|wish\\)[ \t\n]*(")
|
||||
font-lock-constant-face)
|
||||
|
||||
(cons (concat "\\<\\(abs\\|cos\\|C\\|dim\\|\\(i\\)?cloglog\\|equals\\|"
|
||||
"exp\\|for\\|inprod\\|interp[.]line\\|inverse\\|length\\|"
|
||||
"\\(i\\)?logit\\|logdet\\|logfact\\|loggam\\|max\\|mean\\|"
|
||||
"mexp\\|min\\|phi\\|pow\\|probit\\|prod\\|rank\\|round\\|"
|
||||
"sd\\|sin\\|sort\\|sqrt\\|step\\|sum\\|t\\|trunc\\|T\\)[ \t\n]*(")
|
||||
font-lock-function-name-face)
|
||||
|
||||
;; .bmd files
|
||||
(cons (concat (regexp-opt '(
|
||||
"dicClear" "dicSet" "dicStats"
|
||||
"infoMemory" "infoModules" "infoNodeMethods"
|
||||
"infoNodeTypes" "infoNodeValues"
|
||||
"infoUpdatersbyDepth" "infoUpdatersbyName"
|
||||
"modelCheck" "modelCompile" "modelData"
|
||||
"modelDisable" "modelEnable" "modelGenInits"
|
||||
"modelInits" "modelPrecision" "modelQuit"
|
||||
"modelSaveState" "modelSetAP" "modelSetIts"
|
||||
"modelSetOR" "modelSetRN" "modelUpdate"
|
||||
"ranksClear" "ranksSet" "ranksStats"
|
||||
"samplesAutoC" "samplesBgr" "samplesCoda"
|
||||
"samplesDensity" "samplesHistory" "samplesSet"
|
||||
"sampleStats" "samplesThin"
|
||||
"summaryClear" "summarySet" "summaryStats"
|
||||
) 'words) "(")
|
||||
font-lock-function-name-face)
|
||||
|
||||
(cons (concat (regexp-opt '("Local Variables" "End") 'words) ":")
|
||||
font-lock-keyword-face)
|
||||
)
|
||||
"ESS[BUGS]: Font lock keywords."
|
||||
)
|
||||
|
||||
(defun ess-bugs-switch-to-suffix (suffix &optional bugs-chains bugs-monitor bugs-thin
|
||||
bugs-burnin bugs-update)
|
||||
"ESS[BUGS]: Switch to file with suffix."
|
||||
(find-file (concat ess-bugs-file-dir ess-bugs-file-root suffix))
|
||||
|
||||
(if (equal 0 (buffer-size)) (progn
|
||||
(if (equal ".bug" suffix) (progn
|
||||
;(insert "var ;\n")
|
||||
(insert "model {\n")
|
||||
(insert " for (i in 1:N) {\n \n")
|
||||
(insert " }\n")
|
||||
(insert "}\n")
|
||||
(insert "#Local Variables" ":\n")
|
||||
; (insert "#enable-local-variables: :all\n")
|
||||
(insert "#ess-bugs-chains:1\n")
|
||||
(insert "#ess-bugs-monitor:(\"\")\n")
|
||||
(insert "#ess-bugs-thin:1\n")
|
||||
(insert "#ess-bugs-burnin:10000\n")
|
||||
(insert "#ess-bugs-update:10000\n")
|
||||
(insert "#End:\n")
|
||||
))
|
||||
|
||||
(if (equal ".bmd" suffix) (let
|
||||
((ess-bugs-temp-chains "") (ess-bugs-temp-monitor "") (ess-bugs-temp-chain ""))
|
||||
|
||||
(if bugs-chains (setq ess-bugs-chains bugs-chains))
|
||||
(if bugs-monitor (setq ess-bugs-monitor bugs-monitor))
|
||||
(if bugs-thin (setq ess-bugs-thin bugs-thin))
|
||||
|
||||
(setq ess-bugs-temp-chains
|
||||
(concat "modelCompile(" (format "%d" ess-bugs-chains) ")\n"))
|
||||
|
||||
(setq bugs-chains ess-bugs-chains)
|
||||
|
||||
(while (< 0 bugs-chains)
|
||||
(setq ess-bugs-temp-chains
|
||||
(concat ess-bugs-temp-chains
|
||||
"modelInits('" ess-bugs-file-root
|
||||
".##" (format "%d" bugs-chains) "', "
|
||||
(format "%d" bugs-chains) ")\n"))
|
||||
(setq bugs-chains (- bugs-chains 1)))
|
||||
|
||||
(setq ess-bugs-temp-monitor "")
|
||||
|
||||
(while (and (listp ess-bugs-monitor) (consp ess-bugs-monitor))
|
||||
(if (not (string-equal "" (car ess-bugs-monitor)))
|
||||
(setq ess-bugs-temp-monitor
|
||||
(concat ess-bugs-temp-monitor "samplesSet('"
|
||||
(car ess-bugs-monitor)
|
||||
;", thin(" (format "%d" ess-bugs-thin)
|
||||
"')\n")))
|
||||
(setq ess-bugs-monitor (cdr ess-bugs-monitor)))
|
||||
|
||||
(insert "modelCheck('" ess-bugs-file-root ".bug')\n")
|
||||
(insert "modelData('" ess-bugs-file-root ".bdt')\n")
|
||||
(insert (ess-replace-in-string ess-bugs-temp-chains "##" "in"))
|
||||
(insert "modelGenInits()\n")
|
||||
(insert "modelUpdate(" (format "%d" bugs-burnin) ")\n")
|
||||
;(insert "modelUpdate(" (format "%d" (* bugs-thin bugs-burnin)) ")\n")
|
||||
(insert ess-bugs-temp-monitor)
|
||||
(insert "modelUpdate(" (format "%d" (* bugs-thin bugs-update)) ")\n")
|
||||
; (insert (ess-replace-in-string
|
||||
; (ess-replace-in-string ess-bugs-temp-chains
|
||||
; "modelCompile([0-9]+)" "#") "##" "to"))
|
||||
|
||||
(if (< 1 bugs-thin) (insert "samplesThin(" (format "%d" bugs-thin) ")\n"))
|
||||
|
||||
(insert "samplesCoda('*', '" ess-bugs-file-root "')\n")
|
||||
|
||||
; (if ess-bugs-system (progn
|
||||
; (insert "system rm -f " ess-bugs-file-root ".ind\n")
|
||||
; (insert "system ln -s " ess-bugs-file-root "index.txt " ess-bugs-file-root ".ind\n")
|
||||
|
||||
; (setq bugs-chains ess-bugs-chains)
|
||||
|
||||
; (while (< 0 bugs-chains)
|
||||
; (setq ess-bugs-temp-chain (format "%d" bugs-chains))
|
||||
|
||||
; ;.txt not recognized by BOA and impractical to over-ride
|
||||
; (insert "system rm -f " ess-bugs-file-root ess-bugs-temp-chain ".out\n")
|
||||
; (insert "system ln -s " ess-bugs-file-root "chain" ess-bugs-temp-chain ".txt "
|
||||
; ess-bugs-file-root ess-bugs-temp-chain ".out\n")
|
||||
; (setq bugs-chains (- bugs-chains 1)))))
|
||||
|
||||
(insert "modelQuit()\n")
|
||||
(insert "Local Variables" ":\n")
|
||||
; (insert "enable-local-variables: :all\n")
|
||||
(insert "ess-bugs-chains:" (format "%d" ess-bugs-chains) "\n")
|
||||
(insert "ess-bugs-command:\"" ess-bugs-command "\"\n")
|
||||
(insert "End:\n")
|
||||
))
|
||||
))
|
||||
)
|
||||
|
||||
(defun ess-bugs-na-bmd (bugs-command bugs-chains)
|
||||
"ESS[BUGS]: Perform the Next-Action for .bmd."
|
||||
;(ess-save-and-set-local-variables)
|
||||
(if (equal 0 (buffer-size)) (ess-bugs-switch-to-suffix ".bmd")
|
||||
;else
|
||||
(shell)
|
||||
(ess-sleep)
|
||||
|
||||
(if (and (w32-shell-dos-semantics) (string-equal ":" (substring ess-bugs-file 1 2)))
|
||||
(insert (substring ess-bugs-file 0 2)))
|
||||
|
||||
(comint-send-input)
|
||||
(insert "cd \"" ess-bugs-file-dir "\"")
|
||||
(comint-send-input)
|
||||
|
||||
; (let ((ess-bugs-temp-chains ""))
|
||||
;
|
||||
; (while (< 0 bugs-chains)
|
||||
; (setq ess-bugs-temp-chains
|
||||
; (concat (format "%d " bugs-chains) ess-bugs-temp-chains))
|
||||
; (setq bugs-chains (- bugs-chains 1)))
|
||||
|
||||
;; (insert "echo '"
|
||||
;; ess-bugs-batch-pre-command " " bugs-command " < "
|
||||
;; ess-bugs-file-root ".bmd > " ess-bugs-file-root ".bog 2>&1 "
|
||||
;; ess-bugs-batch-post-command "' > " ess-bugs-file-root ".bsh")
|
||||
;; (comint-send-input)
|
||||
|
||||
;; (insert "at -f " ess-bugs-file-root ".bsh now")
|
||||
|
||||
;; (comint-send-input)
|
||||
|
||||
(insert "echo '"
|
||||
ess-bugs-batch-pre-command " " bugs-command " < "
|
||||
ess-bugs-file-root ".bmd > " ess-bugs-file-root ".bog 2>&1 "
|
||||
ess-bugs-batch-post-command "' | at now")
|
||||
|
||||
(comint-send-input)
|
||||
))
|
||||
|
||||
(defun ess-bugs-na-bug ()
|
||||
"ESS[BUGS]: Perform Next-Action for .bug"
|
||||
|
||||
(if (equal 0 (buffer-size)) (ess-bugs-switch-to-suffix ".bug")
|
||||
;else
|
||||
(ess-save-and-set-local-variables)
|
||||
(ess-bugs-switch-to-suffix ".bmd"
|
||||
ess-bugs-chains ess-bugs-monitor ess-bugs-thin ess-bugs-burnin ess-bugs-update))
|
||||
)
|
||||
|
||||
(defun ess-bugs-mode ()
|
||||
"ESS[BUGS]: Major mode for BUGS."
|
||||
(interactive)
|
||||
(kill-all-local-variables)
|
||||
(ess-setq-vars-local '((comment-start . "#")))
|
||||
(setq major-mode 'ess-bugs-mode)
|
||||
(setq mode-name "ESS[BUGS]")
|
||||
(use-local-map ess-bugs-mode-map)
|
||||
(setq font-lock-auto-fontify t)
|
||||
(make-local-variable 'font-lock-defaults)
|
||||
(setq font-lock-defaults '(ess-bugs-font-lock-keywords nil t))
|
||||
(setq ess-language "S") ; mimic S for ess-smart-underscore
|
||||
(run-hooks 'ess-bugs-mode-hook)
|
||||
|
||||
(if (not (w32-shell-dos-semantics))
|
||||
(add-hook 'comint-output-filter-functions 'ess-bugs-exit-notify-sh))
|
||||
)
|
||||
|
||||
(setq features (delete 'ess-bugs-d features))
|
||||
(provide 'ess-bugs-d)
|
||||
|
||||
;;; ess-bugs-d.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-bugs-d.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-bugs-d.elc
Normal file
Binary file not shown.
277
.emacs.d/elpa/ess-20160208.453/lisp/ess-bugs-l.el
Normal file
277
.emacs.d/elpa/ess-20160208.453/lisp/ess-bugs-l.el
Normal file
@@ -0,0 +1,277 @@
|
||||
;;; ess-bugs-l.el --- ESS[BUGS] languages
|
||||
|
||||
;; Copyright (C) 2006-2011 Rodney Sparapani
|
||||
|
||||
;; Author: Rodney Sparapani
|
||||
;; Created: 16 August 2006
|
||||
;; Maintainer: ESS-help <ess-help@r-project.org>
|
||||
|
||||
;; This file is part of ESS
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'font-lock)
|
||||
(require 'comint)
|
||||
(require 'ess-compat)
|
||||
|
||||
(defgroup ess-bugs nil
|
||||
"ESS: BUGS."
|
||||
:group 'ess
|
||||
:prefix "ess-")
|
||||
|
||||
(defcustom ess-bugs-batch-method
|
||||
(if ess-microsoft-p (if (w32-shell-dos-semantics) 'dos 'sh) 'sh)
|
||||
"Method used by `ess-bugs-batch'.
|
||||
The default is based on the value of the emacs variable `system-type'
|
||||
and, on Windows machines, the function `w32-shell-dos-semantics'.
|
||||
'sh if *shell* runs a Bourne-like or a C-like Unix shell
|
||||
'dos if *shell* runs a DOS-like Windows shell
|
||||
|
||||
Unix users will get 'sh by default.
|
||||
|
||||
Windows users running a DOS-like *shell* will get 'dos by default,
|
||||
while those running a Unix-like *shell* will get 'sh by default.
|
||||
|
||||
Users whose default is not 'sh, but are accessing a remote machine with
|
||||
`telnet' or `ssh', should have the following in their init file:
|
||||
(setq-default ess-bugs-batch-method 'sh)"
|
||||
:group 'ess-bugs
|
||||
)
|
||||
|
||||
(defcustom ess-bugs-batch-post-command
|
||||
(if (equal ess-bugs-batch-method 'sh) "&" " ")
|
||||
"*ESS[BUGS]: Modifiers at the end of the batch BUGS command line."
|
||||
:group 'ess-bugs
|
||||
:type 'string
|
||||
)
|
||||
|
||||
(defcustom ess-bugs-batch-pre-command
|
||||
(if (equal ess-bugs-batch-method 'sh) "nohup nice time"
|
||||
(if ess-microsoft-p "start"))
|
||||
"*ESS[BUGS]: Modifiers at the beginning of the batch BUGS command line."
|
||||
:group 'ess-bugs
|
||||
:type 'string
|
||||
)
|
||||
|
||||
|
||||
(defcustom ess-bugs-default-burn-in "500"
|
||||
"ESS[BUGS]: Burn-in iterations to discard."
|
||||
:group 'ess-bugs
|
||||
:type 'string
|
||||
)
|
||||
|
||||
(defcustom ess-bugs-default-update "1000"
|
||||
"ESS[BUGS]: Iterations to store."
|
||||
:group 'ess-bugs
|
||||
:type 'string
|
||||
)
|
||||
|
||||
(defvar ess-bugs-batch-command ";"
|
||||
"*ESS[BUGS]: The name of the command to run BUGS in batch mode."
|
||||
)
|
||||
|
||||
(defvar ess-bugs-file "."
|
||||
"ESS[BUGS]: BUGS file with PATH.")
|
||||
|
||||
(defvar ess-bugs-file-root "."
|
||||
"ESS[BUGS]: Root of BUGS file.")
|
||||
|
||||
(defvar ess-bugs-file-suffix "."
|
||||
"ESS[BUGS]: Suffix of BUGS file.")
|
||||
|
||||
(defvar ess-bugs-file-dir "."
|
||||
"ESS[BUGS]: Directory of BUGS file.")
|
||||
|
||||
(defvar ess-bugs-file-data "..."
|
||||
"ESS[BUGS]: BUGS data file.")
|
||||
|
||||
(defcustom ess-bugs-inits-suffix ".in"
|
||||
"ESS[BUGS]: BUGS init file suffix."
|
||||
:group 'ess-bugs
|
||||
:type 'string
|
||||
)
|
||||
|
||||
(defcustom ess-bugs-data-suffix ".dat"
|
||||
"ESS[BUGS]: BUGS data file suffix."
|
||||
:group 'ess-bugs
|
||||
:type 'string
|
||||
)
|
||||
|
||||
(defcustom ess-bugs-mode-hook nil
|
||||
"*ESS[BUGS]: List of functions to call upon entering mode."
|
||||
:group 'ess-bugs
|
||||
:type 'hook)
|
||||
|
||||
(defvar ess-bugs-monitor-vars " "
|
||||
"ESS[BUGS]: List of BUGS variables to be written out to a file.")
|
||||
|
||||
(defvar ess-bugs-stats-vars " "
|
||||
"ESS[BUGS]: List of BUGS variables to be summarized with statistics.")
|
||||
|
||||
(defvar ess-bugs-mode-map nil
|
||||
"ESS[BUGS]: Keymap for mode.")
|
||||
|
||||
(if ess-bugs-mode-map nil (setq ess-bugs-mode-map (make-keymap)))
|
||||
(define-key ess-bugs-mode-map (quote [f2]) 'ess-revert-wisely)
|
||||
;(define-key ess-bugs-mode-map (quote [f12]) 'ess-bugs-next-action)
|
||||
(define-key ess-bugs-mode-map "\C-c\C-c" 'ess-bugs-next-action)
|
||||
(define-key ess-bugs-mode-map "=" 'ess-bugs-hot-arrow)
|
||||
(define-key ess-bugs-mode-map "_" 'ess-bugs-hot-arrow)
|
||||
|
||||
(defvar ess-bugs-syntax-table nil
|
||||
"ESS[BUGS]: Syntax table for mode.")
|
||||
|
||||
(if ess-bugs-syntax-table nil (setq ess-bugs-syntax-table (make-syntax-table)))
|
||||
(modify-syntax-entry ?\\ "." ess-bugs-syntax-table)
|
||||
(modify-syntax-entry ?# "<" ess-bugs-syntax-table)
|
||||
(modify-syntax-entry ?\n ">" ess-bugs-syntax-table)
|
||||
(modify-syntax-entry ?( "()" ess-bugs-syntax-table)
|
||||
(modify-syntax-entry ?) ")(" ess-bugs-syntax-table)
|
||||
(modify-syntax-entry ?. "w" ess-bugs-syntax-table)
|
||||
|
||||
(defun ess-bugs-file ()
|
||||
"ESS[BUGS]: Set internal variables dealing with BUGS files.
|
||||
Set `ess-bugs-file', `ess-bugs-file-root', `ess-bugs-file-suffix'
|
||||
and `ess-bugs-file-dir'."
|
||||
(let ((ess-bugs-temp-string (buffer-name)))
|
||||
(setq ess-bugs-file (expand-file-name ess-bugs-temp-string))
|
||||
(setq ess-bugs-file-dir
|
||||
(convert-standard-filename (file-name-directory ess-bugs-file)))
|
||||
(setq ess-bugs-file-root
|
||||
(file-name-nondirectory (file-name-sans-extension ess-bugs-file)))
|
||||
|
||||
(if (fboundp 'file-name-extension)
|
||||
(setq ess-bugs-file-suffix (file-name-extension ess-bugs-temp-string))
|
||||
;;else
|
||||
(setq ess-bugs-file-suffix (car (last (split-string ess-bugs-temp-string "[.]")))))
|
||||
|
||||
(setq ess-bugs-file-suffix
|
||||
(downcase (car (split-string (concat "." ess-bugs-file-suffix) "[<]"))))
|
||||
|
||||
(setq ess-bugs-file (concat ess-bugs-file-dir ess-bugs-file-root ess-bugs-file-suffix))
|
||||
)
|
||||
)
|
||||
|
||||
(defun ess-bugs-exit-notify-sh (string)
|
||||
"ESS[BUGS]: Detect completion or failure of submitted job and notify the user."
|
||||
(let* ((exit-done "\\[[0-9]+\\]\\ *\\+*\\ *\\(Exit\\|Done\\)[^\r\n]*")
|
||||
(beg (string-match exit-done string)))
|
||||
(if beg (message (substring string beg (match-end 0))))))
|
||||
|
||||
(defun ess-bugs-hot-arrow ()
|
||||
"*ESS[BUGS]: Substitute <- for = key press"
|
||||
(interactive)
|
||||
(insert " <- "))
|
||||
|
||||
(defun ess-bugs-next-action ()
|
||||
"ESS[BUGS/JAGS]: Perform the appropriate next action."
|
||||
(interactive)
|
||||
(ess-bugs-file)
|
||||
|
||||
(cond ((equal ".bug" ess-bugs-file-suffix) (ess-bugs-na-bug))
|
||||
((equal ".jag" ess-bugs-file-suffix) (ess-jags-na-bug))
|
||||
((equal ".bmd" ess-bugs-file-suffix)
|
||||
(ess-save-and-set-local-variables)
|
||||
(ess-bugs-na-bmd ess-bugs-command ess-bugs-chains))
|
||||
((equal ".jmd" ess-bugs-file-suffix)
|
||||
(ess-save-and-set-local-variables)
|
||||
(ess-jags-na-jmd ess-jags-command ess-jags-chains)))
|
||||
)
|
||||
|
||||
(defun ess-bugs-sci-to-round-4-dp ()
|
||||
"ESS[BUGS]: round output from +/-0.000E+/-0 to 4 decimal places."
|
||||
(interactive)
|
||||
(setq buffer-read-only nil)
|
||||
(save-excursion (goto-char 0)
|
||||
(save-match-data (let ((ess-bugs-replacement-string nil)
|
||||
(ess-bugs-replacement-9 0)
|
||||
(ess-bugs-replacement-diff 0))
|
||||
(while (search-forward-regexp "-?[0-9][.][0-9][0-9][0-9]E[+-][0-9]" nil t)
|
||||
(setq ess-bugs-replacement-string
|
||||
(int-to-string (string-to-number (match-string 0))))
|
||||
(setq ess-bugs-replacement-diff (- (match-end 0) (match-beginning 0)))
|
||||
(save-match-data
|
||||
(setq ess-bugs-replacement-9
|
||||
(string-match "99999999999$" ess-bugs-replacement-string))
|
||||
|
||||
(if (not ess-bugs-replacement-9)
|
||||
(setq ess-bugs-replacement-9
|
||||
(string-match "000000000001$" ess-bugs-replacement-string))))
|
||||
|
||||
(if ess-bugs-replacement-9
|
||||
(setq ess-bugs-replacement-string
|
||||
(substring ess-bugs-replacement-string 0 ess-bugs-replacement-9)))
|
||||
|
||||
(setq ess-bugs-replacement-diff
|
||||
(- ess-bugs-replacement-diff (string-width ess-bugs-replacement-string)))
|
||||
|
||||
(while (> ess-bugs-replacement-diff 0)
|
||||
(setq ess-bugs-replacement-string (concat ess-bugs-replacement-string " "))
|
||||
(setq ess-bugs-replacement-diff (- ess-bugs-replacement-diff 1)))
|
||||
|
||||
(replace-match ess-bugs-replacement-string))))))
|
||||
|
||||
;;; ESS[BUGS-Shell] for running BUGS interactively
|
||||
(defgroup ess-bugs-shell nil
|
||||
"ESS: BUGS-Shell."
|
||||
:group 'ess-bugs
|
||||
:prefix "ess-")
|
||||
|
||||
(defcustom ess-bugs-shell-buffer-name "BUGS"
|
||||
"*ESS[BUGS-Shell]: The name of the BUGS-Shell buffer."
|
||||
:group 'ess-bugs-shell
|
||||
:type 'string)
|
||||
|
||||
(defcustom ess-bugs-shell-command "OpenBUGS"
|
||||
"*ESS[BUGS-Shell]: The name of the command to run BUGS interactively.
|
||||
|
||||
Set to the name of the batch BUGS script that comes with ESS or
|
||||
to the name of BUGS command. Make sure it is in your PATH or
|
||||
add path to the command name."
|
||||
:group 'ess-bugs-shell
|
||||
:type 'string)
|
||||
|
||||
(defcustom ess-bugs-shell-default-output-file-root "bugs"
|
||||
"*ESS[BUGS-Shell]: Default value for the root of output files."
|
||||
:group 'ess-bugs-shell
|
||||
:type 'string)
|
||||
|
||||
(defcustom ess-bugs-shell-mode-hook nil
|
||||
"*ESS[BUGS-Shell]: List of functions to call upon entering mode."
|
||||
:group 'ess-bugs-shell
|
||||
:type 'hook)
|
||||
|
||||
(defun ess-bugs-shell ()
|
||||
"Create a buffer with BUGS running as a subprocess."
|
||||
(interactive)
|
||||
(require 'shell)
|
||||
(switch-to-buffer (concat "*" ess-bugs-shell-buffer-name "*"))
|
||||
(make-comint ess-bugs-shell-buffer-name ess-bugs-shell-command nil
|
||||
ess-bugs-default-bins ess-bugs-shell-default-output-file-root)
|
||||
(comint-mode)
|
||||
(setq shell-dirtrackp t
|
||||
major-mode 'bugs-shell-mode
|
||||
mode-name "ESS[BUGS-Shell]"
|
||||
comint-prompt-regexp "^Bugs> *")
|
||||
(make-local-variable 'font-lock-defaults)
|
||||
(setq font-lock-defaults '(ess-bugs-font-lock-keywords nil t))
|
||||
(run-hooks 'ess-bugs-shell-mode-hook)
|
||||
)
|
||||
|
||||
(provide 'ess-bugs-l)
|
||||
|
||||
;;; ess-bugs-l.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-bugs-l.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-bugs-l.elc
Normal file
Binary file not shown.
67
.emacs.d/elpa/ess-20160208.453/lisp/ess-comp.el
Normal file
67
.emacs.d/elpa/ess-20160208.453/lisp/ess-comp.el
Normal file
@@ -0,0 +1,67 @@
|
||||
;;; ess-comp.el --- setting for compiling, only.
|
||||
|
||||
;; Copyright (C) 1997--2006 A. J. Rossini
|
||||
;; Copyright (C) 1997--2006 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: A.J. Rossini <blindglobe@gmail.com>
|
||||
;; Created: 25 July 1997
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; Keywords: languages
|
||||
|
||||
;; This file is part of ESS
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This file sets up all compilation needs.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(provide 'ess-comp)
|
||||
|
||||
;; Emacs doesn't include '.' in the emacs lisp load path.
|
||||
(add-to-list 'load-path nil)
|
||||
|
||||
;; defvar'ed to nil in ./ess-site.el
|
||||
(setq ess-show-load-messages t)
|
||||
|
||||
(defun ess-message (format-string &rest args)
|
||||
"Shortcut for \\[message] only if `ess-show-load-messages' is non-nil."
|
||||
(if ess-show-load-messages (message format-string args)))
|
||||
|
||||
;; These are required by every other file.
|
||||
(ess-message "loading 'ess-compat ..") (require 'ess-compat) ;set Emacsen diffs
|
||||
(ess-message "loading 'ess-custom ..") (require 'ess-custom) ;set variables
|
||||
(ess-message "loading 'ess ..") (require 'ess) ;configure
|
||||
(ess-message "loading 'ess-site ..") (require 'ess-site) ;overload defaults
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-comp.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-comp.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-comp.elc
Normal file
Binary file not shown.
298
.emacs.d/elpa/ess-20160208.453/lisp/ess-compat.el
Normal file
298
.emacs.d/elpa/ess-20160208.453/lisp/ess-compat.el
Normal file
@@ -0,0 +1,298 @@
|
||||
;;; ess-compat.el --- simple determination of Emacs/XEmacs and version #.
|
||||
|
||||
;; Copyright (C) 2000--2005 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: A.J. Rossini <rossini@biostat.washington.edu>
|
||||
;; Created: 07 June 2000
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; Keywords: languages
|
||||
|
||||
;; This file is part of ESS
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This file contains functions for easily determining features of the
|
||||
;; version of Emacs that we are using. In particular, it look for
|
||||
;; version number, customize support, as well as Emacs/XEmacs, for
|
||||
;; flaggin support later on.
|
||||
|
||||
;;; Code:
|
||||
|
||||
;;; Define a function to make it easier to check which version we're
|
||||
;;; running.
|
||||
;; no longer in use; 2013-12-30:
|
||||
(defun ess-running-emacs-version-or-newer (major minor)
|
||||
(or (> emacs-major-version major)
|
||||
(and (= emacs-major-version major)
|
||||
(>= emacs-minor-version minor))))
|
||||
|
||||
;(defvar ess-running-xemacs (string-match "XEmacs\\|Lucid" emacs-version))
|
||||
|
||||
(defvar ess-local-custom-available (featurep 'custom)
|
||||
"Value is nil if custom.el not available, t if available.
|
||||
Only a concern with earlier versions of Emacs.")
|
||||
|
||||
;; FIXME: When emacs is started from Cygwin shell in Windows,
|
||||
;; we have (equal window-system 'x) -and should use "--ess" in *d-r.el
|
||||
(defvar ess-microsoft-p (or (eq system-type 'ms-dos)
|
||||
(eq system-type 'windows-nt))
|
||||
"Value is t if the OS is one of Microsoft's, nil otherwise.")
|
||||
|
||||
|
||||
;; These definitions are for Emacs versions < 20.4 or XEmacs
|
||||
;; These are taken verbatim from the file emacs-20.6/lisp/w32-fns.el
|
||||
;;
|
||||
;; Note: 20.3 and 19.x NTemacs users are strongly encouraged to upgrade to
|
||||
;; version 20.4 or higher. NTemacs 20.2 is not supported by ESS.
|
||||
|
||||
;; XEmacs 20.x needs this
|
||||
(if (not (fboundp 'find-buffer-visiting))
|
||||
(fset 'find-buffer-visiting 'get-file-buffer))
|
||||
;; XEmacs <= 21.4.15 needs this:
|
||||
(defalias 'ess-line-beginning-position
|
||||
(if (fboundp 'line-beginning-position)
|
||||
'line-beginning-position
|
||||
'point-at-bol))
|
||||
|
||||
(if (and (not (featurep 'xemacs))
|
||||
(string-match "XEmacs\\|Lucid" emacs-version))
|
||||
(provide 'xemacs))
|
||||
|
||||
;; XEmacs 21.x and Emacs 20.x need this
|
||||
(cond ((fboundp 'replace-regexp-in-string)
|
||||
(defalias 'ess-replace-regexp-in-string 'replace-regexp-in-string))
|
||||
((featurep 'xemacs)
|
||||
(defun ess-replace-regexp-in-string(regexp replace string)
|
||||
"Mimic GNU Emacs function replace-regexp-in-string with XEmacs' replace-in-string"
|
||||
(replace-in-string string regexp replace)))
|
||||
|
||||
;; GNU emacs <= 20 -- take Emacs' 21(.3)'s definition:
|
||||
(t (defun ess-replace-regexp-in-string (regexp rep string &optional
|
||||
fixedcase literal subexp start)
|
||||
"Replace all matches for REGEXP with REP in STRING.
|
||||
|
||||
Return a new string containing the replacements.
|
||||
|
||||
Optional arguments FIXEDCASE, LITERAL and SUBEXP are like the
|
||||
arguments with the same names of function `replace-match'. If START
|
||||
is non-nil, start replacements at that index in STRING.
|
||||
|
||||
REP is either a string used as the NEWTEXT arg of `replace-match' or a
|
||||
function. If it is a function it is applied to each match to generate
|
||||
the replacement passed to `replace-match'; the match-data at this
|
||||
point are such that match 0 is the function's argument.
|
||||
|
||||
To replace only the first match (if any), make REGEXP match up to \\'
|
||||
and replace a sub-expression, e.g.
|
||||
(ess-replace-regexp-in-string \"\\(foo\\).*\\'\" \"bar\" \" foo foo\" nil nil 1)
|
||||
=> \" bar foo\"
|
||||
"
|
||||
|
||||
;; To avoid excessive consing from multiple matches in long strings,
|
||||
;; don't just call `replace-match' continually. Walk down the
|
||||
;; string looking for matches of REGEXP and building up a (reversed)
|
||||
;; list MATCHES. This comprises segments of STRING which weren't
|
||||
;; matched interspersed with replacements for segments that were.
|
||||
;; [For a `large' number of replacments it's more efficient to
|
||||
;; operate in a temporary buffer; we can't tell from the function's
|
||||
;; args whether to choose the buffer-based implementation, though it
|
||||
;; might be reasonable to do so for long enough STRING.]
|
||||
(let ((l (length string))
|
||||
(start (or start 0))
|
||||
matches str mb me)
|
||||
(save-match-data
|
||||
(while (and (< start l) (string-match regexp string start))
|
||||
(setq mb (match-beginning 0)
|
||||
me (match-end 0))
|
||||
;; If we matched the empty string, make sure we advance by one char
|
||||
(when (= me mb) (setq me (min l (1+ mb))))
|
||||
;; Generate a replacement for the matched substring.
|
||||
;; Operate only on the substring to minimize string consing.
|
||||
;; Set up match data for the substring for replacement;
|
||||
;; presumably this is likely to be faster than munging the
|
||||
;; match data directly in Lisp.
|
||||
(string-match regexp (setq str (substring string mb me)))
|
||||
(setq matches
|
||||
(cons (replace-match (if (stringp rep)
|
||||
rep
|
||||
(funcall rep (match-string 0 str)))
|
||||
fixedcase literal str subexp)
|
||||
(cons (substring string start mb) ; unmatched prefix
|
||||
matches)))
|
||||
(setq start me))
|
||||
;; Reconstruct a string from the pieces.
|
||||
(setq matches (cons (substring string start l) matches)) ; leftover
|
||||
(apply #'concat (nreverse matches)))))
|
||||
)
|
||||
)
|
||||
|
||||
;; remassoc exists as a built-in function in xemacs, but
|
||||
;; not in GNU emacs
|
||||
;;
|
||||
(if (not (functionp 'remassoc))
|
||||
(defun remassoc (key a)
|
||||
"remove an association pair from an alist"
|
||||
(if a
|
||||
(let ((pair (car a)))
|
||||
(if (equal (car pair) key)
|
||||
(cdr a)
|
||||
(cons pair (remassoc key (cdr a))))))))
|
||||
|
||||
(if (not (fboundp 'w32-using-nt))
|
||||
(defun w32-using-nt ()
|
||||
"Return non-nil if literally running on Windows NT (i.e., not Windows 9X)."
|
||||
(and (eq system-type 'windows-nt) (getenv "SystemRoot"))))
|
||||
|
||||
(if (and (featurep 'xemacs)
|
||||
(fboundp 'extent-at)
|
||||
(fboundp 'make-extent)
|
||||
(fboundp 'set-extent-property))
|
||||
(defun ess-xemacs-insert-glyph (gl)
|
||||
"Insert a glyph at the left edge of point."
|
||||
(let ((prop 'myimage) ;; myimage is an arbitrary name, chosen to
|
||||
;; (hopefully) not conflict with any other
|
||||
;; properties. Change it if necessary.
|
||||
extent)
|
||||
;; First, check to see if one of our extents already exists at
|
||||
;; point. For ease-of-programming, we are creating and using our
|
||||
;; own extents (multiple extents are allowed to exist/overlap at the
|
||||
;; same point, and it's quite possible for other applications to
|
||||
;; embed extents in the current buffer without your knowledge).
|
||||
;; Basically, if an extent, with the property stored in "prop",
|
||||
;; exists at point, we assume that it is one of ours, and we re-use
|
||||
;; it (this is why it is important for the property stored in "prop"
|
||||
;; to be unique, and only used by us).
|
||||
(if (not (setq extent (extent-at (point) (current-buffer) prop)))
|
||||
(progn
|
||||
;; If an extent does not already exist, create a zero-length
|
||||
;; extent, and give it our special property.
|
||||
(setq extent (make-extent (point) (point) (current-buffer)))
|
||||
(set-extent-property extent prop t)
|
||||
))
|
||||
;; Display the glyph by storing it as the extent's "begin-glyph".
|
||||
(set-extent-property extent 'begin-glyph gl))))
|
||||
|
||||
;; XEmacs and NTemacs 19.x need these
|
||||
(if (not (boundp 'w32-system-shells))
|
||||
(defvar w32-system-shells '("cmd" "cmd.exe" "command" "command.com"
|
||||
"4nt" "4nt.exe" "4dos" "4dos.exe"
|
||||
"ndos" "ndos.exe")
|
||||
"List of strings recognized as Windows NT/9X system shells.")
|
||||
)
|
||||
|
||||
(if (not (fboundp 'w32-system-shell-p))
|
||||
(defun w32-system-shell-p (shell-name)
|
||||
(and shell-name
|
||||
(member (downcase (file-name-nondirectory shell-name))
|
||||
w32-system-shells)))
|
||||
)
|
||||
|
||||
(if (not (fboundp 'w32-shell-name))
|
||||
(defun w32-shell-name ()
|
||||
"Return the name of the shell being used."
|
||||
(or (and (boundp 'explicit-shell-file-name) explicit-shell-file-name)
|
||||
(getenv "ESHELL")
|
||||
(getenv "SHELL")
|
||||
(and (w32-using-nt) "cmd.exe")
|
||||
"command.com"))
|
||||
)
|
||||
|
||||
;; XEmacs and NTemacs 20.3 need this
|
||||
(if (not (fboundp 'w32-shell-dos-semantics)) (defun w32-shell-dos-semantics ()
|
||||
"Return t if the interactive shell being used expects msdos shell semantics."
|
||||
(or (w32-system-shell-p (w32-shell-name))
|
||||
(and (member (downcase (file-name-nondirectory (w32-shell-name)))
|
||||
'("cmdproxy" "cmdproxy.exe"))
|
||||
(w32-system-shell-p (getenv "COMSPEC")))))
|
||||
)
|
||||
|
||||
;; XEmacs need this (unless configured with --with-mule=yes)
|
||||
(if (not (boundp 'enable-multibyte-characters))
|
||||
(defvar enable-multibyte-characters nil
|
||||
"Non-nil means the buffer contents are regarded as multi-byte characters.
|
||||
This concept is handled completely differently on Xemacs."))
|
||||
|
||||
(defvar ess-has-tooltip
|
||||
(and (not (featurep 'xemacs))
|
||||
(>= emacs-major-version 21))
|
||||
"non-nil if 'tooltip can be required; typically nil for Xemacs.")
|
||||
|
||||
;; XEmacs on Windows needs this
|
||||
(if (and ess-microsoft-p
|
||||
(not (fboundp 'w32-short-file-name)))
|
||||
(cond ((fboundp 'win32-short-file-name)
|
||||
(fset 'w32-short-file-name 'win32-short-file-name))
|
||||
((fboundp 'mswindows-short-file-name)
|
||||
(fset 'w32-short-file-name 'mswindows-short-file-name))
|
||||
(t
|
||||
(warn "None of 'w32-short-file-name, 'win32-short-file-name,
|
||||
or 'mswindows-short-file-name are defined!
|
||||
You will have to manually set ess-program-files (in ess-custom.el) to
|
||||
the correct \"8.3\"-style directory name."))))
|
||||
|
||||
|
||||
(defun ess-sleep ()
|
||||
"Put emacs to sleep for `ess-sleep-for-shell' seconds (floats work).
|
||||
Sometimes its necessary to wait for a shell prompt."
|
||||
(if (featurep 'xemacs) (sleep-for ess-sleep-for-shell)
|
||||
(sleep-for 0 (truncate (* ess-sleep-for-shell 1000)))))
|
||||
|
||||
(unless (fboundp 'use-region-p)
|
||||
;; emacs 23 needs this
|
||||
(defun use-region-p ()
|
||||
"Return t if the region is active and it is appropriate to act on it.
|
||||
This is used by commands that act specially on the region under
|
||||
Transient Mark mode.
|
||||
|
||||
The return value is t if Transient Mark mode is enabled and the
|
||||
mark is active; furthermore, if `use-empty-active-region' is nil,
|
||||
the region must not be empty. Otherwise, the return value is nil.
|
||||
|
||||
For some commands, it may be appropriate to ignore the value of
|
||||
`use-empty-active-region'; in that case, use `region-active-p'."
|
||||
(and (region-active-p)
|
||||
(or use-empty-active-region (> (region-end) (region-beginning)))))
|
||||
|
||||
(defun region-active-p ()
|
||||
"Return t if Transient Mark mode is enabled and the mark is active.
|
||||
|
||||
Some commands act specially on the region when Transient Mark
|
||||
mode is enabled. Usually, such commands should use
|
||||
`use-region-p' instead of this function, because `use-region-p'
|
||||
also checks the value of `use-empty-active-region'."
|
||||
(and transient-mark-mode mark-active)))
|
||||
|
||||
(provide 'ess-compat)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-compat.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-compat.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-compat.elc
Normal file
Binary file not shown.
3131
.emacs.d/elpa/ess-20160208.453/lisp/ess-custom.el
Normal file
3131
.emacs.d/elpa/ess-20160208.453/lisp/ess-custom.el
Normal file
File diff suppressed because it is too large
Load Diff
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-custom.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-custom.elc
Normal file
Binary file not shown.
173
.emacs.d/elpa/ess-20160208.453/lisp/ess-dde.el
Normal file
173
.emacs.d/elpa/ess-20160208.453/lisp/ess-dde.el
Normal file
@@ -0,0 +1,173 @@
|
||||
;;; ess-dde.el --- ESS customization for ddeclients under Windows 9x/NT
|
||||
|
||||
;; Copyright (C) 1998--1999 Richard M. Heiberger <rmh@temple.edu>
|
||||
;; Copyright (C) 2000--2006 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: Richard M. Heiberger <rmh@temple.edu>
|
||||
;; Created: 9 Dec 1998
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; This file is part of ESS
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Code for dealing with running external processes on Windows 9x/NT
|
||||
;; through ddeclient.
|
||||
|
||||
;;; Code:
|
||||
|
||||
|
||||
;; *NO* Requires and autoloads
|
||||
|
||||
;; C-c C-r
|
||||
(defun ess-eval-region-ddeclient (start end even-empty)
|
||||
"Loop through lines in region and send them to ESS via ddeclient."
|
||||
(setq ;; set the following variables for the current ddeESS process.
|
||||
inferior-ess-ddeclient (ess-get-process-variable 'inferior-ess-ddeclient)
|
||||
inferior-ess-client-name (ess-get-process-variable 'inferior-ess-client-name)
|
||||
inferior-ess-client-command (ess-get-process-variable 'inferior-ess-client-command))
|
||||
(narrow-to-region start end)
|
||||
(goto-char (point-min))
|
||||
(let ((beg))
|
||||
(while (or (< (point) (point-max))
|
||||
(and (= 1 (point-max)) even-empty))
|
||||
(setq beg (point))
|
||||
(end-of-line)
|
||||
;; call-process-region won't send over a 0-character line.
|
||||
;; We go outside the loop to create a 1-character line " " in the
|
||||
;; *ESS-temporary* buffer
|
||||
(if (= beg (point)) ;; do empty line outside loop
|
||||
(ess-eval-linewise-ddeclient " " nil 'eob t)
|
||||
;;(call-process-region start end
|
||||
;; "ddeclient" nil nil nil "S-PLUS" "SCommand")
|
||||
(call-process-region
|
||||
beg (point)
|
||||
inferior-ess-ddeclient nil nil nil
|
||||
inferior-ess-client-name inferior-ess-client-command))
|
||||
(forward-line 1))
|
||||
(widen)))
|
||||
|
||||
;; C-c C-n
|
||||
(defun ess-eval-linewise-ddeclient (text-withtabs &optional
|
||||
invisibly eob even-empty
|
||||
sleep-sec)
|
||||
(with-current-buffer (get-buffer-create "*ESS-temporary*")
|
||||
(ess-setq-vars-local ess-customize-alist (current-buffer))
|
||||
(erase-buffer)
|
||||
(insert text-withtabs)
|
||||
(ess-eval-region-ddeclient (point-min) (point-max) even-empty))
|
||||
(if (numberp sleep-sec)
|
||||
(sleep-for sleep-sec))); in addition to timeout-ms
|
||||
|
||||
;; C-c C-v
|
||||
(defun ess-display-help-on-object-ddeclient (object)
|
||||
"Display the ESS documentation for OBJECT in another window.
|
||||
If prefix arg is given, forces a query of the ESS process for the help
|
||||
file. Otherwise just pops to an existing buffer if it exists."
|
||||
(ess-force-buffer-current "Process to load into: ")
|
||||
(ess-eval-linewise-ddeclient (concat "help(" object ")")))
|
||||
|
||||
|
||||
;; C-c C-l
|
||||
(defun ess-load-file-ddeclient (filename)
|
||||
"Load an S source file into an inferior ESS process; alternate behavior for
|
||||
`ess-load-file', required with S-Plus GUI for Windows: Sends the S-Plus command
|
||||
source(\"filename\") to S. This version does not guarantee to save .Last.value,
|
||||
nor offer alternate buffers or editing capability."
|
||||
(let ((source-buffer (get-file-buffer filename)))
|
||||
(if (ess-check-source filename)
|
||||
(error "Buffer %s has not been saved" (buffer-name source-buffer))
|
||||
;; Find the process to load into
|
||||
(if source-buffer
|
||||
(with-current-buffer source-buffer
|
||||
(ess-force-buffer-current "Process to load into: ")
|
||||
;; (ess-check-modifications) ;;; not possible with ddeclient
|
||||
;; it calls ess-command which requires two-way communication
|
||||
;; with the S-Plus process
|
||||
)))
|
||||
(ess-eval-linewise-ddeclient (format ess-load-command filename)))
|
||||
(widen))
|
||||
|
||||
|
||||
;; C-c C-d
|
||||
(defun ess-dump-object-ddeclient (object filename)
|
||||
"Dump the ESS object OBJECT into file FILENAME."
|
||||
(ess-force-buffer-current "Process to load into: ")
|
||||
(ess-eval-linewise-ddeclient (concat "dump('" object "','" filename "')"))
|
||||
(sleep-for 5)
|
||||
(find-file filename)
|
||||
(widen))
|
||||
|
||||
|
||||
(defun ess-dput-expression-ddeclient (object filename)
|
||||
"Dump the ESS object found by evaluating OBJECT into file FILENAME."
|
||||
(ess-force-buffer-current "Process to load into: ")
|
||||
(ess-eval-linewise-ddeclient (concat "dput(" object ",'" filename "')"))
|
||||
(sleep-for 2)
|
||||
(find-file filename))
|
||||
|
||||
(defun ess-command-ddeclient-proposed (com &optional buf sleep)
|
||||
"ddeclient version of real `ess-command'.
|
||||
Send the ESS process command COM and redirect its output to the
|
||||
temporary file named BUF. The temporary filename is constructed
|
||||
in emacs, not in the ESS process. The default name for the
|
||||
temporary buffer is \"ess-temp.st\". The function waits
|
||||
SLEEP (which defaults to 1) seconds and then brings the temporary
|
||||
file into an emacs buffer and displays it."
|
||||
(let (filename bufname)
|
||||
(if (not buf) (setq buf "ess-temp.st"))
|
||||
(if (not sleep) (setq sleep 1))
|
||||
(setq filename (concat (file-name-as-directory (getenv "TEMP")) buf))
|
||||
(ess-eval-linewise-ddeclient
|
||||
(concat ".old.Last.value <- .Last.value; sink('"
|
||||
filename
|
||||
"'); print("
|
||||
com
|
||||
"); sink(); .Last.value <- .old.Last.value"))
|
||||
(setq bufname (ess-get-file-or-buffer filename)) ;; must follow the eval
|
||||
(sleep-for sleep)
|
||||
(if (not bufname)
|
||||
(find-file filename)
|
||||
(switch-to-buffer bufname))
|
||||
(revert-buffer t t) ;; this allows the user to reuse the BUF name
|
||||
))
|
||||
|
||||
;; previous version (ESS-5.2.12 and earlier)
|
||||
(defun ess-command-ddeclient (com &optional buf sleep)
|
||||
"ddeclient bypass of real ess-command"
|
||||
(ess-eval-linewise com))
|
||||
|
||||
(provide 'ess-dde)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-dde.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-dde.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-dde.elc
Normal file
Binary file not shown.
92
.emacs.d/elpa/ess-20160208.453/lisp/ess-debug.el
Normal file
92
.emacs.d/elpa/ess-20160208.453/lisp/ess-debug.el
Normal file
@@ -0,0 +1,92 @@
|
||||
;;; ess-debug.el --- debugging start up for ESS
|
||||
|
||||
;; Copyright (C) 1997--2001 A.J. Rossini
|
||||
;; Copyright (C) 2001--2006 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: A.J. Rossini <rossini@biostat.washington.edu>
|
||||
;; Created: November 1997
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; Keywords: languages, tools
|
||||
|
||||
;; This file is part of ESS.
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to
|
||||
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Strictly for debugging and development. usage is:
|
||||
;; xemacs -no-site-file -no-init-file -load ess-debug.el -f S4
|
||||
;; (or similar!)
|
||||
;;
|
||||
;; The whole point of this file is to enable debugging from a vanilla
|
||||
;; environment. It probably isn't needed too much right now.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defun ess-add-path (path &rest options)
|
||||
"Add PATH to `load-path' if it exists under `default-load-path'
|
||||
directories and it does not exist in `load-path'.
|
||||
|
||||
You can use following PATH styles:
|
||||
load-path relative: \"PATH/\"
|
||||
(it is searched from `default-load-path')
|
||||
home directory relative: \"~/PATH/\" \"~USER/PATH/\"
|
||||
absolute path: \"/HOO/BAR/BAZ/\"
|
||||
|
||||
You can specify following OPTIONS:
|
||||
'all-paths search from `load-path'
|
||||
instead of `default-load-path'
|
||||
'append add PATH to the last of `load-path'.
|
||||
|
||||
For ESS, ONLY use load-path, since Emacs doesn't have
|
||||
default-load-path."
|
||||
|
||||
(let ((rest load-path)
|
||||
p)
|
||||
(if (and (catch 'tag
|
||||
(while rest
|
||||
(setq p (expand-file-name path (car rest)))
|
||||
(if (file-directory-p p)
|
||||
(throw 'tag p))
|
||||
(setq rest (cdr rest))))
|
||||
(not (member p load-path)))
|
||||
(setq load-path
|
||||
(if (memq 'append options)
|
||||
(append load-path (list p))
|
||||
(cons p load-path))))))
|
||||
|
||||
(setq-default debug-on-error t)
|
||||
(ess-add-path "~rossini/Repos/repos-svn/ess/lisp")
|
||||
;; ^^adapt!!!^^^^^^^^^^^^^^^
|
||||
(require 'ess-site)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-debug.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-debug.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-debug.elc
Normal file
Binary file not shown.
472
.emacs.d/elpa/ess-20160208.453/lisp/ess-developer.el
Normal file
472
.emacs.d/elpa/ess-20160208.453/lisp/ess-developer.el
Normal file
@@ -0,0 +1,472 @@
|
||||
;;; ess-developer.el --- Developer mode for R.
|
||||
|
||||
;; Copyright (C) 2011-2015 V. Spinu, A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: Vitalie Spinu
|
||||
;; Created: 12-11-2011
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; Keywords: languages, tools
|
||||
|
||||
;; This file is part of ESS.
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; see apropriate documentation section of ESS user manual
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; (require 'ess-site) ;; need to assigne the keys in the map
|
||||
|
||||
(defgroup ess-developer nil
|
||||
"ESS: developer."
|
||||
:group 'ess
|
||||
:prefix "ess-developer-")
|
||||
|
||||
(defface ess-developer-indicator-face
|
||||
'((((class grayscale)) (:background "DimGray"))
|
||||
(((class color) (background light))
|
||||
(:foreground "red4" :bold t ))
|
||||
(((class color) (background dark))
|
||||
(:foreground "deep sky blue" :bold t )))
|
||||
"Face to highlight mode line process name when developer mode is on."
|
||||
:group 'ess-developer)
|
||||
|
||||
(defcustom ess-developer-packages nil
|
||||
"List of names of R packages you currently develop.
|
||||
Set this variable to the list of packages you commonly develop or
|
||||
use `ess-developer-add-package' to modify interactively this
|
||||
list."
|
||||
:group 'ess-developer
|
||||
:type 'list)
|
||||
|
||||
(defcustom ess-developer-load-package-command "library(devtools)\nload_all('%s')\n"
|
||||
"Command issued by `ess-developer-load-package'.
|
||||
%s is subsituted with the user supplied directory."
|
||||
:group 'ess-developer
|
||||
:type 'string)
|
||||
|
||||
(defvar ess-developer-root-file "DESCRIPTION"
|
||||
"If this file is present in the directory, it is considered a
|
||||
project root.")
|
||||
|
||||
;; (defcustom ess-developer-force-attach nil
|
||||
;; "If non-nill all the packages listed in `ess-developer-packages' should be attached
|
||||
;; when ess-developer mode is turned on."
|
||||
;; :group 'ess-developer
|
||||
;; :type 'boolean)
|
||||
|
||||
(defcustom ess-developer-enter-hook nil
|
||||
"Normal hook run on entering `ess-developer' mode."
|
||||
:group 'ess-developer
|
||||
:type 'hook)
|
||||
|
||||
(defcustom ess-developer-exit-hook nil
|
||||
"Normal hook run on exiting `ess-developer' mode."
|
||||
:group 'ess-developer
|
||||
:type 'hook)
|
||||
|
||||
(defcustom ess-developer-activate-in-package t
|
||||
"If non-nil, `ess-developer' is automatically turned on within R packages.
|
||||
The activation is triggered only for packages currently listed in
|
||||
`ess-developer-packages'."
|
||||
:group 'ess-developer
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom ess-developer-load-on-add-commands '(("library" . "library(%n)")
|
||||
("load_all" . "library(devtools)\nload_all('%d')"))
|
||||
"Alist of available load commands what are proposed for loading
|
||||
on `ess-developer-add-package'.
|
||||
|
||||
%n is replaced with package name,
|
||||
%d is replaced with package directory.
|
||||
|
||||
See also `ess-developer-load-package' for related functionality."
|
||||
:group 'ess-developer
|
||||
:type 'alist)
|
||||
|
||||
(defvar ess-developer--load-hist nil)
|
||||
|
||||
(defun ess-developer-add-package (&optional attached-only)
|
||||
"Add a package to `ess-developer-packages' list.
|
||||
With prefix argument only choose from among attached packages."
|
||||
(interactive "P")
|
||||
(ess-force-buffer-current)
|
||||
(let* ((packs (ess-get-words-from-vector
|
||||
(format "print(unique(c(.packages(), %s)), max=1e6)\n"
|
||||
(if attached-only "NULL" ".packages(TRUE)"))))
|
||||
(cur-pack (ess-developer--get-package-name))
|
||||
(sel (ess-completing-read "Add package" packs nil nil nil nil
|
||||
(unless (member cur-pack ess-developer-packages)
|
||||
cur-pack)))
|
||||
(check-attached (format ".ess_package_attached('%s')\n" sel)))
|
||||
(unless (ess-boolean-command check-attached)
|
||||
(let* ((fn (if (> (length ess-developer-load-on-add-commands) 1)
|
||||
(ess-completing-read "Package not loaded. Use"
|
||||
(mapcar 'car ess-developer-load-on-add-commands) nil t
|
||||
nil 'ess-developer--load-hist
|
||||
(car ess-developer--load-hist))
|
||||
(caar ess-developer-load-on-add-commands)))
|
||||
(cmd (cdr (assoc fn ess-developer-load-on-add-commands))))
|
||||
(setq cmd (replace-regexp-in-string "%n" sel cmd))
|
||||
(when (string-match-p "%d" cmd)
|
||||
(let ((dir (read-directory-name
|
||||
"Package: " (ess-developer--get-package-path sel) nil t nil)))
|
||||
(setq cmd (replace-regexp-in-string "%d" dir cmd))))
|
||||
(ess-eval-linewise (concat cmd "\n")))
|
||||
(ess-wait-for-process)
|
||||
(when (not (ess-boolean-command check-attached))
|
||||
(error "Package '%s' could not be added" sel)))
|
||||
(setq ess-developer-packages
|
||||
(ess-uniq-list (append ess-developer-packages (list sel))))
|
||||
;; turn developer in all files from selected package
|
||||
(ess-developer-activate-in-package sel 'all)
|
||||
(message "You are developing: %s" ess-developer-packages)))
|
||||
|
||||
(defun ess-developer-remove-package ()
|
||||
"Remove packages from `ess-developer-packages' list; defaults to *ALL*."
|
||||
(interactive)
|
||||
(unless ess-developer-packages
|
||||
(error "Nothing to remove, 'ess-developer-packages' is empty"))
|
||||
(let ((sel (ess-completing-read "Remove package(s)"
|
||||
(append ess-developer-packages (list "*ALL*"))
|
||||
nil t nil nil "*ALL*")))
|
||||
(if (equal "*ALL*" sel)
|
||||
(progn
|
||||
(setq ess-developer-packages nil)
|
||||
(ess-developer-deactivate-in-package nil 'all)
|
||||
(message "Removed *ALL* packages from the `ess-developer-packages' list."))
|
||||
(setq ess-developer-packages (delete sel ess-developer-packages))
|
||||
(ess-developer-deactivate-in-package sel 'all)
|
||||
(message "Removed package '%s' from the `ess-developer-packages' list"
|
||||
(propertize sel 'face 'font-lock-function-name-face)))))
|
||||
|
||||
(defun ess-developer-send-region-fallback (proc beg end visibly &optional message tracebug func)
|
||||
(if tracebug
|
||||
(ess-tracebug-send-region proc beg end visibly message t)
|
||||
(ess-send-region proc beg end visibly message)))
|
||||
|
||||
(defun ess-developer-source-current-file (&optional filename)
|
||||
"Ask for namespace to source the current file into.
|
||||
If *current* is selected just invoke source('file_name'),
|
||||
otherwise call devSource."
|
||||
(interactive)
|
||||
(ess-force-buffer-current "R process to use: ")
|
||||
(unless ess-developer
|
||||
(error "Ess-developer mode is not active"))
|
||||
(if (not (or filename
|
||||
buffer-file-name))
|
||||
(error "Buffer '%s' doesn't visit a file" (buffer-name (current-buffer)))
|
||||
(let* ((filename (or filename buffer-file-name))
|
||||
(file (file-name-nondirectory filename))
|
||||
(all-packs (append ess-developer-packages (list "*current*" )))
|
||||
(default (car (member (car ess-developer--hist) all-packs)))
|
||||
(env (ess-completing-read (format "devSource '%s' into" file)
|
||||
all-packs nil t nil 'ess-developer--hist default))
|
||||
(comm (if (equal env "*current*")
|
||||
(format "source(file=\"%s\", local=F)\n cat(\"Sourced file '%s' into\", capture.output(environment()), '\n')" filename file)
|
||||
(format ".essDev_source(source='%s',package='%s')" filename env))))
|
||||
(when (buffer-modified-p) (save-buffer))
|
||||
(message "devSourcing '%s' ..." file)
|
||||
(ess-developer--command comm 'ess-developer--propertize-output))))
|
||||
|
||||
(defun ess-developer--exists-in-ns (var ns)
|
||||
;; If namespace does not exist, the R code below throw an error. But that's equivalent to FALSE.
|
||||
(let ((cmd "as.character(exists('%s', envir=asNamespace('%s'), mode='function', inherits=FALSE))\n"))
|
||||
(ess-boolean-command
|
||||
(format cmd var ns))))
|
||||
|
||||
(defun ess-developer-send-function (proc beg end name &optional visibly message tracebug)
|
||||
(save-excursion
|
||||
(if (null ess-developer-packages)
|
||||
(error "`ess-developer-packages' is empty (add packages with C-c C-t C-a).")
|
||||
(if (null name)
|
||||
(error "Oops, could not find function name (probably a regexp bug)")
|
||||
(let ((nms (ess-get-words-from-vector "loadedNamespaces()\n"))
|
||||
(dev-packs ess-developer-packages)
|
||||
(default-ns (ess-developer--get-package-name))
|
||||
assigned-p ns)
|
||||
(if (string-match-p ess-set-function-start (concat name "("))
|
||||
;; if setMethod, setClass etc, do send region
|
||||
(ess-developer-send-region proc beg end visibly message tracebug)
|
||||
(when tracebug (ess-tracebug-set-last-input proc))
|
||||
(if (member default-ns dev-packs)
|
||||
(ess-developer-devSource beg end default-ns message)
|
||||
;; iterate over all developed packages and check if functions
|
||||
;; exists in that namespace
|
||||
(while (and (setq ns (pop dev-packs))
|
||||
(not assigned-p))
|
||||
(when (and (member ns nms)
|
||||
(ess-developer--exists-in-ns name ns))
|
||||
(ess-developer-devSource beg end ns message)
|
||||
(setq assigned-p t)))
|
||||
;; last resort - assign in current env
|
||||
(unless assigned-p
|
||||
(ess-developer-send-region-fallback proc beg end visibly message tracebug)))))))))
|
||||
|
||||
(defvar ess-developer--hist nil)
|
||||
|
||||
(defun ess-developer-send-region (proc beg end &optional visibly message tracebug)
|
||||
"Ask for for the package and devSource region into it."
|
||||
(let* ((all-packs (append ess-developer-packages (list "*current*" )))
|
||||
(default (car (member (car ess-developer--hist) all-packs)))
|
||||
(package
|
||||
(ess-completing-read "devEval into" all-packs
|
||||
nil t nil 'ess-developer--hist default)))
|
||||
(message (if message (format "dev%s ..." message)))
|
||||
(if (equal package "*current*")
|
||||
(ess-developer-send-region-fallback proc beg end visibly message tracebug)
|
||||
;; else, (ignore VISIBLY here)
|
||||
(ess-developer-devSource beg end package message))))
|
||||
|
||||
(defun ess-developer-devSource (beg end package &optional message)
|
||||
(let* ((ess-eval-command
|
||||
(format ".essDev.eval(\"%s\", package=\"%s\", file=\"%s\")" "%s" package "%f"))
|
||||
(ess-eval-visibly-command ess-eval-command)
|
||||
(ess-eval-visibly-noecho-command ess-eval-command))
|
||||
(if message (message message))
|
||||
(ess-developer--command (ess--make-source-refd-command beg end)
|
||||
'ess-developer--propertize-output)))
|
||||
|
||||
(defun ess-developer--command (comm &optional propertize-func)
|
||||
"Evaluate the command and popup a message with the output if succed.
|
||||
On error insert the error at the end of the inferior-ess buffer.
|
||||
|
||||
PROPERTIZE-FUNC is a function called with the output buffer being
|
||||
current. usually used to manipulate the output, for example to
|
||||
propertize output text.
|
||||
"
|
||||
(setq comm (format "eval({cat(\"\\n\")\n%s\ncat(\"!@OK@!\")})\n" comm))
|
||||
(let ((buff (get-buffer-create " *ess-command-output*"))
|
||||
out)
|
||||
(ess-command comm buff nil nil 0.1)
|
||||
(with-current-buffer buff
|
||||
(goto-char (point-min))
|
||||
(delete-region (point) (min (point-max) ;; delete + + +
|
||||
(1+ (point-at-eol))))
|
||||
(goto-char (point-max))
|
||||
(if (re-search-backward "!@OK@!" nil t)
|
||||
(progn
|
||||
(when (fboundp propertize-func)
|
||||
(save-excursion (funcall propertize-func)))
|
||||
(message "%s" (buffer-substring (point-min) (max (point-min)
|
||||
(1- (point))))))
|
||||
(message "%s" (buffer-substring-no-properties (point-min) (point-max)))))))
|
||||
|
||||
(defun ess-developer--propertize-output ()
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "\\(FUN\\|CLS\\|METH\\)\\[" nil t)
|
||||
(put-text-property (match-beginning 1) (match-end 1)
|
||||
'face 'font-lock-function-name-face))
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "\\([^ \t]+\\):" nil t)
|
||||
(put-text-property (match-beginning 1) (match-end 1)
|
||||
'face 'font-lock-keyword-face)))
|
||||
|
||||
(defvar ess-developer--pack-name nil)
|
||||
(make-variable-buffer-local 'ess-developer--pack-name)
|
||||
|
||||
(defun ess-developer--get-package-path (&optional pack-name)
|
||||
"Get the root of R package that contains current directory.
|
||||
Root is determined by locating `ess-developer-root-file'.
|
||||
|
||||
If PACK-NAME is given, iterate over default-directories of all
|
||||
open R files till package with name pack-name is found. If not
|
||||
found, return nil."
|
||||
(if pack-name
|
||||
(let ((bl (buffer-list))
|
||||
path bf)
|
||||
(while (and (setq bf (pop bl))
|
||||
(not path))
|
||||
(when (buffer-local-value 'ess-dialect bf)
|
||||
(with-current-buffer bf
|
||||
(setq path (ess-developer--get-package-path))
|
||||
(unless (equal pack-name (ess-developer--get-package-name))
|
||||
(setq path nil)))))
|
||||
path)
|
||||
(let ((path (directory-file-name default-directory)))
|
||||
(when (string= "R" (file-name-nondirectory path))
|
||||
(setq path (file-name-directory path))
|
||||
(when (file-exists-p (expand-file-name ess-developer-root-file path))
|
||||
path)))
|
||||
;; This following version is incredibly slow on remotes:
|
||||
;; (let ((path default-directory)
|
||||
;; opath package)
|
||||
;; (while (and path
|
||||
;; (not package)
|
||||
;; (not (equal path opath)))
|
||||
;; (if (file-exists-p (expand-file-name ess-developer-root-file path))
|
||||
;; (setq package path)
|
||||
;; (setq opath path
|
||||
;; path (file-name-directory (directory-file-name path)))))
|
||||
;; package)
|
||||
))
|
||||
|
||||
(defun ess-developer--get-package-name (&optional path force)
|
||||
"Find package name in path. Parses DESCRIPTION file in PATH (R
|
||||
specific so far). PATH defaults to the value returned
|
||||
by (ess-developer--get-package-path).
|
||||
|
||||
If FORCE is non-nil, don't check for buffer local cached value of
|
||||
the package name."
|
||||
(or (and (not force)
|
||||
ess-developer--pack-name)
|
||||
(when (setq path (or path (ess-developer--get-package-path)))
|
||||
(let ((file (expand-file-name ess-developer-root-file path))
|
||||
(case-fold-search t))
|
||||
(when (file-exists-p file)
|
||||
(with-temp-buffer
|
||||
(insert-file-contents file)
|
||||
(goto-char (point-min))
|
||||
(re-search-forward "package: \\(.*\\)")
|
||||
(setq ess-developer--pack-name (match-string 1))))))))
|
||||
|
||||
(defun ess-developer-activate-in-package (&optional package all)
|
||||
"Activate developer if current file is part of a package which
|
||||
is registered in `ess-developer-packages'.
|
||||
|
||||
If PACKAGE is given, activate only if current file is part of the
|
||||
PACKAGE, `ess-developer-packages' is ignored in this case.
|
||||
|
||||
If ALL is non-nil, perform activation in all R buffers.
|
||||
|
||||
This function does nothing if `ess-developer-activate-in-package'
|
||||
is nil."
|
||||
(when ess-developer-activate-in-package
|
||||
(if all
|
||||
(dolist (bf (buffer-list))
|
||||
(with-current-buffer bf
|
||||
(ess-developer-activate-in-package package)))
|
||||
(let ((pack (ess-developer--get-package-name)))
|
||||
(when (and buffer-file-name
|
||||
pack
|
||||
(not ess-developer)
|
||||
(if package
|
||||
(equal pack package)
|
||||
(member pack ess-developer-packages)))
|
||||
(ess-developer t))))))
|
||||
|
||||
(defun ess-developer-deactivate-in-package (&optional package all)
|
||||
"Deactivate developer if current file is part of the R package.
|
||||
|
||||
If PACKAGE is given, deactivate only if current package is
|
||||
PACKAGE.
|
||||
|
||||
If ALL is non-nil, deactivate in all open R buffers."
|
||||
(if all
|
||||
(dolist (bf (buffer-list))
|
||||
(with-current-buffer bf
|
||||
(ess-developer-deactivate-in-package package)))
|
||||
(let ((pack (ess-developer--get-package-name)))
|
||||
(when (and ess-developer
|
||||
(or (null package)
|
||||
(equal pack package)))
|
||||
(ess-developer -1)))))
|
||||
|
||||
(defun ess-developer-load-package ()
|
||||
"Interface to load_all function from devtools package."
|
||||
(interactive)
|
||||
(ess-force-buffer-current)
|
||||
(let ((package (ess-developer--get-package-path)))
|
||||
(unless (and package ess-developer)
|
||||
;; ask only when not obvious
|
||||
(setq package
|
||||
(read-directory-name "Package: " package nil t nil)))
|
||||
(unless (file-exists-p (expand-file-name ess-developer-root-file package))
|
||||
(error "Not a valid package. No '%s' found in `%s'."
|
||||
ess-developer-root-file package))
|
||||
(message "Loading %s" (abbreviate-file-name package))
|
||||
(ess-eval-linewise
|
||||
(format ess-developer-load-package-command package))))
|
||||
|
||||
(defvar ess-developer nil
|
||||
"Non nil in buffers where developer mode is active")
|
||||
(make-variable-buffer-local 'ess-developer)
|
||||
|
||||
;; Since the ESSR package, this one is not needed:
|
||||
;; (defun ess-developer--inject-source-maybe ()
|
||||
;; ;; puting this into ESSR.R makes loading very slow
|
||||
;; ;; when ESSR is a package, this should go away
|
||||
;; (let ((devR-file (concat (file-name-directory ess-etc-directory)
|
||||
;; "ess-developer.R")))
|
||||
;; (unless (ess-boolean-command
|
||||
;; "exists('.essDev_source', envir = .ESSR_Env)\n")
|
||||
;; (unless (file-exists-p devR-file)
|
||||
;; (error "Cannot locate 'ess-developer.R' file"))
|
||||
;; (message "Injecting ess-developer code ...")
|
||||
;; (ess--inject-code-from-file devR-file)
|
||||
;; (unless (ess-boolean-command "exists('.essDev_source', envir = .ESSR_Env)\n")
|
||||
;; (error "Could not source ess-developer.R. Please investigate the output of *ess-command-output* buffer for errors")))))
|
||||
|
||||
(defun ess-developer (&optional val)
|
||||
"Toggle on/off `ess-developer' functionality.
|
||||
If optional VAL is non-negative, turn on the developer mode. If
|
||||
VAL is negative turn it off.
|
||||
|
||||
See also `ess-developer-packages', `ess-developer-add-package'
|
||||
and `ess-developer-activate-in-package'."
|
||||
(interactive)
|
||||
(when (eq val t) (setq val 1))
|
||||
(let ((ess-dev (if (numberp val)
|
||||
(if (< val 0) nil t)
|
||||
(not ess-developer))))
|
||||
(if ess-dev
|
||||
(progn
|
||||
(run-hooks 'ess-developer-enter-hook)
|
||||
(if ess-developer-packages
|
||||
(message "You are developing: %s" ess-developer-packages)
|
||||
(message "Developer is on (add packages with C-c C-t a)")))
|
||||
(run-hooks 'ess-developer-exit-hook)
|
||||
(message "%s developer is off" (if (get-buffer-process (current-buffer))
|
||||
"Global"
|
||||
"Local")))
|
||||
|
||||
(setq ess-developer ess-dev))
|
||||
(force-window-update))
|
||||
|
||||
(defalias 'ess-toggle-developer 'ess-developer)
|
||||
|
||||
|
||||
|
||||
;;; MODELINE
|
||||
|
||||
(defvar ess-developer--local-indicator
|
||||
'(""
|
||||
(:eval
|
||||
;; process has priority
|
||||
(if (and (ess-process-live-p)
|
||||
(ess-get-process-variable 'ess-developer))
|
||||
(propertize " D" 'face 'ess-developer-indicator-face)
|
||||
(if ess-developer
|
||||
(propertize " d" 'face 'ess-developer-indicator-face)
|
||||
"")))))
|
||||
(put 'ess-developer--local-indicator 'risky-local-variable t)
|
||||
|
||||
(defun ess-developer-setup-modeline ()
|
||||
(add-to-list 'ess--local-mode-line-process-indicator
|
||||
'ess-developer--local-indicator 'append))
|
||||
|
||||
|
||||
|
||||
;;; HOOKS
|
||||
|
||||
(add-hook 'R-mode-hook 'ess-developer-activate-in-package)
|
||||
(add-hook 'R-mode-hook 'ess-developer-setup-modeline)
|
||||
(add-hook 'inferior-ess-mode-hook 'ess-developer-setup-modeline)
|
||||
|
||||
(provide 'ess-developer)
|
||||
;;; ess-developer.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-developer.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-developer.elc
Normal file
Binary file not shown.
176
.emacs.d/elpa/ess-20160208.453/lisp/ess-eldoc.el
Normal file
176
.emacs.d/elpa/ess-20160208.453/lisp/ess-eldoc.el
Normal file
@@ -0,0 +1,176 @@
|
||||
;;; ess-eldoc.el --- Use eldoc to report R function names.
|
||||
|
||||
;; Copyright (C) 1997--2009 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: Stephen Eglen
|
||||
;; Created: 2007-06-30
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; This file is part of ESS
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;;;; eldoc funcitonality has been moved into the core ;;;;;
|
||||
;;;;; this file has no effect and is left in ESS in order not to break
|
||||
;;;;; users configuration
|
||||
|
||||
;; This is an initial attempt to use the emacs facility ELDOC in R
|
||||
;; buffers. Eldoc is used in Emacs lisp buffers to show the function
|
||||
;; arglist and docstrings for variables. To try it, view an emacs
|
||||
;; lisp buffer, and then do M-x turn-on-eldoc-mode, and move over
|
||||
;; function and variable names.
|
||||
|
||||
;; This file extends eldoc to work in R buffers. It currently uses
|
||||
;; Sven's ess-r-args.el file to retrieve args for a given R function
|
||||
;; (via ess-r-args-get). Note that it works slightly different to
|
||||
;; Sven's code, in that you just need to have the point over the name
|
||||
;; of an R function, or inside its arguments list, for eldoc to show
|
||||
;; the arg list.
|
||||
|
||||
;; To use this functionality, simply add
|
||||
;;
|
||||
;; (require 'ess-eldoc)
|
||||
;;
|
||||
;; to your .emacs file. When you visit a R mode, eldoc will be turned
|
||||
;; on. However, you will first need to associate the R buffer with an
|
||||
;; *R* process so that args can be looked up -- otherwise, eldoc will
|
||||
;; silently not report anything. So, e.g. try:
|
||||
;; C-x C-f somefile.R
|
||||
;; M-x R (so that somefile.R is associated with *R*)
|
||||
;; eldoc should then work.
|
||||
|
||||
;; e.g. put the following rnorm() command in an R buffer. The line
|
||||
;; underneath shows a key of what arg list will be shown as you move
|
||||
;; across the rnorm line.
|
||||
|
||||
;; rnorm(n=100, mean=sqrt(20), sd=10)
|
||||
;; 1111111111111222223333333311444111
|
||||
;; 1: rnorm
|
||||
;; 2: mean
|
||||
;; 3: sqrt
|
||||
;; 4: sd
|
||||
;;
|
||||
|
||||
;; Note that the arg list for rnorm() should be shown either when you
|
||||
;; are on the function name, or in the arg list. However, since the
|
||||
;; 2nd and 3rd arguments are also function names, the arg lists of
|
||||
;; those function names are reported instead. This might be seen as
|
||||
;; undesirable behaviour, in which case a solution would be to only
|
||||
;; look up the function name if it is followed by (.
|
||||
|
||||
;; If you want to use this feature in *R* buffers, add the following
|
||||
;; to .emacs:
|
||||
;; (add-hook 'inferior-ess-mode-hook 'ess-use-eldoc)
|
||||
|
||||
|
||||
;; In the current version, I do not cache the arg list, but that was
|
||||
;; done in an earlier version, to save repeated calls to
|
||||
;; ess-r-args-get.
|
||||
|
||||
;; This code has been tested only in Emacs 22.1. It will not work on
|
||||
;; Emacs 21, because it needs the variable
|
||||
;; eldoc-documentation-function.
|
||||
|
||||
;;;; VS [25-02-2012]: all these issues were at least partially addresed in the
|
||||
;;;; new implementation:
|
||||
|
||||
;; Bug (in eldoc?): the arg list for legend() is too long to fit in
|
||||
;; minibuffer, and it seems that we see the last N lines of the arg
|
||||
;; list, rather than the first N lines. It would be better to see the
|
||||
;; first N lines since the more important args come first.
|
||||
|
||||
;; Doc issue: the eldoc vars (e.g. eldoc-echo-area-use-multiline-p)
|
||||
;; work only for elisp mode.
|
||||
|
||||
;; Issue: You will probably see the message "Using process 'R'" flash;
|
||||
;; this is generated by `ess-request-a-process', and I'd like to avoid
|
||||
;; that appearing, non-interactively.
|
||||
|
||||
;; If *R* is currently busy (e.g. processing Sys.sleep(999)), then the
|
||||
;; eldoc commands won't work; ess-command could be silenced in this
|
||||
;; regard perhaps with a new SILENT arg for example to prevent the
|
||||
;; call to (ess-error).
|
||||
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; ;; This could be done on buffer local basis.
|
||||
;; (setq ess-r-args-noargsmsg "")
|
||||
|
||||
;; ;; following two defvars are not currently used.
|
||||
;; (defvar ess-eldoc-last-name nil
|
||||
;; "Name of the last function looked up in eldoc.
|
||||
;; We remember this to see whether we need to look up documentation, or used
|
||||
;; the cached value in `ess-eldoc-last-args'.")
|
||||
|
||||
;; (defvar ess-eldoc-last-args nil
|
||||
;; "Args list last looked up for eldoc. Used as cache.")
|
||||
|
||||
;; (defun ess-eldoc-2 ()
|
||||
;; ;; simple, old version.
|
||||
;; (interactive)
|
||||
;; (ess-r-args-get (ess-read-object-name-default)))
|
||||
|
||||
;; (defun ess-eldoc-1 ()
|
||||
;; "Return the doc string, or nil.
|
||||
;; This is the first version; works only on function name, not within arg list."
|
||||
;; (interactive)
|
||||
|
||||
;; ;; Possible ways to get the function at point.
|
||||
;; ;;(setq name (thing-at-point 'sexp))
|
||||
;; ;;(setq name (ess-read-object-name-default))
|
||||
;; ;;(setq name (find-tag-default))
|
||||
|
||||
;; (if ess-current-process-name
|
||||
;; (progn
|
||||
;; (setq name (ess-guess-fun)) ;guess the word at point.
|
||||
;; (if (equal (length name) 0)
|
||||
;; nil
|
||||
;; ;; else
|
||||
;; (unless (equal name ess-eldoc-last-name)
|
||||
;; ;; name is different to the last name we lookedup, so get
|
||||
;; ;; new args from R and store them.
|
||||
;; (setq ess-eldoc-last-args (ess-r-args-get name)
|
||||
;; ess-eldoc-last-name name))
|
||||
;; ess-eldoc-last-args))
|
||||
;; ;; no ESS process current.
|
||||
;; nil)
|
||||
;; )
|
||||
|
||||
|
||||
;; (defsubst ess-guess-fun ()
|
||||
;; "Guess what the function at point is."
|
||||
;; ;; Derived from Man-default-man-entry in man.el
|
||||
;; (let (word)
|
||||
;; (save-excursion
|
||||
;; (skip-chars-backward "-a-zA-Z0-9._+:")
|
||||
;; (let ((start (point)))
|
||||
;; (skip-chars-forward "-a-zA-Z0-9._+:")
|
||||
;; (setq word (buffer-substring-no-properties start (point)))))
|
||||
;; word))
|
||||
|
||||
(defun ess-use-eldoc ()
|
||||
"Does nothing. Defined not to break old users' code."
|
||||
(interactive))
|
||||
|
||||
;; For now, while testing, switch on ess-eldoc. Later, ths could be removed
|
||||
;; and instead ask user to add it.
|
||||
;; (add-hook 'R-mode-hook 'ess-use-eldoc)
|
||||
|
||||
(provide 'ess-eldoc)
|
||||
|
||||
;;; ess-eldoc.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-eldoc.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-eldoc.elc
Normal file
Binary file not shown.
167
.emacs.d/elpa/ess-20160208.453/lisp/ess-font-lock.el
Normal file
167
.emacs.d/elpa/ess-20160208.453/lisp/ess-font-lock.el
Normal file
@@ -0,0 +1,167 @@
|
||||
;;; ess-font-lock.el --- font-lock color options
|
||||
|
||||
;; Copyright (C) 2000--2006 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: Richard M. Heiberger <rmh@temple.edu>
|
||||
;; Created: 06 Feb 2000
|
||||
|
||||
;; Keywords: languages, faces
|
||||
|
||||
;; This file is part of ESS
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; provides syntax highlighting support.
|
||||
|
||||
;;; Code:
|
||||
|
||||
; Requires and autoloads
|
||||
|
||||
(require 'font-lock)
|
||||
(require 'paren)
|
||||
(if (fboundp 'show-paren-mode) (show-paren-mode 1))
|
||||
|
||||
;;; Emacs 20.x notes:
|
||||
|
||||
;; font-lock faces are defined in /emacs/emacs-20.5/lisp/font-lock.el
|
||||
;; The font-lock faces are applied to ESS buffers by
|
||||
;; ess-mode.el ess-inf.el ess-trns.el ess-custom.el
|
||||
;; The keywords for faces are defined in the ess[dl]*.el files.
|
||||
;; All faces can be looked at, under Emacs 20.x, with
|
||||
;; [menu-bar] [Edit] [Text Properties] [Display Faces}
|
||||
|
||||
;;; For XEmacs
|
||||
|
||||
;; ... (tony needs to write something here).
|
||||
|
||||
(defun ess-font-lock-rmh ()
|
||||
"Set font-lock colors to Richard Heiberger's usual choice."
|
||||
(interactive)
|
||||
|
||||
(if (featurep 'xemacs) nil
|
||||
(set-foreground-color "Black")
|
||||
(set-background-color "lightcyan"))
|
||||
|
||||
(set-face-background 'modeline "lightskyblue")
|
||||
(set-face-foreground 'modeline "midnightblue")
|
||||
|
||||
(set-face-foreground 'font-lock-comment-face "Firebrick")
|
||||
(set-face-foreground 'font-lock-function-name-face "Blue")
|
||||
(set-face-foreground 'font-lock-keyword-face "Purple")
|
||||
(set-face-foreground 'font-lock-constant-face "Brown")
|
||||
(set-face-foreground 'font-lock-string-face "VioletRed")
|
||||
(set-face-foreground 'font-lock-type-face "Sienna")
|
||||
(set-face-foreground 'font-lock-variable-name-face "Black"))
|
||||
|
||||
(defun ess-font-lock-blue ()
|
||||
"Set font-lock colors to Richard Heiberger's blue color scheme."
|
||||
(interactive)
|
||||
|
||||
(if (featurep 'xemacs) nil
|
||||
(set-foreground-color "Black")
|
||||
(set-background-color "LightBlue"))
|
||||
|
||||
(set-face-foreground 'modeline "LightBlue")
|
||||
(set-face-background 'modeline "DarkSlateBlue")
|
||||
|
||||
(set-face-foreground 'font-lock-comment-face "Firebrick")
|
||||
(set-face-foreground 'font-lock-function-name-face "Blue")
|
||||
(set-face-foreground 'font-lock-keyword-face "Purple")
|
||||
(set-face-foreground 'font-lock-constant-face "Brown")
|
||||
(set-face-foreground 'font-lock-string-face "VioletRed")
|
||||
(set-face-foreground 'font-lock-type-face "Sienna")
|
||||
(set-face-foreground 'font-lock-variable-name-face "Black"))
|
||||
|
||||
(defun ess-font-lock-wheat ()
|
||||
"Set font-lock colors to Richard Heiberger's wheat color scheme."
|
||||
(interactive)
|
||||
|
||||
(if (featurep 'xemacs) nil
|
||||
(set-foreground-color "Black")
|
||||
(set-background-color "Wheat"))
|
||||
|
||||
(set-face-foreground 'modeline "Wheat")
|
||||
(set-face-background 'modeline "Sienna")
|
||||
|
||||
(set-face-foreground 'font-lock-comment-face "Firebrick")
|
||||
(set-face-foreground 'font-lock-function-name-face "Blue")
|
||||
(set-face-foreground 'font-lock-keyword-face "Purple")
|
||||
(set-face-foreground 'font-lock-constant-face "Brown")
|
||||
(set-face-foreground 'font-lock-string-face "VioletRed")
|
||||
(set-face-foreground 'font-lock-type-face "Sienna")
|
||||
(set-face-foreground 'font-lock-variable-name-face "Black"))
|
||||
|
||||
|
||||
(defun ess-font-lock-bw ()
|
||||
"Set font-lock colors to Richard Heiberger's black and white color scheme."
|
||||
(interactive)
|
||||
|
||||
(if (featurep 'xemacs) nil
|
||||
(set-foreground-color "Black")
|
||||
(set-background-color "white"))
|
||||
|
||||
(set-face-foreground 'modeline "gray10")
|
||||
(set-face-background 'modeline "gray90")
|
||||
|
||||
;; modify-face is an interactive compiled Lisp function in `faces'.
|
||||
;; Sample usage:
|
||||
|
||||
;;(modify-face FACE FOREGROUND BACKGROUND STIPPLE BOLD-P ITALIC-P UNDERLINE-P &optional INVERSE-P FRAME)
|
||||
|
||||
(modify-face 'modeline "gray10" "gray90" nil nil t nil )
|
||||
(modify-face 'font-lock-comment-face "black" "white" nil nil t nil )
|
||||
(modify-face 'font-lock-function-name-face "black" "white" nil t nil nil )
|
||||
(modify-face 'font-lock-keyword-face "black" "white" nil nil nil t )
|
||||
(modify-face 'font-lock-constant-face "black" "white" nil t nil nil )
|
||||
(modify-face 'font-lock-string-face "black" "white" nil nil t t )
|
||||
(modify-face 'font-lock-type-face "black" "white" nil t t nil )
|
||||
(modify-face 'font-lock-variable-name-face "black" "white" nil nil nil nil )
|
||||
(modify-face 'font-lock-builtin-face "black" "white" nil t nil nil )
|
||||
(modify-face 'font-lock-warning-face "black" "white" nil t nil nil )
|
||||
(modify-face 'show-paren-match-face "gray20" "gray80" nil t nil nil )
|
||||
(modify-face 'show-paren-mismatch-face "white" "gray40" nil t t nil ))
|
||||
|
||||
(defun ess-font-lock-db ()
|
||||
"Set font-lock colors (leave fore-/back-ground alone) courtesy David Brahm <David.Brahm@fmr.com>"
|
||||
(interactive)
|
||||
(set-face-foreground 'font-lock-comment-face "Firebrick") ; #... %...
|
||||
(set-face-foreground 'font-lock-string-face "SeaGreen") ; "..." "..."
|
||||
(set-face-foreground 'font-lock-keyword-face "MediumBlue") ; if \end
|
||||
(set-face-foreground 'font-lock-function-name-face "VioletRed") ; talk<- {center}
|
||||
(set-face-foreground 'font-lock-variable-name-face "Blue") ; xv
|
||||
(set-face-foreground 'font-lock-type-face "Goldenrod") ; T,F ?
|
||||
(set-face-foreground 'font-lock-constant-face "Magenta") ; <- {eq1}
|
||||
)
|
||||
|
||||
(provide 'ess-font-lock)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-font-lock.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-font-lock.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-font-lock.elc
Normal file
Binary file not shown.
657
.emacs.d/elpa/ess-20160208.453/lisp/ess-gretl.el
Normal file
657
.emacs.d/elpa/ess-20160208.453/lisp/ess-gretl.el
Normal file
@@ -0,0 +1,657 @@
|
||||
;; ess-gretl.el --- ESS gretl mode and inferior interaction
|
||||
;;
|
||||
;; Copyright (C) 2012 Allin Cottrell
|
||||
;; Copyright (C) 2012 Ahmadou DICKO
|
||||
;; Copyright (C) 2013 ESS core team
|
||||
;;
|
||||
;; Filename: ess-gretl.el
|
||||
;; Author: Ahmadou DICKO, Spinu Vitalie and Allin Cottrell (based on ess-julia.el and gretl.el)
|
||||
;; Maintainer: Ahmadou DICKO
|
||||
;; Created: 01-10-2012 (ESS 12.09)
|
||||
;; Keywords: ESS, gretl, econometrics
|
||||
;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
|
||||
;; This file is *NOT* part of GNU Emacs.
|
||||
;; This file is *NOT YET* part of ESS
|
||||
;;
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 3, any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
;; details.
|
||||
;;
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
;;
|
||||
;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
;; start the inferior with M-x gretl.
|
||||
;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
(require 'compile); for compilation-* below
|
||||
|
||||
|
||||
;;; Code:
|
||||
(defvar gretl-mode-hook nil)
|
||||
(add-to-list 'auto-mode-alist '("\\.inp$" . gretl-mode))
|
||||
|
||||
|
||||
(defvar gretl-syntax-table
|
||||
(let ((table (make-syntax-table)))
|
||||
(modify-syntax-entry ?_ "w" table) ; underscores in words
|
||||
(modify-syntax-entry ?@ "w" table)
|
||||
(modify-syntax-entry ?# "<" table) ; # single-line comment start
|
||||
(modify-syntax-entry ?\n ">" table) ; \n single-line comment end
|
||||
(modify-syntax-entry ?\{ "(} " table)
|
||||
(modify-syntax-entry ?\} "){ " table)
|
||||
(modify-syntax-entry ?\[ "(] " table)
|
||||
(modify-syntax-entry ?\] ")[ " table)
|
||||
(modify-syntax-entry ?\( "() " table)
|
||||
(modify-syntax-entry ?\) ")( " table)
|
||||
(modify-syntax-entry ?\r " " table)
|
||||
(modify-syntax-entry ?+ "." table)
|
||||
(modify-syntax-entry ?- "." table)
|
||||
(modify-syntax-entry ?= "." table)
|
||||
(modify-syntax-entry ?* "." table)
|
||||
(modify-syntax-entry ?/ "." table)
|
||||
(modify-syntax-entry ?> "." table)
|
||||
(modify-syntax-entry ?< "." table)
|
||||
(modify-syntax-entry ?& "." table)
|
||||
(modify-syntax-entry ?| "." table)
|
||||
(modify-syntax-entry ?! "." table)
|
||||
(modify-syntax-entry ?\\ "\\" table)
|
||||
(modify-syntax-entry ?\' "." table)
|
||||
(modify-syntax-entry ?\` "w" table)
|
||||
(modify-syntax-entry ?\" "\"" table)
|
||||
(modify-syntax-entry ?. "w" table)
|
||||
(modify-syntax-entry ?_ "w" table)
|
||||
(modify-syntax-entry ?\% "." table)
|
||||
(modify-syntax-entry ?\# "<" table)
|
||||
(modify-syntax-entry ?\n ">" table)
|
||||
table)
|
||||
"Syntax table for `gretl-mode'.")
|
||||
|
||||
;; syntax table that holds within strings
|
||||
(defvar gretl-mode-string-syntax-table
|
||||
(let ((table (make-syntax-table)))
|
||||
table)
|
||||
"Syntax table for `gretl-mode' that holds within strings.")
|
||||
|
||||
(defcustom gretl-continuation-offset 4
|
||||
"*Extra indentation applied to Gretl continuation lines."
|
||||
:type 'integer
|
||||
:group 'ess-gretl)
|
||||
|
||||
(defvar gretl-continuation-regexp
|
||||
"[^#%\n]*\\(\\\\\\|\\.\\.\\.\\)\\s-*\\(\\s<.*\\)?$")
|
||||
|
||||
(defcustom gretl-continuation-string "\\"
|
||||
"*Character string used for Gretl continuation lines. Normally \\."
|
||||
:type 'string
|
||||
:group 'ess-gretl)
|
||||
|
||||
;; (defconst gretl-string-regex
|
||||
;; "\"[^\"]*?\\(\\(\\\\\\\\\\)*\\\\\"[^\"]*?\\)*\"")
|
||||
|
||||
(defconst gretl-function-header-regexp
|
||||
(concat "^\\s-*\\<\\(function\\)\\>"
|
||||
"\\([^=;\n]*=[ \t]*\\|[ \t]*\\)\\(\\w+\\)\\>")
|
||||
"Regexp to match a Gretl function header.
|
||||
The string `function' and its name are given by the first and third
|
||||
parenthetical grouping.")
|
||||
|
||||
;; (defconst ess-function-call-regexp
|
||||
;; "\\s\"?\\(\\(\\sw\\|\\s_\\)+\\(<-\\)?\\)\\s\"?*\\s-*("
|
||||
;; "Regexp for function names")
|
||||
|
||||
(defvar gretl-command-words
|
||||
'("add" "adf" "anova" "append" "ar" "ar1" "arbond" "arch"
|
||||
"arima" "biprobit" "break" "boxplot" "chow" "clear" "coeffsum" "coint"
|
||||
"coint2" "corr" "corrgm" "cusum" "data" "dataset" "delete" "diff"
|
||||
"difftest" "discrete" "dpanel" "dummify" "duration" "elif" "else" "end"
|
||||
"endif" "endloop" "eqnprint" "equation" "estimate" "fcast" "foreign" "fractint"
|
||||
"freq" "function" "funcerr" "garch" "genr" "gmm" "gnuplot" "graphpg"
|
||||
"hausman" "heckit" "help" "hsk" "hurst" "if" "include" "info"
|
||||
"intreg" "kalman" "kpss" "labels" "lad" "lags" "ldiff" "leverage"
|
||||
"levinlin" "logistic" "logit" "logs" "loop" "mahal" "makepkg" "meantest"
|
||||
"mle" "modeltab" "modprint" "modtest" "mpols" "negbin" "nls" "normtest"
|
||||
"nulldata" "ols" "omit" "open" "orthdev" "outfile" "panel" "pca"
|
||||
"pergm" "textplot" "poisson" "print" "printf" "probit" "pvalue" "quantreg"
|
||||
"qlrtest" "qqplot" "quit" "rename" "reset" "restrict" "rmplot" "run"
|
||||
"runs" "scatters" "sdiff" "set" "setinfo" "setobs" "setmiss" "shell"
|
||||
"smpl" "spearman" "sprintf" "square" "sscanf" "store" "summary" "system"
|
||||
"tabprint" "tobit" "tsls" "var" "varlist" "vartest" "vecm" "vif"
|
||||
"wls" "xcorrgm" "xtab" "debug" "return" "catch" "for" "foreach"
|
||||
"funcerr" "return" "while" "elif" "const" "3sls" "liml" "fiml"
|
||||
"sur" "params" "deriv" "orthog" "weights" "series" "scalar" "genr")
|
||||
"Commands in Gretl (these names are also reserved).")
|
||||
|
||||
(defvar gretl-genr-functions
|
||||
'("abs" "sin" "cos" "tan" "asin" "acos" "atan" "sinh"
|
||||
"cosh" "tanh" "asinh" "acosh" "atanh" "log" "ln" "log10"
|
||||
"log2" "exp" "sqrt" "diff" "ldiff" "sdiff" "lags" "int"
|
||||
"round" "ceil" "floor" "sort" "dsort" "sortby" "ranking" "orthdev"
|
||||
"nobs" "firstobs" "lastobs" "uniform" "normal" "cum" "missing" "ok"
|
||||
"misszero" "lrvar" "quantile" "median" "gini" "zeromiss" "sum" "mean"
|
||||
"min" "max" "sd" "var" "sst" "cnorm" "dnorm" "qnorm"
|
||||
"gammafun" "lngamma" "digamma" "resample" "pnobs" "pmin" "pmax" "pmean"
|
||||
"psd" "hpfilt" "bkfilt" "bwfilt" "fracdiff" "boxcox" "cov" "corr"
|
||||
"movavg" "I" "zeros" "ones" "seq" "replace" "muniform" "mnormal"
|
||||
"sumc" "sumr" "meanc" "meanr" "sdc" "minc" "maxc" "minr"
|
||||
"maxr" "iminc" "imaxc" "iminr" "imaxr" "fft" "ffti" "cmult"
|
||||
"cdiv" "mcov" "mcorr" "mxtab" "cdemean" "cholesky" "psdroot" "inv"
|
||||
"invpd" "ginv" "diag" "transp" "vec" "vech" "unvech" "upper"
|
||||
"lower" "rows" "cols" "det" "ldet" "tr" "onenorm" "infnorm"
|
||||
"rcond" "rank" "qform" "mlag" "qrdecomp" "eigensym" "eigengen" "nullspace"
|
||||
"princomp" "mexp" "fdjac" "BFGSmax" "obsnum" "isseries" "isscalar" "islist"
|
||||
"isstring" "isnull" "nelem" "pdf" "cdf" "invcdf" "pvalue" "critical"
|
||||
"randgen" "urcpval" "values" "mshape" "svd" "mols" "mpols" "mrls"
|
||||
"mread" "mwrite" "selifc" "selifr" "polroots" "dummify" "wmean" "wvar"
|
||||
"wsd" "xpx" "filter" "kfilter" "ksmooth" "ksimul" "trimr" "getenv"
|
||||
"argname" "obslabel" "readfile" "grab" "strstr" "strncmp" "strlen" "sscanf"
|
||||
"varname" "varnum" "tolower" "colnames" "rownames" "ljungbox" "msortby" "lincomb"
|
||||
"imhof" "toepsolv" "diagcat" "xmin" "xmax" "corrgm" "mcovg" "fcstats"
|
||||
"bessel" "fraclag" "mreverse" "deseas" "pergm" "irr" "npv" "logistic"
|
||||
"weekday" "kdensity" "monthlen" "epochday" "setnote" "invmills" "polyfit" "chowlin"
|
||||
"varsimul" "strsplit" "inlist" "errmsg" "isconst" "irf" "inbundle")
|
||||
"Builtin functions for Gretl's genr command.")
|
||||
|
||||
|
||||
(defvar gretl-option-flags
|
||||
'("addstats" "all" "anova" "append"
|
||||
"arch" "arma-init" "asymptotic" "autocorr" "auto"
|
||||
"autocorr" "auxiliary" "balanced" "bartlett"
|
||||
"between" "bootstrap" "both" "breusch-pagan"
|
||||
"byobs" "by" "c" "close"
|
||||
"coded" "cols" "column" "comfac"
|
||||
"complete" "conditional" "contiguous" "continue"
|
||||
"continuous" "control" "covariance" "cross"
|
||||
"cross-section" "crt" "csv" "ct"
|
||||
"ctt" "cubes-only" "dat" "database"
|
||||
"dataset" "db" "degrees" "dhansen"
|
||||
"difference" "diffuse" "discrete" "dpdstyle"
|
||||
"drop-empty" "drop-first" "drop-last" "dummy"
|
||||
"dynamic" "equal" "exit" "exponential"
|
||||
"fcp" "fixed-effects" "from-file" "full"
|
||||
"func" "gamma" "geomean" "gls"
|
||||
"gmm" "gnu-R" "gnu-octave" "gph"
|
||||
"gzipped" "hausman-reg" "hessian" "hilu"
|
||||
"impulse-responses" "input" "inst" "integrate"
|
||||
"intervals" "inverse-fit" "iterate" "jackknife"
|
||||
"jbera" "jitter" "jmulti" "kendall"
|
||||
"lags" "lagselect" "lbfgs" "lillie"
|
||||
"liml" "linear-fit" "list" "loess-fit"
|
||||
"log" "loglogistic" "lognormal" "logs"
|
||||
"matrix" "matrix-diff" "medians" "ml"
|
||||
"model1" "multi" "multinomial" "nc"
|
||||
"next" "no-corc" "no-dates" "no-df-corr"
|
||||
"no-gradient-check" "no-header" "no-missing" "no-scaling"
|
||||
"no-stats" "normal" "normality" "notches"
|
||||
"numerical" "odbc" "omit-obs" "one-scale"
|
||||
"opg" "orthdev" "other" "out-of-sample"
|
||||
"output" "overwrite" "p-values" "panel"
|
||||
"panel-vars" "plot" "pooled" "preserve"
|
||||
"print-final" "progress-bar" "progressive" "pwe"
|
||||
"quadratic-fit" "quiet" "quit" "radians"
|
||||
"random" "random-effects" "rank-sum" "raw"
|
||||
"rc" "replace" "restrict" "restructure"
|
||||
"reverse" "robust" "rolling" "row"
|
||||
"rtf" "save" "save-all" "save-ehat"
|
||||
"save-xbeta" "scalars" "seasonals" "send-data"
|
||||
"sign" "signed-rank" "silent" "simple"
|
||||
"simple-print" "single-yaxis" "skip-df" "spearman"
|
||||
"special-time-series" "squares" "squares-only" "stacked-cross-section"
|
||||
"stacked-time-series" "static" "stdresid" "suppress-fitted"
|
||||
"swilk" "system" "t-ratios" "tall"
|
||||
"test-down" "tex" "time-dummies" "time-series"
|
||||
"to-file" "to_file" "traditional" "trend"
|
||||
"two-step" "unequal-vars" "uniform" "unit-weights"
|
||||
"variance-decomp" "vcv" "verbose" "wald"
|
||||
"weibull" "weights" "white" "white-nocross"
|
||||
"with-impulses" "with-lines" "write" "www"
|
||||
"x-12-arima" "y-diff-only" "z-scores" "zeros")
|
||||
"Gretl option flags.")
|
||||
|
||||
(defvar gretl-internal-vars
|
||||
'("Fstat" "T" "ahat" "aic" "bic" "chisq" "coeff_ci"
|
||||
"coeff" "compan" "datatype" "df" "dwpval" "ec" "ehat"
|
||||
"error" "ess" "fcast" "fcerr" "gmmcrit" "hausman" "hqc"
|
||||
"h" "jalpha" "jbeta" "jvbeta" "kalman_llt" "kalman_lnl" "kalman_s2"
|
||||
"kalman_t" "kalman_uhat" "llt" "lnl" "mnlprobs" "ncoeff" "nobs"
|
||||
"nscan" "nvars" "obs" "pd" "pvalue" "rho" "rlnl"
|
||||
"rsq" "s00" "s01" "s11" "sample" "sargan" "sigma"
|
||||
"stderr" "stopwatch" "sysA" "sysB" "sysGamma" "t1" "t2"
|
||||
"test" "trsq" "uhat" "unit" "vcv" "version" "vma"
|
||||
"windows" "xlist" "xtxinv" "yhat" )
|
||||
"Model- and dataset-related variables.")
|
||||
|
||||
(defconst gretl-block-start-keywords
|
||||
(list "loop" "foreign" "function" "gmm" "if" "system" "mle" "nls" "restrict"))
|
||||
|
||||
(defconst gretl-block-other-keywords
|
||||
(list "else" "elif"))
|
||||
|
||||
(defconst gretl-block-end-keywords
|
||||
(list "end" "endif" "endloop"))
|
||||
|
||||
(defvar gretl-keywords
|
||||
(append gretl-block-start-keywords
|
||||
gretl-block-other-keywords
|
||||
gretl-block-end-keywords
|
||||
'("break"))
|
||||
"Reserved words in Gretl.")
|
||||
|
||||
|
||||
(defun gretl-at-keyword (kw-list)
|
||||
; not a keyword if used as a field name, X.word, or quoted, :word
|
||||
(and (or (= (point) 1)
|
||||
(and (not (equal (char-before (point)) ?.))
|
||||
(not (equal (char-before (point)) ?:))))
|
||||
(not (ess-inside-string-or-comment-p (point)))
|
||||
(not (ess-inside-brackets-p (point)))
|
||||
(member (current-word) kw-list)))
|
||||
|
||||
|
||||
(defconst gretl-font-lock-defaults
|
||||
(list
|
||||
;; Fontify all builtin keywords.
|
||||
(cons (concat "\\<\\("
|
||||
(mapconcat 'identity gretl-keywords "\\|")
|
||||
"\\)\\>")
|
||||
'font-lock-keyword-face)
|
||||
;; Fontify all option flags.
|
||||
(cons (concat "[ \t]--\\("
|
||||
(mapconcat 'identity gretl-option-flags "\\|")
|
||||
"\\)")
|
||||
'font-lock-constant-face)
|
||||
;; Fontify all command words.
|
||||
(cons (concat "\\<\\("
|
||||
(mapconcat 'identity gretl-command-words "\\|")
|
||||
"\\)\\>")
|
||||
'font-lock-builtin-face)
|
||||
;; Fontify all builtin operators.
|
||||
(cons "\\(&\\||\\|<=\\|>=\\|==\\|<\\|>\\|!=\\|!\\)"
|
||||
(if (boundp 'font-lock-builtin-face)
|
||||
'font-lock-builtin-face
|
||||
'font-lock-preprocessor-face))
|
||||
;; Fontify all internal variables.
|
||||
(cons (concat "\\$\\("
|
||||
(mapconcat 'identity gretl-internal-vars "\\|")
|
||||
"\\)\\>")
|
||||
'font-lock-variable-name-face)
|
||||
|
||||
;; Fontify all genr functions.
|
||||
(cons (concat "\\<\\("
|
||||
(mapconcat 'identity gretl-genr-functions "\\|")
|
||||
"\\)\\>")
|
||||
'font-lock-variable-name-face)
|
||||
;; Fontify all function declarations.
|
||||
(list gretl-function-header-regexp
|
||||
'(1 font-lock-keyword-face)
|
||||
'(3 font-lock-function-name-face nil t)))
|
||||
"Additional Gretl expressions to highlight.")
|
||||
|
||||
|
||||
(defvar gretl-block-begin-regexp
|
||||
(concat "\\<\\("
|
||||
(mapconcat 'identity gretl-block-start-keywords "\\|")
|
||||
"\\)\\>"))
|
||||
|
||||
(defvar gretl-block-else-regexp
|
||||
(concat "\\<\\("
|
||||
(mapconcat 'identity gretl-block-other-keywords "\\|")
|
||||
"\\)\\>"))
|
||||
|
||||
(defvar gretl-block-end-regexp
|
||||
(concat "\\<\\("
|
||||
(mapconcat 'identity gretl-block-end-keywords "\\|")
|
||||
"\\)\\>"))
|
||||
|
||||
(defvar gretl-block-begin-or-end-regexp
|
||||
(concat gretl-block-begin-regexp "\\|" gretl-block-end-regexp))
|
||||
|
||||
|
||||
(defvar gretl-block-else-or-end-regexp
|
||||
(concat gretl-block-else-regexp "\\|" gretl-block-end-regexp))
|
||||
|
||||
|
||||
(defvar gretl-block-match-alist
|
||||
'(("loop" . ("endloop"))
|
||||
("if" . ("else" "elif" "endif"))
|
||||
("nls" . ("end"))
|
||||
("mle" . ("end"))
|
||||
("gmm" . ("end"))
|
||||
("foreign" . ("end"))
|
||||
("restrict" . ("end"))
|
||||
("kalman" . ("end"))
|
||||
("system" . ("end")))
|
||||
"Alist with Gretl's matching block keywords.
|
||||
Has Gretl's begin keywords as keys and a list of the matching else or
|
||||
end keywords as associated values.")
|
||||
|
||||
|
||||
|
||||
; get the position of the last open block
|
||||
(defun gretl-last-open-block-pos (min)
|
||||
(let ((count 0))
|
||||
(while (not (or (> count 0) (<= (point) min)))
|
||||
(backward-word 1)
|
||||
(setq count
|
||||
(cond ((gretl-at-keyword gretl-block-start-keywords)
|
||||
(+ count 1))
|
||||
((and (zerop (string-match "\\(?:e\\(?:l\\(?:if\\|se\\)\\|nd\\(?:if\\|loop\\)?\\)\\)" (current-word)))
|
||||
(not (ess-inside-comment-p)) (not (ess-inside-brackets-p)))
|
||||
(- count 1))
|
||||
(t count))))
|
||||
(if (> count 0)
|
||||
(point)
|
||||
nil)))
|
||||
|
||||
|
||||
(defun gretl-last-open-block (min)
|
||||
(let ((pos (gretl-last-open-block-pos min)))
|
||||
(and pos
|
||||
(progn
|
||||
(goto-char pos)
|
||||
(+ gretl-basic-offset (current-indentation))))))
|
||||
|
||||
|
||||
; return indent implied by a special form opening on the previous line, if any
|
||||
(defun gretl-form-indent ()
|
||||
(forward-line -1)
|
||||
(end-of-line)
|
||||
(backward-sexp)
|
||||
(if (gretl-at-keyword gretl-block-other-keywords)
|
||||
(+ gretl-basic-offset (current-indentation))
|
||||
(if (char-equal (char-after (point)) ?\()
|
||||
(progn
|
||||
(backward-word 1)
|
||||
(let ((cur (current-indentation)))
|
||||
(if (gretl-at-keyword gretl-block-start-keywords)
|
||||
(+ gretl-basic-offset cur)
|
||||
nil)))
|
||||
nil)))
|
||||
|
||||
|
||||
(defun gretl-indent-line ()
|
||||
"Indent current line of gretl code"
|
||||
(interactive)
|
||||
; (save-excursion
|
||||
(end-of-line)
|
||||
(indent-line-to
|
||||
(or (and (ess-inside-string-p (point-at-bol)) 0)
|
||||
(save-excursion (ignore-errors (gretl-form-indent)))
|
||||
(save-excursion
|
||||
(let ((endtok (progn
|
||||
(beginning-of-line)
|
||||
(forward-to-indentation 0)
|
||||
(gretl-at-keyword gretl-block-end-keywords))))
|
||||
(ignore-errors (+ (gretl-last-open-block (point-min))
|
||||
(if endtok (- gretl-basic-offset) 0)))))
|
||||
;; previous line ends in =
|
||||
(save-excursion
|
||||
(if (and (not (equal (point-min) (line-beginning-position)))
|
||||
(progn
|
||||
(forward-line -1)
|
||||
(end-of-line) (backward-char 1)
|
||||
(equal (char-after (point)) ?=)))
|
||||
(+ gretl-basic-offset (current-indentation))
|
||||
nil))
|
||||
;; take same indentation as previous line
|
||||
(save-excursion (forward-line -1)
|
||||
(current-indentation))
|
||||
0))
|
||||
(when (gretl-at-keyword gretl-block-end-keywords)
|
||||
(forward-word 1)))
|
||||
|
||||
|
||||
(defvar gretl-editing-alist
|
||||
'((paragraph-start . (concat "\\s-*$\\|" page-delimiter))
|
||||
(paragraph-separate . (concat "\\s-*$\\|" page-delimiter))
|
||||
(paragraph-ignore-fill-prefix . t)
|
||||
(require-final-newline . mode-require-final-newline)
|
||||
(comment-start . "# ")
|
||||
(comment-add . 1)
|
||||
(comment-start-skip . "\\s<+\\s-*")
|
||||
(comment-column . 40)
|
||||
;;(comment-indent-function . 'S-comment-indent)
|
||||
;;(ess-comment-indent . 'S-comment-indent)
|
||||
;;(ess-indent-line . 'S-indent-line)
|
||||
(ess-calculate-indent . 'ess-calculate-indent)
|
||||
(ess-indent-line-function . 'gretl-indent-line)
|
||||
(parse-sexp-ignore-comments . t)
|
||||
(ess-style . ess-default-style) ;; ignored
|
||||
(ess-local-process-name . nil)
|
||||
;;(ess-keep-dump-files . 'ask)
|
||||
(ess-mode-syntax-table . gretl-syntax-table)
|
||||
;; (add-log-current-defun-header-regexp . "^.*function[ \t]*\\([^ \t(]*\\)[ \t]*(")
|
||||
(font-lock-defaults . '(gretl-font-lock-defaults))
|
||||
)
|
||||
"General options for gretl source files.")
|
||||
|
||||
(autoload 'inferior-ess "ess-inf" "Run an ESS process.")
|
||||
(autoload 'ess-mode "ess-mode" "Edit an ESS process.")
|
||||
|
||||
|
||||
;; (defun gretl-send-string-function (process string visibly)
|
||||
;; (let ((gretl-process (get-process "gretlcli")))
|
||||
;; (process-send-string process (format ess-load-command file)))
|
||||
|
||||
|
||||
;; (defun gretl-send-string-function (process string visibly)
|
||||
;; (let ((file (concat temporary-file-directory "gretl_eval_region.inp")))
|
||||
;; (with-temp-file file
|
||||
;; (insert string))
|
||||
;; (process-send-string process (format ess-load-command file))))
|
||||
|
||||
(defun gretl--get-words-from-command (command start-reg end-reg)
|
||||
(with-current-buffer (ess-command command)
|
||||
(goto-char (point-min))
|
||||
(let ((beg (or (re-search-forward start-reg nil t)
|
||||
(point-min)))
|
||||
(end (progn (goto-char (point-max))
|
||||
(or (re-search-backward end-reg)
|
||||
(point-max))))
|
||||
acum)
|
||||
(goto-char beg)
|
||||
(skip-chars-forward "\n")
|
||||
(while (re-search-forward "[^ \t\n]+" end t)
|
||||
(push (match-string-no-properties 0) acum))
|
||||
acum)))
|
||||
|
||||
(defun gretl-get-help-topics-function (name)
|
||||
(delete-dups
|
||||
(append gretl-command-words gretl-genr-functions
|
||||
gretl-block-end-keywords gretl-block-other-keywords
|
||||
gretl-block-start-keywords
|
||||
(gretl--get-words-from-command "help\n" "are:" "^For")
|
||||
(gretl--get-words-from-command "help functions\n" "Accessors:" "^Functions")
|
||||
(gretl--get-words-from-command "help functions\n" "^Functions" "^For")
|
||||
)))
|
||||
|
||||
;; (defvar ess-gretl-error-regexp-alist '(gretl-in gretl-at)
|
||||
;; "List of symbols which are looked up in `compilation-error-regexp-alist-alist'.")
|
||||
|
||||
;; (add-to-list 'compilation-error-regexp-alist-alist
|
||||
;; '(gretl-in "^\\s-*in [^ \t\n]* \\(at \\(.*\\):\\([0-9]+\\)\\)" 2 3 nil 2 1))
|
||||
;; (add-to-list 'compilation-error-regexp-alist-alist
|
||||
;; '(gretl-at "^\\s-*\\(at \\(.*\\):\\([0-9]+\\)\\)" 2 3 nil 2 1))
|
||||
|
||||
|
||||
(defvar gretl-customize-alist
|
||||
'((comint-use-prompt-regexp . t)
|
||||
(inferior-ess-primary-prompt . "\\? ")
|
||||
(inferior-ess-secondary-prompt . "\\ ")
|
||||
(inferior-ess-prompt . "\\? ")
|
||||
(ess-local-customize-alist . 'gretl-customize-alist)
|
||||
(inferior-ess-program . "gretlcli")
|
||||
(inferior-ess-font-lock-defaults . gretl-font-lock-defaults)
|
||||
(ess-get-help-topics-function . 'gretl-get-help-topics-function)
|
||||
(ess-load-command . "open \"%s\"\n")
|
||||
;; (ess-dump-error-re . "in \\w* at \\(.*\\):[0-9]+")
|
||||
;; (ess-error-regexp . "\\(^\\s-*at\\s-*\\(?3:.*\\):\\(?2:[0-9]+\\)\\)")
|
||||
;; (ess-error-regexp-alist . ess-gretl-error-regexp-alist)
|
||||
(ess-send-string-function . 'gretl-send-string-function)
|
||||
;; (inferior-ess-objects-command . inferior-gretl-objects-command)
|
||||
;; (inferior-ess-search-list-command . "search()\n")
|
||||
;; inferior-ess-help-command . gretl-help-command)
|
||||
(inferior-ess-help-command . "help %s\n")
|
||||
(ess-language . "gretl")
|
||||
(ess-dialect . "gretl")
|
||||
(ess-suffix . "inp")
|
||||
(ess-dump-filename-template . (ess-replace-regexp-in-string
|
||||
"S$" ess-suffix ; in the one from custom:
|
||||
ess-dump-filename-template-proto))
|
||||
(ess-mode-syntax-table . gretl-syntax-table)
|
||||
(ess-mode-editing-alist . gretl-editing-alist)
|
||||
(ess-change-sp-regexp . nil );ess-R-change-sp-regexp)
|
||||
(ess-help-sec-regex . ess-help-R-sec-regex)
|
||||
(ess-help-sec-keys-alist . ess-help-R-sec-keys-alist)
|
||||
(ess-loop-timeout . ess-S-loop-timeout);fixme: dialect spec.
|
||||
(ess-cmd-delay . ess-R-cmd-delay)
|
||||
(ess-function-pattern . ess-R-function-pattern)
|
||||
(ess-object-name-db-file . "ess-r-namedb.el" )
|
||||
;; (ess-imenu-mode-function . nil)
|
||||
(ess-smart-operators . ess-R-smart-operators)
|
||||
(inferior-ess-help-filetype . nil)
|
||||
(inferior-ess-exit-command . "exit\n")
|
||||
;;harmful for shell-mode's C-a: -- but "necessary" for ESS-help?
|
||||
(inferior-ess-start-file . nil) ;; "~/.ess-R"
|
||||
(inferior-ess-start-args . "")
|
||||
(inferior-ess-language-start . nil)
|
||||
(ess-STERM . "iESS")
|
||||
)
|
||||
"Variables to customize for Gretl -- set up later than emacs initialization.")
|
||||
|
||||
;; (defcustom inferior-gretl-program-name "gretlcli"
|
||||
;; "*The program to use for running gretl scripts."
|
||||
;; :type 'string
|
||||
;; :group 'ess-gretl)
|
||||
|
||||
;; (defvar ess-gretl-versions '("gretcli")
|
||||
;; "List of partial strings for versions of Julia to access within ESS.
|
||||
;; Each string specifies the start of a filename. If a filename
|
||||
;; beginning with one of these strings is found on `exec-path', a M-x
|
||||
;; command for that version of Julia is made available. ")
|
||||
|
||||
(defcustom inferior-gretl-args ""
|
||||
"String of arguments used when starting gretl.
|
||||
These arguments are currently not passed to other versions of gretl that have
|
||||
been created using the variable `ess-r-versions'."
|
||||
:group 'ess-gretl
|
||||
:type 'string)
|
||||
|
||||
(defvar gretl-basic-offset 4)
|
||||
|
||||
;;;###autoload
|
||||
(defun gretl-mode (&optional proc-name)
|
||||
"Major mode for editing gretl source. See `ess-mode' for more help."
|
||||
(interactive "P")
|
||||
;; (setq ess-customize-alist gretl-customize-alist)
|
||||
;;(setq imenu-generic-expression R-imenu-generic-expression)
|
||||
(ess-mode gretl-customize-alist proc-name)
|
||||
;; for emacs < 24
|
||||
;; (add-hook 'comint-dynamic-complete-functions 'ess-complete-object-name nil 'local)
|
||||
;; for emacs >= 24
|
||||
;; (remove-hook 'completion-at-point-functions 'ess-filename-completion 'local) ;; should be first
|
||||
;; (add-hook 'completion-at-point-functions 'ess-object-completion nil 'local)
|
||||
;; (add-hook 'completion-at-point-functions 'ess-filename-completion nil 'local)
|
||||
(if (fboundp 'ess-add-toolbar) (ess-add-toolbar))
|
||||
(set (make-local-variable 'end-of-defun-function) 'ess-end-of-function)
|
||||
;; (local-set-key "\t" 'gretl-indent-line) ;; temp workaround
|
||||
;; (set (make-local-variable 'indent-line-function) 'gretl-indent-line)
|
||||
;; (ess-imenu-gretl)
|
||||
(run-hooks 'gretl-mode-hook))
|
||||
|
||||
|
||||
(defvar ess-gretl-post-run-hook nil
|
||||
"Functions run in process buffer after the initialization of
|
||||
Gretl process.")
|
||||
|
||||
|
||||
|
||||
;;;###autoload
|
||||
(defun gretl (&optional start-args)
|
||||
"Call 'gretl',
|
||||
Optional prefix (C-u) allows to set command line arguments, such as
|
||||
--vsize. This should be OS agnostic.
|
||||
If you have certain command line arguments that should always be passed
|
||||
to gretl, put them in the variable `inferior-gretl-args'."
|
||||
(interactive "P")
|
||||
;; get settings, notably inferior-R-program-name :
|
||||
;; (if (null inferior-gretl-program-name)
|
||||
;; (error "'inferior-gretl-program-name' does not point to 'gretl-release-basic' executable")
|
||||
(setq ess-customize-alist gretl-customize-alist)
|
||||
(ess-write-to-dribble-buffer ;; for debugging only
|
||||
(format
|
||||
"\n(Gretl): ess-dialect=%s, buf=%s"
|
||||
ess-dialect (current-buffer)))
|
||||
(let* ((r-start-args
|
||||
(concat inferior-gretl-args " " ; add space just in case
|
||||
(if start-args
|
||||
(read-string
|
||||
(concat "Starting Args [other than `"
|
||||
inferior-gretl-args
|
||||
"'] ? "))
|
||||
nil))))
|
||||
(inferior-ess r-start-args)
|
||||
(set (make-local-variable 'indent-line-function) 'gretl-indent-line)
|
||||
(set (make-local-variable 'gretl-basic-offset) 4)
|
||||
(setq indent-tabs-mode nil)
|
||||
(goto-char (point-max))
|
||||
;; (if inferior-ess-language-start
|
||||
;; (ess-eval-linewise inferior-ess-language-start
|
||||
;; nil nil nil 'wait-prompt)))
|
||||
(with-ess-process-buffer nil
|
||||
(run-mode-hooks 'ess-gretl-post-run-hook))
|
||||
))
|
||||
|
||||
|
||||
;;;; IMENU
|
||||
|
||||
;; (defvar gretl-imenu-generic-expression
|
||||
;; '(("Function (_)" "^\\s-*function\\s-+\\(_[^ \t\n]*\\)" 1)
|
||||
;; ("Function" "^\\s-*function\\s-+\\([^_][^ \t\n]*\\)" 1)
|
||||
;; ("Const" "^\\s-*const \\([^ \t\n]*\\)" 1)
|
||||
;; ("Type" "^\\s-*\\w*type\\w* \\([^ \t\n]*\\)" 1)
|
||||
;; ("Load" " *\\(load\\)(\\([^ \t\n)]*\\)" 2)
|
||||
;; ;; ("Classes" "^.*setClass(\\(.*\\)," 1)
|
||||
;; ;; ("Coercions" "^.*setAs(\\([^,]+,[^,]*\\)," 1) ; show from and to
|
||||
;; ;; ("Generics" "^.*setGeneric(\\([^,]*\\)," 1)
|
||||
;; ;; ("Methods" "^.*set\\(Group\\|Replace\\)?Method(\"\\(.+\\)\"," 2)
|
||||
;; ;; ;;[ ]*\\(signature=\\)?(\\(.*,?\\)*\\)," 1)
|
||||
;; ;; ;;
|
||||
;; ;; ;;("Other" "^\\(.+\\)\\s-*<-[ \t\n]*[^\\(function\\|read\\|.*data\.frame\\)]" 1)
|
||||
;; ;; ("Package" "^.*\\(library\\|require\\)(\\(.*\\)," 2)
|
||||
;; ;; ("Data" "^\\(.+\\)\\s-*<-[ \t\n]*\\(read\\|.*data\.frame\\).*(" 1)))
|
||||
;; ))
|
||||
|
||||
|
||||
;; (defun ess-imenu-gretl (&optional arg)
|
||||
;; "Gretl Language Imenu support for ESS."
|
||||
;; (interactive)
|
||||
;; (setq imenu-generic-expression gretl-imenu-generic-expression)
|
||||
;; (imenu-add-to-menubar "Imenu-gretl"))
|
||||
|
||||
|
||||
;; (defun ess-imenu-gretl (&optional arg)
|
||||
;; "Gretl Language Imenu support for ESS."
|
||||
;; (interactive)
|
||||
;; (setq imenu-generic-expression gretl-imenu-generic-expression)
|
||||
;; (imenu-add-to-menubar "Imenu-jl"))
|
||||
|
||||
|
||||
(provide 'ess-gretl)
|
||||
;; (provide 'ess-gretl)
|
||||
|
||||
(provide 'ess-gretl)
|
||||
|
||||
;;; ess-gretl.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-gretl.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-gretl.elc
Normal file
Binary file not shown.
1090
.emacs.d/elpa/ess-20160208.453/lisp/ess-help.el
Normal file
1090
.emacs.d/elpa/ess-20160208.453/lisp/ess-help.el
Normal file
File diff suppressed because it is too large
Load Diff
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-help.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-help.elc
Normal file
Binary file not shown.
3465
.emacs.d/elpa/ess-20160208.453/lisp/ess-inf.el
Normal file
3465
.emacs.d/elpa/ess-20160208.453/lisp/ess-inf.el
Normal file
File diff suppressed because it is too large
Load Diff
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-inf.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-inf.elc
Normal file
Binary file not shown.
236
.emacs.d/elpa/ess-20160208.453/lisp/ess-install.el
Normal file
236
.emacs.d/elpa/ess-20160208.453/lisp/ess-install.el
Normal file
@@ -0,0 +1,236 @@
|
||||
;;; ess-install.el --- Automatic installation of ESS.
|
||||
;; Auto-install procedure. EXPERIMENTAL!
|
||||
|
||||
;; Copyright (C) 2006 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: Stephen Eglen
|
||||
|
||||
;; This file is part of ESS
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
;;
|
||||
;;
|
||||
;; In short: you may use this code any way you like, as long as you
|
||||
;; don't charge more than a distribution fee for it, do distribute the
|
||||
;; source with any binaries, remove this notice, or hold anyone liable
|
||||
;; for its results.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Although installing ESS is relatively simple, sometimes people get
|
||||
;; confused as to what to add to their init files, or even where their
|
||||
;; init files are located. The following procedure should be a bit
|
||||
;; simpler, as Emacs will add the necessary start-up lines itself.
|
||||
;; (The instructions below assume you have downloaded ess as a zip
|
||||
;; package, but it will work also for the .tar.gz version of ESS as
|
||||
;; long as you know how to unpack a .tar.gz in step 3.)
|
||||
;;
|
||||
;; Installing ESS for the first time.
|
||||
;;
|
||||
;; 1. Create a folder (e.g C:/emacs) where you will store ESS. We will
|
||||
;; assume that you are installing ESS into C:/emacs (unix users can use
|
||||
;; ~/emacs).
|
||||
;;
|
||||
;; 2. Download ess-5.2.12.zip and store it in the folder you created.
|
||||
;;
|
||||
;; 3. Unpack the files from the zip archive, e.g. by right-clicking on it
|
||||
;; within Windows explorer and selecting "Extract all". On unix, use
|
||||
;; "unzip ess-5.2.12.zip".
|
||||
;;
|
||||
;; 4. Start a new emacs (or xemacs).
|
||||
;;
|
||||
;; 5. In the new emacs, you need to open the file "ess-install.el" which
|
||||
;; is part of ESS. To do this, type:
|
||||
;;
|
||||
;; C-x C-f c:/emacs/ess-5.2.12/lisp/ess-install.el RET
|
||||
;;
|
||||
;; You should now see a lisp file with the top line:
|
||||
;; ;;; ess-install.el --- Automatic installation of ESS.
|
||||
;;
|
||||
;; 6. Type M-x eval-buffer RET
|
||||
;;
|
||||
;; What does this do? This will find your emacs initialisation file, and
|
||||
;; it will add the following two lines to the end of the file:
|
||||
;;
|
||||
;; ;;; ESS setup for version 5.2.12
|
||||
;; (load "c:/emacs/ess-5.2.12/lisp/ess-site")
|
||||
;;
|
||||
;; Do not edit those two lines! They are useful if later you come to
|
||||
;; upgrade ESS.
|
||||
;;
|
||||
;; 7. Start a new Emacs and you should find then that ESS is loaded. For
|
||||
;; example, create a new file called "foo.R" and check that it opens
|
||||
;; in R mode by looking at the mode line and menubar.
|
||||
;;
|
||||
;; Upgrading your version of ESS.
|
||||
;;
|
||||
;; If (and only if) you use the above instructions for installing ESS,
|
||||
;; when a new version of ESS is released, you can use the same method to
|
||||
;; install the new version. Repeat steps 2-7 for the new release of ESS,
|
||||
;; and this time in step 6, if emacs finds that you already have the
|
||||
;; special line ";;; ESS setup for version 5.2.12", it will highlight
|
||||
;; those lines, and query whether you want to replace those two lines
|
||||
;; with the new setup code.
|
||||
;;
|
||||
;; If you do upgrade ESS this way, bear in mind that your old version
|
||||
;; will not be deleted from your filespace -- you will have to delete it
|
||||
;; yourself.
|
||||
|
||||
;; TODO: possibly add a call to (byte-recompile-directory ess-lisp-dir
|
||||
;; 0) so that lisp files are byte compiled.
|
||||
|
||||
;;; Code:
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Location where the new lisp files are stored.
|
||||
(defvar ess-lisp-dir (file-name-directory
|
||||
(abbreviate-file-name buffer-file-name))
|
||||
"Location where the new lisp files are stored.")
|
||||
|
||||
(defvar ess-site-file (concat ess-lisp-dir "ess-site")
|
||||
"Full path to the new ess-site file.
|
||||
Do not include .el extension in case there is also a .elc around.")
|
||||
|
||||
(defvar ess-new-version nil
|
||||
"Version number of new ESS to be installed.")
|
||||
|
||||
(defvar ess-installed nil)
|
||||
|
||||
|
||||
(defun ess-install-byte-compile ()
|
||||
"Byte compile the ESS files.
|
||||
This will probably generate warnings, but they can hopefully be
|
||||
ignored."
|
||||
;; To do byte compilation, XEmacs seems to want the files on its
|
||||
;; load-path so that it can do the (require 'xyz) statements.
|
||||
(add-to-list 'load-path ess-lisp-dir)
|
||||
(byte-recompile-directory ess-lisp-dir 0))
|
||||
|
||||
;; Check that ess-site-file is written using unix directory separators.
|
||||
;; i.e. need to change c:\\some\\dir\\ess-site.el to
|
||||
;; c:/some/dir/ess-site.el
|
||||
;; To do this, we have to load in ess-replace-in-string, from
|
||||
;; the file ess-inf.el
|
||||
|
||||
(save-window-excursion
|
||||
(find-file (concat ess-lisp-dir "ess-inf.el"))
|
||||
(goto-char (point-min))
|
||||
(search-forward-regexp "^(defun ess-replace-in-string " nil t)
|
||||
(eval-defun nil)
|
||||
(setq ess-site-file
|
||||
(ess-replace-in-string ess-site-file "\\\\" "/" t))
|
||||
)
|
||||
|
||||
|
||||
;; Get the version number of the new software. Open the file
|
||||
;; ess-custom.el and then find the definition of the variable
|
||||
;; ess-version.
|
||||
(save-window-excursion
|
||||
(let ((beg))
|
||||
(find-file (concat ess-lisp-dir "ess-custom.el"))
|
||||
;; go back to start, just in case file was previously open.
|
||||
(goto-char (point-min))
|
||||
(search-forward "defvar ess-version \"")
|
||||
(setq beg (point))
|
||||
(search-forward "\"")
|
||||
(setq ess-new-version (buffer-substring beg (1- (point))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; Highlighting (copied from reftex.el -- cheers Carsten!)
|
||||
;; Only one highlight region is needed, whereas two are provided here,
|
||||
;; so this code could be simplified. But we may want it again later.
|
||||
|
||||
;; Highlighting uses overlays. If this is for XEmacs, we need to load
|
||||
;; the overlay library, available in version 19.15
|
||||
(and (not (fboundp 'make-overlay))
|
||||
(condition-case nil
|
||||
(require 'overlay)
|
||||
('error
|
||||
(error "Fm needs overlay emulation (available in XEmacs 19.15)"))))
|
||||
|
||||
;; We keep a vector with several different overlays to do our highlighting.
|
||||
(defvar ess-highlight-overlays [nil nil])
|
||||
|
||||
;; Initialize the overlays (here we provide two overlays)
|
||||
(aset ess-highlight-overlays 0 (make-overlay 1 1))
|
||||
(overlay-put (aref ess-highlight-overlays 0) 'face 'highlight)
|
||||
(aset ess-highlight-overlays 1 (make-overlay 1 1))
|
||||
(overlay-put (aref ess-highlight-overlays 1) 'face 'highlight)
|
||||
|
||||
;; Two functions for activating and deactivation highlight overlays
|
||||
(defun ess-highlight (index begin end &optional buffer)
|
||||
"Highlight a region with overlay INDEX."
|
||||
(move-overlay (aref ess-highlight-overlays index)
|
||||
begin end (or buffer (current-buffer))))
|
||||
(defun ess-unhighlight (index)
|
||||
"Detatch overlay INDEX."
|
||||
(delete-overlay (aref ess-highlight-overlays index)))
|
||||
|
||||
;;; End of highlighting code.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; Try to find the .emacs init file and edit it.
|
||||
(save-window-excursion
|
||||
|
||||
;; Try to find the init file if one already exists,
|
||||
;; or create a new one if we can't find any.
|
||||
(if (stringp user-init-file)
|
||||
(find-file user-init-file)
|
||||
;; else, let's guess that the init file should be called ".emacs"
|
||||
;; and the tilde will be resolved okay.
|
||||
(find-file "~/.emacs"))
|
||||
(goto-char (point-min))
|
||||
|
||||
(let ((ess-commands
|
||||
(concat "\n;;; ESS setup for version " ess-new-version "\n"
|
||||
"(load \"" ess-site-file "\")\n"))
|
||||
(new-install)
|
||||
(beg))
|
||||
(if (search-forward ";;; ESS setup for version " nil t)
|
||||
(progn
|
||||
(message "You already have ESS installed.")
|
||||
(setq ess-installed
|
||||
(buffer-substring (point)
|
||||
(save-excursion (end-of-line) (point))))
|
||||
|
||||
(beginning-of-line)
|
||||
(setq beg (point))
|
||||
;; We assume the next line contains a sexp that loads the
|
||||
;; the ess-site; this sexp can be multiple lines.
|
||||
(forward-line 1)
|
||||
(forward-list 1)
|
||||
(ess-highlight 0 beg (point))
|
||||
|
||||
(setq new-install
|
||||
(yes-or-no-p
|
||||
(concat "Replace ESS version " ess-installed
|
||||
" with version "
|
||||
ess-new-version "? ")))
|
||||
(when new-install
|
||||
(kill-region beg (point))
|
||||
(insert ess-commands)
|
||||
(save-buffer)
|
||||
(ess-install-byte-compile)
|
||||
(message (concat "ESS updated to version " ess-new-version))
|
||||
))
|
||||
;; else, just insert commands at end.
|
||||
(goto-char (point-max))
|
||||
(insert ess-commands)
|
||||
(save-buffer)
|
||||
(ess-install-byte-compile)
|
||||
(message (concat "ESS version "ess-new-version" installed."))
|
||||
)))
|
||||
|
||||
;;; ess-install.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-install.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-install.elc
Normal file
Binary file not shown.
260
.emacs.d/elpa/ess-20160208.453/lisp/ess-jags-d.el
Normal file
260
.emacs.d/elpa/ess-20160208.453/lisp/ess-jags-d.el
Normal file
@@ -0,0 +1,260 @@
|
||||
;;; ess-jags-d.el --- ESS[JAGS] dialect
|
||||
|
||||
;; Copyright (C) 2008-2011 Rodney Sparapani
|
||||
|
||||
;; Author: Rodney Sparapani
|
||||
;; Created: 13 March 2008
|
||||
;; Maintainer: ESS-help <ess-help@r-project.org>
|
||||
|
||||
;; This file is part of ESS
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'ess-bugs-l)
|
||||
(require 'ess-utils)
|
||||
(require 'ess-inf)
|
||||
|
||||
(setq auto-mode-alist
|
||||
(append '(("\\.[jJ][aA][gG]\\'" . ess-jags-mode)) auto-mode-alist))
|
||||
|
||||
(defvar ess-jags-command "jags" "Default JAGS program in PATH.")
|
||||
(make-local-variable 'ess-jags-command)
|
||||
|
||||
(defvar ess-jags-monitor '("") "Default list of variables to monitor.")
|
||||
(make-local-variable 'ess-jags-monitor)
|
||||
|
||||
(defvar ess-jags-thin 1 "Default thinning parameter.")
|
||||
(make-local-variable 'ess-jags-thin)
|
||||
|
||||
(defvar ess-jags-chains 1 "Default number of chains.")
|
||||
(make-local-variable 'ess-jags-chains)
|
||||
|
||||
(defvar ess-jags-burnin 10000 "Default burn-in.")
|
||||
(make-local-variable 'ess-jags-burnin)
|
||||
|
||||
(defvar ess-jags-update 10000 "Default number of updates after burnin.")
|
||||
(make-local-variable 'ess-jags-update)
|
||||
|
||||
(defvar ess-jags-system t "Default whether JAGS recognizes the system command.")
|
||||
|
||||
(defvar ess-jags-font-lock-keywords
|
||||
(list
|
||||
;; .jag files
|
||||
(cons "#.*\n" font-lock-comment-face)
|
||||
|
||||
(cons "^[ \t]*\\(model\\|var\\)\\>"
|
||||
font-lock-keyword-face)
|
||||
|
||||
(cons (concat "\\<d\\(bern\\|beta\\|bin\\|cat\\|chisq\\|"
|
||||
"dexp\\|dirch\\|exp\\|\\(gen[.]\\)?gamma\\|hyper\\|"
|
||||
"interval\\|lnorm\\|logis\\|mnorm\\|mt\\|multi\\|"
|
||||
"negbin\\|norm\\(mix\\)?\\|par\\|pois\\|sum\\|t\\|"
|
||||
"unif\\|weib\\|wish\\)[ \t\n]*(")
|
||||
font-lock-constant-face)
|
||||
|
||||
(cons (concat "\\<\\(abs\\|cos\\|dim\\|\\(i\\)?cloglog\\|equals\\|"
|
||||
"exp\\|for\\|inprod\\|interp[.]line\\|inverse\\|length\\|"
|
||||
"\\(i\\)?logit\\|logdet\\|logfact\\|loggam\\|max\\|mean\\|"
|
||||
"mexp\\|min\\|phi\\|pow\\|probit\\|prod\\|rank\\|round\\|"
|
||||
"sd\\|sin\\|sort\\|sqrt\\|step\\|sum\\|t\\|trunc\\|T\\)[ \t\n]*(")
|
||||
font-lock-function-name-face)
|
||||
|
||||
;; .jmd files
|
||||
(cons (concat "\\<\\(adapt\\|cd\\|clear\\|coda\\|data\\|dir\\|"
|
||||
"exit\\|in\\(itialize\\)?\\|load\\|model\\|monitors\\|parameters\\|"
|
||||
"pwd\\|run\\|s\\(amplers\\|ystem\\)\\|to\\|update\\)[ \t\n]")
|
||||
font-lock-keyword-face)
|
||||
|
||||
(cons "\\<\\(compile\\|monitor\\)[, \t\n]"
|
||||
font-lock-keyword-face)
|
||||
|
||||
(cons "[, \t\n]\\(by\\|chain\\|nchains\\|stem\\|thin\\|type\\)[ \t\n]*("
|
||||
font-lock-function-name-face)
|
||||
)
|
||||
"ESS[JAGS]: Font lock keywords."
|
||||
)
|
||||
|
||||
(defun ess-jags-switch-to-suffix (suffix &optional jags-chains jags-monitor jags-thin
|
||||
jags-burnin jags-update)
|
||||
"ESS[JAGS]: Switch to file with suffix."
|
||||
(find-file (concat ess-bugs-file-dir ess-bugs-file-root suffix))
|
||||
|
||||
(if (equal 0 (buffer-size)) (progn
|
||||
(if (equal ".jag" suffix) (progn
|
||||
(insert "var ;\n")
|
||||
(insert "model {\n")
|
||||
(insert " for (i in 1:N) {\n \n")
|
||||
(insert " }\n")
|
||||
(insert "}\n")
|
||||
(insert "#Local Variables" ":\n")
|
||||
(insert "#ess-jags-chains:1\n")
|
||||
(insert "#ess-jags-monitor:(\"\")\n")
|
||||
(insert "#ess-jags-thin:1\n")
|
||||
(insert "#ess-jags-burnin:10000\n")
|
||||
(insert "#ess-jags-update:10000\n")
|
||||
(insert "#End:\n")
|
||||
))
|
||||
|
||||
(if (equal ".jmd" suffix) (let
|
||||
((ess-jags-temp-chains "") (ess-jags-temp-monitor "") (ess-jags-temp-chain ""))
|
||||
|
||||
(if jags-chains (setq ess-jags-chains jags-chains))
|
||||
(if jags-monitor (setq ess-jags-monitor jags-monitor))
|
||||
(if jags-thin (setq ess-jags-thin jags-thin))
|
||||
|
||||
(setq ess-jags-temp-chains
|
||||
(concat "compile, nchains(" (format "%d" ess-jags-chains) ")\n"))
|
||||
|
||||
(setq jags-chains ess-jags-chains)
|
||||
|
||||
(while (< 0 jags-chains)
|
||||
(setq ess-jags-temp-chains
|
||||
(concat ess-jags-temp-chains
|
||||
"parameters ## \"" ess-bugs-file-root
|
||||
".##" (format "%d" jags-chains) "\", chain("
|
||||
(format "%d" jags-chains) ")\n"))
|
||||
(setq jags-chains (- jags-chains 1)))
|
||||
|
||||
(setq ess-jags-temp-monitor "")
|
||||
|
||||
(while (and (listp ess-jags-monitor) (consp ess-jags-monitor))
|
||||
(if (not (string-equal "" (car ess-jags-monitor)))
|
||||
(setq ess-jags-temp-monitor
|
||||
(concat ess-jags-temp-monitor "monitor "
|
||||
(car ess-jags-monitor) ", thin(" (format "%d" ess-jags-thin) ")\n")))
|
||||
(setq ess-jags-monitor (cdr ess-jags-monitor)))
|
||||
|
||||
(insert "model in \"" ess-bugs-file-root ".jag\"\n")
|
||||
(insert "data in \"" ess-bugs-file-root ".jdt\"\n")
|
||||
(insert (ess-replace-in-string ess-jags-temp-chains "##" "in"))
|
||||
(insert "initialize\n")
|
||||
;(insert "update " (format "%d" (* jags-thin jags-burnin)) "\n")
|
||||
(insert "update " (format "%d" jags-burnin) "\n")
|
||||
(insert ess-jags-temp-monitor)
|
||||
(insert "update " (format "%d" (* jags-thin jags-update)) "\n")
|
||||
(insert (ess-replace-in-string
|
||||
(ess-replace-in-string ess-jags-temp-chains
|
||||
"compile, nchains([0-9]+)" "#") "##" "to"))
|
||||
(insert "coda "
|
||||
;(if ess-microsoft-p (if (w32-shell-dos-semantics) "*" "\\*") "\\*")
|
||||
"*, stem(\"" ess-bugs-file-root "\")\n")
|
||||
|
||||
(if ess-jags-system (progn
|
||||
(insert "system rm -f " ess-bugs-file-root ".ind\n")
|
||||
(insert "system ln -s " ess-bugs-file-root "index.txt " ess-bugs-file-root ".ind\n")
|
||||
|
||||
(setq jags-chains ess-jags-chains)
|
||||
|
||||
(while (< 0 jags-chains)
|
||||
(setq ess-jags-temp-chain (format "%d" jags-chains))
|
||||
|
||||
;.txt not recognized by BOA and impractical to over-ride
|
||||
(insert "system rm -f " ess-bugs-file-root ess-jags-temp-chain ".out\n")
|
||||
(insert "system ln -s " ess-bugs-file-root "chain" ess-jags-temp-chain ".txt "
|
||||
ess-bugs-file-root ess-jags-temp-chain ".out\n")
|
||||
(setq jags-chains (- jags-chains 1)))))
|
||||
|
||||
(insert "exit\n")
|
||||
(insert "Local Variables" ":\n")
|
||||
(insert "ess-jags-chains:" (format "%d" ess-jags-chains) "\n")
|
||||
(insert "ess-jags-command:\"jags\"\n")
|
||||
(insert "End:\n")
|
||||
))
|
||||
))
|
||||
)
|
||||
|
||||
(defun ess-jags-na-jmd (jags-command jags-chains)
|
||||
"ESS[JAGS]: Perform the Next-Action for .jmd."
|
||||
;(ess-save-and-set-local-variables)
|
||||
(if (equal 0 (buffer-size)) (ess-jags-switch-to-suffix ".jmd")
|
||||
;else
|
||||
(shell)
|
||||
(ess-sleep)
|
||||
|
||||
(if (w32-shell-dos-semantics)
|
||||
(if (string-equal ":" (substring ess-bugs-file 1 2))
|
||||
(progn
|
||||
(insert (substring ess-bugs-file 0 2))
|
||||
(comint-send-input)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(insert "cd \"" ess-bugs-file-dir "\"")
|
||||
(comint-send-input)
|
||||
|
||||
; (let ((ess-jags-temp-chains ""))
|
||||
;
|
||||
; (while (< 0 jags-chains)
|
||||
; (setq ess-jags-temp-chains
|
||||
; (concat (format "%d " jags-chains) ess-jags-temp-chains))
|
||||
; (setq jags-chains (- jags-chains 1)))
|
||||
|
||||
(insert ess-bugs-batch-pre-command " " jags-command " "
|
||||
ess-bugs-file-root ".jmd "
|
||||
|
||||
(if (or (equal shell-file-name "/bin/csh")
|
||||
(equal shell-file-name "/bin/tcsh")
|
||||
(equal shell-file-name "/bin/zsh")
|
||||
(equal shell-file-name "/bin/bash"))
|
||||
(concat ">& " ess-bugs-file-root ".jog ")
|
||||
;else
|
||||
"> " ess-bugs-file-root ".jog 2>&1 ")
|
||||
|
||||
; ;.txt not recognized by BOA and impractical to over-ride
|
||||
; "&& (rm -f " ess-bugs-file-root ".ind; "
|
||||
; "ln -s " ess-bugs-file-root "index.txt " ess-bugs-file-root ".ind; "
|
||||
; "for i in " ess-jags-temp-chains "; do; "
|
||||
; "rm -f " ess-bugs-file-root "$i.out; "
|
||||
; "ln -s " ess-bugs-file-root "chain$i.txt " ess-bugs-file-root "$i.out; done) "
|
||||
|
||||
ess-bugs-batch-post-command)
|
||||
|
||||
(comint-send-input)
|
||||
))
|
||||
|
||||
(defun ess-jags-na-bug ()
|
||||
"ESS[JAGS]: Perform Next-Action for .jag"
|
||||
|
||||
(if (equal 0 (buffer-size)) (ess-jags-switch-to-suffix ".jag")
|
||||
;else
|
||||
(ess-save-and-set-local-variables)
|
||||
(ess-jags-switch-to-suffix ".jmd"
|
||||
ess-jags-chains ess-jags-monitor ess-jags-thin ess-jags-burnin ess-jags-update))
|
||||
)
|
||||
|
||||
(defun ess-jags-mode ()
|
||||
"ESS[JAGS]: Major mode for JAGS."
|
||||
(interactive)
|
||||
(kill-all-local-variables)
|
||||
(ess-setq-vars-local '((comment-start . "#")))
|
||||
(setq major-mode 'ess-jags-mode)
|
||||
(setq mode-name "ESS[JAGS]")
|
||||
(use-local-map ess-bugs-mode-map)
|
||||
(setq font-lock-auto-fontify t)
|
||||
(make-local-variable 'font-lock-defaults)
|
||||
(setq font-lock-defaults '(ess-jags-font-lock-keywords nil t))
|
||||
(setq ess-language "S") ; mimic S for ess-smart-underscore
|
||||
(run-hooks 'ess-bugs-mode-hook)
|
||||
|
||||
(if (not (w32-shell-dos-semantics))
|
||||
(add-hook 'comint-output-filter-functions 'ess-bugs-exit-notify-sh))
|
||||
)
|
||||
|
||||
(setq features (delete 'ess-bugs-d features))
|
||||
(provide 'ess-jags-d)
|
||||
|
||||
;;; ess-jags-d.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-jags-d.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-jags-d.elc
Normal file
Binary file not shown.
414
.emacs.d/elpa/ess-20160208.453/lisp/ess-julia.el
Normal file
414
.emacs.d/elpa/ess-20160208.453/lisp/ess-julia.el
Normal file
@@ -0,0 +1,414 @@
|
||||
;; ess-julia.el --- ESS julia mode and inferior interaction
|
||||
;;
|
||||
;; Copyright (C) 2012-2015 Vitalie Spinu and the ESS Core team.
|
||||
;;
|
||||
;; Filename: ess-julia.el
|
||||
;; Author: Vitalie Spinu (based on julia-mode.el from julia-lang project)
|
||||
;; Maintainer: Vitalie Spinu
|
||||
;; Created: 02-04-2012 (ESS 12.03)
|
||||
;; Keywords: ESS, julia
|
||||
;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; This file is *NOT* part of GNU Emacs.
|
||||
;; This file is part of ESS
|
||||
;;
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 3, or
|
||||
;; (at your option) any later version.
|
||||
;;
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
;;
|
||||
;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; Customise inferior-julia-program-name to point to your julia binary
|
||||
;; and start the inferior with M-x julia.
|
||||
;;
|
||||
;; As of Sept 2015, this file depends heavily on julia-mode.el from the Julia
|
||||
;; sources. If you install ESS using `make', this will work fine, otherwise
|
||||
;; ensure that julia-mode.el is on your path before loading this file.
|
||||
;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
(require 'compile); for compilation-* below
|
||||
(require 'ess-utils)
|
||||
|
||||
;;;--- ALL the following only if julia-mode is found and loaded correctly : ----------
|
||||
(condition-case nil
|
||||
(progn
|
||||
(require 'julia-mode)
|
||||
(when (featurep 'julia-mode)
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(autoload 'inferior-ess "ess-inf" "Run an ESS process.")
|
||||
(autoload 'ess-mode "ess-mode" "Edit an ESS process.")
|
||||
|
||||
(defun ess-julia-send-string-function (process string visibly)
|
||||
"Send the Julia STRING to the PROCESS.
|
||||
VISIBLY is not currently used."
|
||||
(let ((file (concat temporary-file-directory "julia_eval_region.jl")))
|
||||
(with-temp-file file
|
||||
(insert string))
|
||||
(process-send-string process (format ess-load-command file))))
|
||||
|
||||
|
||||
;;; HELP
|
||||
(defun ess-julia-get-help-topics (&optional proc)
|
||||
(append (ess-get-words-from-vector "ESS.all_help_topics()\n")
|
||||
(ess-julia--get-objects)))
|
||||
;; (ess-command com)))
|
||||
|
||||
(defun ess-julia--retrive-topics (url)
|
||||
(with-current-buffer (url-retrieve-synchronously url)
|
||||
(require 'url)
|
||||
(goto-char (point-min))
|
||||
(let (out)
|
||||
(while (re-search-forward "toctree.*href=\"\\(.+\\)\">\\(.+\\)</a" nil t)
|
||||
(push (propertize (match-string 2)
|
||||
:manual (concat url (match-string 1)))
|
||||
out))
|
||||
(kill-buffer)
|
||||
(nreverse out))))
|
||||
|
||||
(defvar ess-julia--manual-topics nil)
|
||||
(defun ess-julia-manual-lookup-function (&rest args) ; args are not used
|
||||
(interactive)
|
||||
"Look up topics at http://docs.julialang.org/en/latest/manual/"
|
||||
;; <li class="toctree-l1"><a class="reference internal" href="introduction/">Introduction</a></li>
|
||||
(let* ((pages (or ess-julia--manual-topics
|
||||
(setq ess-julia--manual-topics
|
||||
(ess-julia--retrive-topics "http://docs.julialang.org/en/latest/manual/"))))
|
||||
(page (ess-completing-read "Lookup:" pages nil t)))
|
||||
(browse-url (get-text-property 1 :manual page))))
|
||||
|
||||
(defun ess-julia-input-sender (proc string)
|
||||
(save-current-buffer
|
||||
(let* ((help-?-regexp "^ *\\(?:\\(?1: *?\\? *\\)\\(?2:.+\\)\\)")
|
||||
(help-?-match (string-match help-?-regexp string)))
|
||||
(cond (help-?-match
|
||||
(ess-display-help-on-object (match-string 2 string))
|
||||
(process-send-string proc "\n"))
|
||||
(t ;; normal command
|
||||
(inferior-ess-input-sender proc string))))))
|
||||
|
||||
;; julia 0.3.0 doesn't provide categories. Thus we don't support this anymore.
|
||||
;; (defun ess-julia-reference-lookup-function (&rest args) ; args are not used
|
||||
;; (interactive)
|
||||
;; "Look up reference topics"
|
||||
;; ;; <li class="toctree-l1"><a class="reference internal" href="introduction/">Introduction</a></li>
|
||||
;; (let* ((pages (ess-get-words-from-vector "ESS.help_categories()\n")))
|
||||
;; (ess-display-help-on-object
|
||||
;; (ess-completing-read "Category" pages nil t))))
|
||||
|
||||
|
||||
|
||||
;;; COMPLETION
|
||||
(defun ess-julia-object-completion ()
|
||||
"Return completions at point in a format required by `completion-at-point-functions'. "
|
||||
(let ((proc (ess-get-next-available-process ess-dialect t))
|
||||
(beg (ess-symbol-start)))
|
||||
(if proc
|
||||
(when beg
|
||||
(let* ((prefix (buffer-substring-no-properties beg (point)))
|
||||
(obj (and (string-match "\\(.*\\)\\..*$" prefix)
|
||||
(match-string 1 prefix)))
|
||||
(beg (if obj
|
||||
(+ beg 1 (length obj))
|
||||
beg)))
|
||||
(list beg (point)
|
||||
(nreverse (mapcar 'car (ess-julia--get-objects proc obj)))
|
||||
:exclusive 'no)))
|
||||
(when (string-match "complet" (symbol-name last-command))
|
||||
(message "No ESS process of dialect %s started" ess-dialect)
|
||||
nil))))
|
||||
|
||||
(defun ess-julia-objects (prefix)
|
||||
"Get all cached objects"
|
||||
(when prefix
|
||||
(let ((proc (ess-get-next-available-process nil t)))
|
||||
(if (string-match "\\(.*\\)\\..*$" prefix)
|
||||
(let ((module (match-string 1 prefix)))
|
||||
(mapcar (lambda (el) (concat module "." (car el)))
|
||||
(ess-julia--get-objects proc module)))
|
||||
(ess-julia--get-objects proc)))))
|
||||
|
||||
(defun ess-julia--get-objects (&optional proc obj)
|
||||
"Return all available objects.
|
||||
Local caching might be used. If MODULE is givven, return only
|
||||
objects from that MODULE."
|
||||
(setq proc (or proc
|
||||
(get-process ess-local-process-name)))
|
||||
(when (process-live-p proc)
|
||||
(let ((objects (process-get proc 'objects)))
|
||||
(if (process-get proc 'busy)
|
||||
(if obj
|
||||
(assoc obj objects)
|
||||
(process-get proc 'objects))
|
||||
(if obj
|
||||
(or (cdr (assoc obj objects))
|
||||
;; don't cache composite objects and datatypes
|
||||
(ess-julia--get-components proc obj))
|
||||
;; this segment is entered when user completon at top level is
|
||||
;; requested, either Tab or AC. Hence Main is always updated.
|
||||
(let ((modules (ess-get-words-from-vector
|
||||
"ESS.main_modules()\n" nil nil proc))
|
||||
(loc (process-get proc 'last-objects-cache))
|
||||
(lev (process-get proc 'last-eval)))
|
||||
(prog1
|
||||
(apply #'nconc
|
||||
(mapcar
|
||||
(lambda (mod)
|
||||
;; we are caching all modules, and reinit Main every
|
||||
;; time user enters commands
|
||||
(copy-sequence
|
||||
(or (and (or (not (equal mod "Main"))
|
||||
(ignore-errors (time-less-p lev loc)))
|
||||
(cdr (assoc mod objects)))
|
||||
(ess-julia--get-components proc mod t))))
|
||||
modules))
|
||||
(process-put proc 'last-objects-cache (current-time)))))))))
|
||||
|
||||
(defun ess-julia--get-components (proc obj &optional cache?)
|
||||
(with-current-buffer (ess-command (format "ESS.components(%s)\n" obj)
|
||||
nil nil nil nil proc)
|
||||
(goto-char (point-min))
|
||||
(let (list)
|
||||
(while (re-search-forward
|
||||
"^\\([^ \t\n]+\\) +\\([^ \t\n]+\\)$" nil t)
|
||||
(push (cons (match-string 1) (match-string 2)) list))
|
||||
(when cache?
|
||||
(let ((objects (process-get proc 'objects)))
|
||||
(push (cons obj list) objects)
|
||||
(process-put proc 'objects objects)))
|
||||
list)))
|
||||
|
||||
(defun ess-julia-get-object-help-string (sym)
|
||||
"Help string for ac."
|
||||
(let ((proc (ess-get-next-available-process nil t)))
|
||||
(if (null proc)
|
||||
"No free ESS process found"
|
||||
(let ((buf (get-buffer-create " *ess-command-output*")))
|
||||
(with-current-buffer (process-buffer proc)
|
||||
(ess-with-current-buffer buf
|
||||
(ess--flush-help-into-current-buffer sym nil t)))
|
||||
(with-current-buffer buf
|
||||
(ess-help-underline)
|
||||
(goto-char (point-min))
|
||||
(buffer-string))))))
|
||||
|
||||
(defvar ac-source-ess-julia-objects
|
||||
'((prefix . ess-symbol-start)
|
||||
(requires . 2)
|
||||
(candidates . ess-ac-julia-objects)
|
||||
(document . ess-julia-get-object-help-string))
|
||||
"Auto-completion source for julia objects")
|
||||
|
||||
(defun ess-ac-julia-objects ()
|
||||
(ess-julia-objects ac-prefix))
|
||||
|
||||
(defun company-ess-julia-objects (command &optional arg &rest ignored)
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-ess-julia-objects))
|
||||
(prefix (unless (company-in-string-or-comment)
|
||||
(let ((start (ess-symbol-start)))
|
||||
(when start (buffer-substring-no-properties start (point))))))
|
||||
(candidates (all-completions arg (mapcar #'car (ess-julia-objects arg))))
|
||||
(doc-buffer (company-doc-buffer (ess-julia-get-object-help-string arg)))))
|
||||
|
||||
|
||||
;;; ERRORS
|
||||
(defvar ess-julia-error-regexp-alist '(ess-julia-in ess-julia-at ess-julia-while-load)
|
||||
"List of symbols which are looked up in `compilation-error-regexp-alist-alist'.")
|
||||
|
||||
(add-to-list 'compilation-error-regexp-alist-alist
|
||||
'(ess-julia-in "^\\s-*in [^ \t\n]* \\(at \\(.*\\):\\([0-9]+\\)\\)" 2 3 nil 2 1))
|
||||
(add-to-list 'compilation-error-regexp-alist-alist
|
||||
'(ess-julia-at "^\\S-+\\s-+\\(at \\(.*\\):\\([0-9]+\\)\\)" 2 3 nil 2 1))
|
||||
(add-to-list 'compilation-error-regexp-alist-alist
|
||||
'(ess-julia-while-load "^\\s-*\\(while loading\\s-\\(.*\\), in .* on line +\\([0-9]+\\)\\)" 2 3 nil 2 1))
|
||||
|
||||
|
||||
;;; ELDOC
|
||||
(defun ess-julia-eldoc-function ()
|
||||
"Return the doc string, or nil.
|
||||
If an ESS process is not associated with the buffer, do not try
|
||||
to look up any doc strings."
|
||||
(interactive)
|
||||
(when (and (ess-process-live-p)
|
||||
(not (ess-process-get 'busy)))
|
||||
(let ((funname (or (and ess-eldoc-show-on-symbol ;; aggressive completion
|
||||
(symbol-at-point))
|
||||
(car (ess--funname.start)))))
|
||||
(when funname
|
||||
(let* ((args (copy-sequence (nth 2 (ess-function-arguments funname))))
|
||||
(W (- (window-width (minibuffer-window)) (+ 4 (length funname))))
|
||||
(doc (concat (propertize funname 'face font-lock-function-name-face) ": ")))
|
||||
(when args
|
||||
(setq args (sort args (lambda (s1 s2)
|
||||
(< (length s1) (length s2)))))
|
||||
(setq doc (concat doc (pop args)))
|
||||
(while (and args (< (+ (length doc) (length (car args))) W))
|
||||
(setq doc (concat doc " "
|
||||
(pop args))))
|
||||
(when (and args (< (length doc) W))
|
||||
(setq doc (concat doc " {--}"))))
|
||||
doc)))))
|
||||
|
||||
|
||||
;;; IMENU
|
||||
(defvar ess-julia-imenu-generic-expression
|
||||
;; don't use syntax classes, screws egrep
|
||||
'(("Function (_)" "[ \t]*function[ \t]+\\(_[^ \t\n]*\\)" 1)
|
||||
("Function" "^[ \t]*function[ \t]+\\([^_][^\t\n]*\\)" 1)
|
||||
("Const" "[ \t]*const \\([^ \t\n]*\\)" 1)
|
||||
("Type" "^[ \t]*[a-zA-Z0-9_]*type[a-zA-Z0-9_]* \\([^ \t\n]*\\)" 1)
|
||||
("Require" " *\\(\\brequire\\)(\\([^ \t\n)]*\\)" 2)
|
||||
("Include" " *\\(\\binclude\\)(\\([^ \t\n)]*\\)" 2)
|
||||
))
|
||||
|
||||
|
||||
;;; CORE
|
||||
(defvar ess-julia-customize-alist
|
||||
'((comint-use-prompt-regexp . t)
|
||||
(ess-eldoc-function . 'ess-julia-eldoc-function)
|
||||
(inferior-ess-primary-prompt . "a> ") ;; from julia>
|
||||
(inferior-ess-secondary-prompt . nil)
|
||||
(inferior-ess-prompt . "\\w*> ")
|
||||
(ess-local-customize-alist . 'ess-julia-customize-alist)
|
||||
(inferior-ess-program . inferior-julia-program-name)
|
||||
(ess-get-help-topics-function . 'ess-julia-get-help-topics)
|
||||
(ess-help-web-search-command . "http://docs.julialang.org/en/latest/search/?q=%s")
|
||||
(ess-manual-lookup-command . 'ess-julia-manual-lookup-function)
|
||||
;; (ess-reference-lookup-command . 'ess-julia-reference-lookup-function)
|
||||
(ess-load-command . "include(\"%s\")\n")
|
||||
(ess-funargs-command . "ESS.fun_args(\"%s\")\n")
|
||||
(ess-dump-error-re . "in \\w* at \\(.*\\):[0-9]+")
|
||||
(ess-error-regexp . "\\(^\\s-*at\\s-*\\(?3:.*\\):\\(?2:[0-9]+\\)\\)")
|
||||
(ess-error-regexp-alist . ess-julia-error-regexp-alist)
|
||||
(ess-send-string-function . nil);'ess-julia-send-string-function)
|
||||
(ess-imenu-generic-expression . ess-julia-imenu-generic-expression)
|
||||
;; (inferior-ess-objects-command . inferior-R-objects-command)
|
||||
;; (inferior-ess-search-list-command . "search()\n")
|
||||
(inferior-ess-help-command . "ESS.help(\"%s\")\n")
|
||||
;; (inferior-ess-help-command . "help(\"%s\")\n")
|
||||
(ess-language . "julia")
|
||||
(ess-dialect . "julia")
|
||||
(ess-suffix . "jl")
|
||||
(ess-ac-sources . '(ac-source-ess-julia-objects))
|
||||
(ess-company-backends . '(company-ess-julia-objects))
|
||||
(ess-dump-filename-template . (ess-replace-regexp-in-string
|
||||
"S$" ess-suffix ; in the one from custom:
|
||||
ess-dump-filename-template-proto))
|
||||
(ess-mode-editing-alist . nil)
|
||||
(ess-change-sp-regexp . nil );ess-R-change-sp-regexp)
|
||||
(ess-help-sec-regex . ess-help-R-sec-regex)
|
||||
(ess-help-sec-keys-alist . ess-help-R-sec-keys-alist)
|
||||
(ess-loop-timeout . ess-S-loop-timeout);fixme: dialect spec.
|
||||
(ess-cmd-delay . ess-R-cmd-delay)
|
||||
(ess-function-pattern . ess-R-function-pattern)
|
||||
(ess-object-name-db-file . "ess-jl-namedb.el" )
|
||||
(ess-smart-operators . ess-R-smart-operators)
|
||||
(inferior-ess-help-filetype . nil)
|
||||
(inferior-ess-exit-command . "exit()\n")
|
||||
;;harmful for shell-mode's C-a: -- but "necessary" for ESS-help?
|
||||
(inferior-ess-start-file . nil) ;; "~/.ess-R"
|
||||
(inferior-ess-start-args . "")
|
||||
(inferior-ess-language-start . nil)
|
||||
(ess-STERM . "iESS")
|
||||
(ess-editor . R-editor)
|
||||
(ess-pager . R-pager)
|
||||
)
|
||||
"Variables to customize for Julia -- set up later than emacs initialization.")
|
||||
|
||||
(defcustom inferior-julia-args ""
|
||||
"String of arguments (see 'julia --help') used when starting julia."
|
||||
:group 'ess-julia
|
||||
:type 'string)
|
||||
|
||||
(defvar ess-julia-mode-map ess-mode-map)
|
||||
|
||||
;;;###autoload
|
||||
(define-derived-mode ess-julia-mode julia-mode "ESS[julia-derived]"
|
||||
"Major mode for editing julia source. See `ess-mode' for more help."
|
||||
(ess-mode ess-julia-customize-alist nil t)
|
||||
;; for emacs >= 24
|
||||
(remove-hook 'completion-at-point-functions 'ess-filename-completion 'local) ;; should be first
|
||||
(add-hook 'completion-at-point-functions 'ess-julia-object-completion nil 'local)
|
||||
(add-hook 'completion-at-point-functions 'ess-filename-completion nil 'local)
|
||||
(if (fboundp 'ess-add-toolbar) (ess-add-toolbar))
|
||||
(set (make-local-variable 'end-of-defun-function) 'ess-end-of-function)
|
||||
|
||||
(set (make-local-variable 'ess-julia-basic-offset) 4)
|
||||
(setq imenu-generic-expression ess-julia-imenu-generic-expression)
|
||||
(imenu-add-to-menubar "Imenu-jl")
|
||||
(run-hooks 'ess-julia-mode-hook))
|
||||
|
||||
(defvar ess-julia-mode-hook nil)
|
||||
(defvar ess-julia-post-run-hook nil
|
||||
"Functions run in process buffer after starting julia process.")
|
||||
|
||||
;;;###autoload
|
||||
(defun julia (&optional start-args)
|
||||
"Call 'julia'.
|
||||
Optional prefix (C-u) allows to set command line arguments, such as
|
||||
--load=<file>. This should be OS agnostic.
|
||||
If you have certain command line arguments that should always be passed
|
||||
to julia, put them in the variable `inferior-julia-args'."
|
||||
(interactive "P")
|
||||
;; get settings, notably inferior-julia-program-name :
|
||||
(if (null inferior-julia-program-name)
|
||||
(error "'inferior-julia-program-name' does not point to 'julia' or 'julia-basic' executable")
|
||||
(setq ess-customize-alist ess-julia-customize-alist)
|
||||
(ess-write-to-dribble-buffer ;; for debugging only
|
||||
(format
|
||||
"\n(julia): ess-dialect=%s, buf=%s, start-arg=%s\n current-prefix-arg=%s\n"
|
||||
ess-dialect (current-buffer) start-args current-prefix-arg))
|
||||
(let* ((jl-start-args
|
||||
(concat inferior-julia-args " " ; add space just in case
|
||||
(if start-args
|
||||
(read-string
|
||||
(concat "Starting Args"
|
||||
(if inferior-julia-args
|
||||
(concat " [other than '" inferior-julia-args "']"))
|
||||
" ? "))
|
||||
nil))))
|
||||
(inferior-ess jl-start-args)
|
||||
|
||||
(remove-hook 'completion-at-point-functions 'ess-filename-completion 'local) ;; should be first
|
||||
(add-hook 'completion-at-point-functions 'ess-julia-object-completion nil 'local)
|
||||
(add-hook 'completion-at-point-functions 'ess-filename-completion nil 'local)
|
||||
(setq comint-input-sender 'ess-julia-input-sender)
|
||||
|
||||
(ess--tb-start)
|
||||
(set (make-local-variable 'ess-julia-basic-offset) 4)
|
||||
;; remove ` from julia's logo
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "`" nil t)
|
||||
(replace-match "'"))
|
||||
(goto-char (point-max))
|
||||
;; --> julia helpers from ../etc/ess-julia.jl :
|
||||
(ess--inject-code-from-file (format "%sess-julia.jl" ess-etc-directory))
|
||||
(with-ess-process-buffer nil
|
||||
(run-mode-hooks 'ess-julia-post-run-hook))
|
||||
)))
|
||||
|
||||
(add-to-list 'auto-mode-alist '("\\.jl\\'" . ess-julia-mode))
|
||||
|
||||
)) (error nil))
|
||||
(provide 'ess-julia)
|
||||
;;; ess-julia.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-julia.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-julia.elc
Normal file
Binary file not shown.
82
.emacs.d/elpa/ess-20160208.453/lisp/ess-lsp-l.el
Normal file
82
.emacs.d/elpa/ess-20160208.453/lisp/ess-lsp-l.el
Normal file
@@ -0,0 +1,82 @@
|
||||
;;; ess-lsp-l.el --- Support for editing Lisp source code
|
||||
|
||||
;; Copyright (C) 1997 A.J. Rossini.
|
||||
;; Copyright (C) 1998--2004 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: A.J. Rossini <rossini@stat.sc.edu>
|
||||
;; Created: 1 Sept 1997
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; This file is part of ESS.
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Configurations for editing XLispStat source code. Contains any underlying
|
||||
;; changes that need to be made.
|
||||
|
||||
;;; Code:
|
||||
|
||||
; Requires and autoloads
|
||||
|
||||
;; Contents "translated" from lisp-mode.el
|
||||
(require 'lisp-mode)
|
||||
|
||||
; Configuration variables
|
||||
|
||||
|
||||
|
||||
(defvar Lisp-editing-alist
|
||||
'((paragraph-start . (concat "^$\\|" page-delimiter))
|
||||
(paragraph-separate . (concat "^$\\|" page-delimiter))
|
||||
(paragraph-ignore-fill-prefix . t)
|
||||
(fill-paragraph-function . 'lisp-fill-paragraph)
|
||||
(adaptive-fill-mode . nil)
|
||||
(indent-line-function . 'lisp-indent-line)
|
||||
(indent-region-function . 'lisp-indent-region)
|
||||
(require-final-newline . mode-require-final-newline)
|
||||
(comment-start . ";")
|
||||
(comment-start-skip . "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
|
||||
(comment-column . 40)
|
||||
(comment-indent-function . 'lisp-comment-indent)
|
||||
(parse-sexp-ignore-comments . t)
|
||||
(ess-style . ess-default-style)
|
||||
(ess-local-process-name . nil)
|
||||
;;(ess-keep-dump-files . 'ask)
|
||||
(ess-mode-syntax-table . lisp-mode-syntax-table)
|
||||
(font-lock-defaults . '(lisp-font-lock-keywords)))
|
||||
"General options for editing LispStat, XLispStat, and ViSta source files.")
|
||||
|
||||
(provide 'ess-lsp-l)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; outline-minor-mode: nil
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-lsp-l.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-lsp-l.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-lsp-l.elc
Normal file
Binary file not shown.
162
.emacs.d/elpa/ess-20160208.453/lisp/ess-menu.el
Normal file
162
.emacs.d/elpa/ess-20160208.453/lisp/ess-menu.el
Normal file
@@ -0,0 +1,162 @@
|
||||
;;; ess-menu.el --- Menu and Speedbar support for statistical
|
||||
;;; programming and analysis
|
||||
|
||||
;; Copyright (C) 2000--2005 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: A.J. Rossini
|
||||
;; Created: September 4, 2000
|
||||
;; Maintainer: ESS Core Team <ESS-core@r-project.org>
|
||||
|
||||
;; Keywords: statistics, languages
|
||||
|
||||
;; Summary: general functions for ESS
|
||||
|
||||
;; This file is part of ESS
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
|
||||
;;*;; Requires and autoloads
|
||||
;;;=====================================================
|
||||
|
||||
(require 'ess-custom)
|
||||
(if (and (featurep 'xemacs); need this, since require in XEmacs has only 2 arg
|
||||
(not (require 'imenu "imenu.elc")))
|
||||
(message "** warning: 'imenu not available for this version of XEmacs"))
|
||||
|
||||
;;(defgroup ess-menu nil
|
||||
;; "ESS: object menu systems."
|
||||
;; :group 'ess
|
||||
;; :prefix "ess-")
|
||||
|
||||
|
||||
;;; Function Menu (func-menu) for XEmacs:
|
||||
|
||||
;; (if ess-funcmenu-use-p
|
||||
;; (defvar fume-function-name-regexp-S
|
||||
;; (append
|
||||
;; '((s-mode . fume-function-name-regexp-smode)
|
||||
;; (r-mode . fume-function-name-regexp-smode))
|
||||
;; fume-function-name-regexp-alist)
|
||||
;; "Expression to get function names"))
|
||||
|
||||
;;; Imenu for Emacs/XEmacs...
|
||||
|
||||
;;; XLS imenu support
|
||||
|
||||
;; (defun ess-imenu-XLS (&optional arg)
|
||||
;; "XLispStat Language Imenu support for ESS."
|
||||
;; (interactive)
|
||||
;; (setq imenu-generic-expression
|
||||
;; '( (nil "New one needed" 1)))
|
||||
;; (imenu-add-to-menubar "XLS-fcts"))
|
||||
|
||||
;; (defun imenu-example--XLS-extract-index-name ()
|
||||
;; ;; Example of a candidate for `imenu-extract-index-name-function'.
|
||||
;; ;; This will generate a flat index of definitions in a lisp file.
|
||||
;; (save-match-data
|
||||
;; (and (looking-at "(def")
|
||||
;; (condition-case nil
|
||||
;; (progn
|
||||
;; (down-list 1)
|
||||
;; (forward-sexp 2)
|
||||
;; (let ((beg (point))
|
||||
;; (end (progn (forward-sexp -1) (point))))
|
||||
;; (buffer-substring beg end)))
|
||||
;; (error nil)))))
|
||||
|
||||
;; (defun imenu-example--create-XLS-index ()
|
||||
;; ;; Example of a candidate for `imenu-create-index-function'.
|
||||
;; ;; It will generate a nested index of definitions.
|
||||
;; (let ((index-alist '())
|
||||
;; (index-var-alist '())
|
||||
;; (index-type-alist '())
|
||||
;; (index-unknown-alist '())
|
||||
;; prev-pos)
|
||||
;; (goto-char (point-max))
|
||||
;; (imenu-progress-message prev-pos 0)
|
||||
;; ;; Search for the function
|
||||
;; (while (beginning-of-defun)
|
||||
;; (imenu-progress-message prev-pos nil t)
|
||||
;; (save-match-data
|
||||
;; (and (looking-at "(def")
|
||||
;; (save-excursion
|
||||
;; (down-list 1)
|
||||
;; (cond
|
||||
;; ((looking-at "def\\(var\\|const\\)")
|
||||
;; (forward-sexp 2)
|
||||
;; (push (imenu-example--name-and-position)
|
||||
;; index-var-alist))
|
||||
;; ((looking-at "def\\(un\\|subst\\|macro\\|advice\\)")
|
||||
;; (forward-sexp 2)
|
||||
;; (push (imenu-example--name-and-position)
|
||||
;; index-alist))
|
||||
;; ((looking-at "def\\(type\\|struct\\|class\\|ine-condition\\)")
|
||||
;; (forward-sexp 2)
|
||||
;; (if (= (char-after (1- (point))) ?\))
|
||||
;; (progn
|
||||
;; (forward-sexp -1)
|
||||
;; (down-list 1)
|
||||
;; (forward-sexp 1)))
|
||||
;; (push (imenu-example--name-and-position)
|
||||
;; index-type-alist))
|
||||
;; (t
|
||||
;; (forward-sexp 2)
|
||||
;; (push (imenu-example--name-and-position)
|
||||
;; index-unknown-alist)))))))
|
||||
;; (imenu-progress-message prev-pos 100)
|
||||
;; (and index-var-alist
|
||||
;; (push (cons "Variables" index-var-alist)
|
||||
;; index-alist))
|
||||
;; (and index-type-alist
|
||||
;; (push (cons "Types" index-type-alist)
|
||||
;; index-alist))
|
||||
;; (and index-unknown-alist
|
||||
;; (push (cons "Syntax-unknown" index-unknown-alist)
|
||||
;; index-alist))
|
||||
;; index-alist))
|
||||
|
||||
;; (defun ess-imenu-STA (&optional arg)
|
||||
;; "Stata Language Imenu support for ESS."
|
||||
;; (interactive)
|
||||
;; (setq imenu-generic-expression
|
||||
;; '( (nil "New one needed" 1)))
|
||||
;; (imenu-add-to-menubar "Stata-fcts"))
|
||||
|
||||
; Run load hook and provide package
|
||||
|
||||
(provide 'ess-menu)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-menu.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-menu.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-menu.elc
Normal file
Binary file not shown.
1143
.emacs.d/elpa/ess-20160208.453/lisp/ess-mode.el
Normal file
1143
.emacs.d/elpa/ess-20160208.453/lisp/ess-mode.el
Normal file
File diff suppressed because it is too large
Load Diff
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-mode.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-mode.elc
Normal file
Binary file not shown.
257
.emacs.d/elpa/ess-20160208.453/lisp/ess-mouse.el
Normal file
257
.emacs.d/elpa/ess-20160208.453/lisp/ess-mouse.el
Normal file
@@ -0,0 +1,257 @@
|
||||
;;; ess-mouse.el --- Support for mouse- or cursor-sensitive actions
|
||||
|
||||
;; Copyright (C) 2001 Richard M. Heiberger <rmh@temple.edu>
|
||||
;; Copyright (C) 2002--2004 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: Richard M. Heiberger <rmh@temple.edu>
|
||||
;; Created: 25 Mar 2001
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; This file is part of ESS
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Support for mouse- or cursor-sensitive actions. This is based on
|
||||
;; and uses mouseme.el. mouseme.el only does mouse sensititivity.
|
||||
;; The new functions ess-mouse-me and ess-mouse-me-helper do similar
|
||||
;; things based on the cursor, not the mouse, and can be bound to a
|
||||
;; keystroke.
|
||||
|
||||
;;; Code:
|
||||
|
||||
; Requires and autoloads
|
||||
|
||||
;;*;; Requires
|
||||
(require 'mouseme)
|
||||
;;(if (or (equal window-system 'w32)
|
||||
;; (equal window-system 'win32)
|
||||
;; (equal window-system 'mswindows))
|
||||
;; (require 'essiw32b))
|
||||
|
||||
(defun ess-mouse-me ()
|
||||
"Popup a menu of functions to run on selected string or region."
|
||||
(interactive)
|
||||
(ess-mouse-me-helper
|
||||
(lambda ()
|
||||
(or (x-popup-menu (list '(0 0)
|
||||
(get-buffer-window (get-buffer (buffer-name))))
|
||||
(funcall mouse-me-build-menu-function name))
|
||||
(error "No command to run")))))
|
||||
|
||||
|
||||
|
||||
(defun ess-mouse-me-helper (func)
|
||||
"Determine the string to use to process EVENT and call FUNC to get cmd."
|
||||
(let (name sp sm mouse beg end cmd mmtype)
|
||||
;; temporarily goto where the event occurred, get the name clicked
|
||||
;; on and enough info to figure out what to do with it
|
||||
(save-match-data
|
||||
(save-excursion
|
||||
(setq sp (point)) ; saved point
|
||||
(setq sm (mark t)) ; saved mark
|
||||
;;; (set-buffer (window-buffer (posn-window (event-start event))))
|
||||
;;; (setq mouse (goto-char (posn-point (event-start event))))
|
||||
(setq mouse (point)) ;; ess-mouse-me-helper
|
||||
;; if there is a region and point is inside it
|
||||
;; check for sm first incase (null (mark t))
|
||||
;; set name to either the thing they clicked on or region
|
||||
(if (and sm
|
||||
(or (and transient-mark-mode mark-active)
|
||||
(eq last-command 'mouse-drag-region))
|
||||
(>= mouse (setq beg (min sp sm)))
|
||||
(<= mouse (setq end (max sp sm))))
|
||||
(setq name (buffer-substring beg end))
|
||||
(setq name (funcall mouse-me-get-string-function))
|
||||
(if (listp name)
|
||||
(setq beg (nth 1 name)
|
||||
end (nth 2 name)
|
||||
name (car name))
|
||||
(goto-char mouse)
|
||||
(while (not (looking-at (regexp-quote name)))
|
||||
(backward-char 1))
|
||||
(setq beg (point))
|
||||
(setq end (search-forward name))))))
|
||||
;; check if name is null, meaning they clicked on no word
|
||||
(if (or (null name)
|
||||
(and (stringp name) (string= name "" )))
|
||||
(error "No string to pass to function"))
|
||||
;; popup a menu to get a command to run
|
||||
(setq cmd (funcall func))
|
||||
;; run the command, eval'ing if it was a list
|
||||
(if (listp cmd)
|
||||
(setq cmd (eval cmd)))
|
||||
(setq mmtype (get cmd 'mouse-me-type))
|
||||
(cond ((eq mmtype 'region)
|
||||
(funcall cmd beg end))
|
||||
((eq mmtype 'string)
|
||||
(funcall cmd name))
|
||||
(t
|
||||
(funcall cmd name)))))
|
||||
|
||||
(defcustom ess-S-mouse-me-menu-commands-alist
|
||||
'("S-Plus 4 and 6 GUI under Windows"
|
||||
("Edit.data" . ess-mouse-me-Edit.data)
|
||||
"----"
|
||||
("print" . ess-mouse-me-print)
|
||||
("summary" . ess-mouse-me-summary)
|
||||
("plot" . ess-mouse-me-plot)
|
||||
("show" . ess-mouse-me-show)
|
||||
("help" . ess-display-help-on-object)
|
||||
("args" . ess-mouse-me-args)
|
||||
"----"
|
||||
("Browser on" . ess-mouse-me-browser-on)
|
||||
("Browser off" . ess-mouse-me-browser-off))
|
||||
"*Command menu used by `mouse-me-build-menu'.
|
||||
A alist of elements where each element is either a cons cell or a string.
|
||||
If a cons cell the car is a string to be displayed in the menu and the
|
||||
cdr is either a function to call passing a string to, or a list which evals
|
||||
to a function to call passing a string to. If the element is a string
|
||||
it makes a non-selectable element in the menu. To make a separator line
|
||||
use a string consisting solely of hyphens.
|
||||
|
||||
The function returned from this menu will be called with one string
|
||||
argument. Or if the function has the symbol property `mouse-me-type'
|
||||
and if its value is the symbol `region' it will be called with the
|
||||
beginning and ending points of the selected string. If the value is
|
||||
the symbol `string' it will be called with one string argument."
|
||||
:type '(repeat sexp)
|
||||
:group 'mouseme)
|
||||
|
||||
|
||||
(defun ess-mouse-me-Edit.data (string)
|
||||
(ess-mouse-me-eval-expanded string "Edit.data(" ")" nil nil nil))
|
||||
|
||||
(defun ess-mouse-me-print (string)
|
||||
(ess-mouse-me-eval-expanded string "" "" nil (ess-ddeclient-p) t))
|
||||
(defun ess-mouse-me-summary (string)
|
||||
(ess-mouse-me-eval-expanded string "summary(" ")" nil (ess-ddeclient-p) t))
|
||||
(defun ess-mouse-me-plot (string)
|
||||
(ess-mouse-me-eval-expanded string "plot(" ")") nil nil nil)
|
||||
(defun ess-mouse-me-show (string)
|
||||
(ess-mouse-me-eval-expanded string "show(" ")") nil nil nil)
|
||||
(defun ess-mouse-me-args (string)
|
||||
(ess-mouse-me-eval-expanded string "args(" ")" nil (ess-ddeclient-p) t))
|
||||
|
||||
(defun ess-mouse-me-browser-on (string)
|
||||
(if (equal (substring ess-dialect 0 1) "R")
|
||||
(ess-eval-linewise (concat "debug(" string ")"))
|
||||
(ess-mouse-me-eval-expanded string "trace(" ", exit=browser)") nil nil nil))
|
||||
|
||||
(defun ess-mouse-me-browser-off (string)
|
||||
(if (equal (substring ess-dialect 0 1) "R")
|
||||
(ess-eval-linewise (concat "undebug(" string ")"))
|
||||
(ess-mouse-me-eval-expanded string "untrace(" ")") nil nil nil))
|
||||
|
||||
|
||||
|
||||
(defun ess-mouse-me-eval-expanded (string &optional head tail commands-buffer
|
||||
page value-returned)
|
||||
"Send the expanded STRING to the inferior-ess process using `ess-command'
|
||||
after first concating the HEAD and TAIL. Put answer in COMMANDS-BUFFER if
|
||||
specified and not using ddeclient, otherwise in \"tmp-buffer\". In either
|
||||
case the buffer containing the answer is renamed to the value of the
|
||||
constructed command. If PAGE is non-nil and using ddeclient, expand
|
||||
the string one more time by embedding it in a \"page()\" command."
|
||||
(interactive)
|
||||
(let* (scommand
|
||||
page-scommand
|
||||
(lproc-name ess-local-process-name)
|
||||
(ess-mouse-customize-alist ess-local-customize-alist))
|
||||
(if (not head) (setq head "summary("))
|
||||
(if (not tail) (setq tail ")"))
|
||||
(if (not commands-buffer) (setq commands-buffer
|
||||
(get-buffer-create "tmp-buffer")))
|
||||
(setq scommand (concat head string tail))
|
||||
|
||||
(if (ess-ddeclient-p)
|
||||
(progn
|
||||
(setq page-scommand (if page
|
||||
(concat "page(" scommand ")")
|
||||
scommand))
|
||||
(set-buffer-file-coding-system 'undecided-dos)
|
||||
(ess-command page-scommand commands-buffer)
|
||||
(if (not value-returned)
|
||||
nil
|
||||
(sleep-for 2)
|
||||
(switch-to-buffer (car (buffer-list)))))
|
||||
(ess-make-buffer-current)
|
||||
(switch-to-buffer commands-buffer)
|
||||
(ess-setq-vars-local (eval ess-mouse-customize-alist) (current-buffer))
|
||||
(setq ess-local-process-name lproc-name)
|
||||
(ess-command (concat scommand "\n") commands-buffer)
|
||||
(if (not value-returned) (switch-to-buffer (nth 1 (buffer-list)))))
|
||||
(if (not value-returned)
|
||||
nil
|
||||
(if ess-microsoft-p ;; there ought to be a filter
|
||||
(while (search-forward "\r" nil t) ;; function to keep the ^M
|
||||
(replace-match "" nil t))) ;; from showing up at all
|
||||
(ess-transcript-mode (eval ess-mouse-customize-alist))
|
||||
(setq ess-local-process-name lproc-name)
|
||||
(rename-buffer scommand))))
|
||||
|
||||
|
||||
; Provide package
|
||||
|
||||
(provide 'ess-mouse)
|
||||
|
||||
|
||||
|
||||
;;;;;;;; STARTUP STUFF ;;;;;;;;;;;;
|
||||
|
||||
(make-variable-buffer-local 'mouse-me-menu-commands)
|
||||
|
||||
(defun ess-S-mouse-me-menu-commands ()
|
||||
(if (equal ess-language "S")
|
||||
(setq mouse-me-menu-commands ess-S-mouse-me-menu-commands-alist)))
|
||||
|
||||
;; (if (not (featurep 'xemacs))
|
||||
;; (progn
|
||||
;; ;;gnu emacs
|
||||
;; (define-key ess-mode-map [S-mouse-3] 'ess-mouse-me)
|
||||
;; (define-key inferior-ess-mode-map [S-mouse-3] 'ess-mouse-me)
|
||||
;; (defun ess-S-mouse-me-ess-transcript-mode ()
|
||||
;; (define-key ess-transcript-mode-map [S-mouse-3] 'ess-mouse-me)))
|
||||
;; ;; xemacs
|
||||
;; (define-key ess-mode-map [(shift button3)] 'ess-mouse-me)
|
||||
;; (define-key inferior-ess-mode-map [(shift button3)] 'ess-mouse-me)
|
||||
;; (defun ess-S-mouse-me-ess-transcript-mode ()
|
||||
;; (define-key ess-transcript-mode-map [(shift button3)] 'ess-mouse-me)))
|
||||
;;
|
||||
(add-hook 'ess-mode-hook 'ess-S-mouse-me-menu-commands)
|
||||
(add-hook 'inferior-ess-mode-hook 'ess-S-mouse-me-menu-commands)
|
||||
(add-hook 'ess-transcript-mode-hook 'ess-S-mouse-me-menu-commands)
|
||||
;; (add-hook 'ess-transcript-mode-hook 'ess-S-mouse-me-ess-transcript-mode)
|
||||
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; outline-minor-mode: nil
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-mouse.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-mouse.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-mouse.elc
Normal file
Binary file not shown.
400
.emacs.d/elpa/ess-20160208.453/lisp/ess-noweb-font-lock-mode.el
Normal file
400
.emacs.d/elpa/ess-20160208.453/lisp/ess-noweb-font-lock-mode.el
Normal file
@@ -0,0 +1,400 @@
|
||||
;;; ess-noweb-font-lock-mode.el --- edit noweb files with GNU Emacs
|
||||
|
||||
;; Copyright (C) 1999 by Adnan Yaqub (AYaqub@orga.com)
|
||||
;; and Mark Lunt (mark.lunt@mrc-bsu.cam.ac.uk
|
||||
;; Copyright (C) 2002 by A.J. Rossini <rossini@u.washington.edu>
|
||||
;; Copyright (C) 2003--2004 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
;;
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Code-dependent highlighting
|
||||
;; *****
|
||||
;;
|
||||
;; Adding highlighting to ess-noweb-mode.el
|
||||
;;
|
||||
;; Here is a description of how one can add highlighting via the
|
||||
;; font-lock package to noweb buffers. It uses the hooks provided by
|
||||
;; ess-noweb-mode.el. The solution provides the following features:
|
||||
;; 1) The documentation chunks are highlighted in the ess-noweb-doc-mode
|
||||
;; (e.g., LaTeX).
|
||||
;; 2) The code chunks without mode comments (-*- mode -*-) are
|
||||
;; highlighted in the ess-noweb-code-mode.
|
||||
;; 3) The code chunks with mode comments (-*- mode -*-) on the first
|
||||
;; line of the first chunk with this name are highlighted in the mode
|
||||
;; in the comment.
|
||||
;;
|
||||
;; For example, given the file:
|
||||
;;
|
||||
;; % -*- mode: Noweb; ess-noweb-code-mode: c-mode -*-
|
||||
;;
|
||||
;; \begin{itemize}
|
||||
;; \item a main routine written in C,
|
||||
;; \item a log configuration file parser written in YACC, and
|
||||
;; \item a lexical analyzer written in Lex.
|
||||
;; \end{itemize}
|
||||
;;
|
||||
;; <<warning c comment>>=
|
||||
;; /* DO NOT EDIT ME! */
|
||||
;; /* This file was automatically generated from %W% (%G%). */
|
||||
;; @
|
||||
;;
|
||||
;; <<warning nroff comment>>=
|
||||
;; .\" -*- nroff -*-
|
||||
;; .\" DO NOT EDIT ME!
|
||||
;; .\" This file was automatically generated from %W% (%G%).
|
||||
;; @
|
||||
;;
|
||||
;; The LaTeX list is highlighted in latex-mode (the default noweb doc
|
||||
;; mode), the chunk <<warning c comment>> is highlighted in c-mode (the
|
||||
;; default noweb code mode), and the chunk <<warning nroff comment>> is
|
||||
;; highlighted in nroff-mode due to the "-*- nroff -*-" comment.
|
||||
;;
|
||||
;; Chunks are highlighted each time point moves into them from a
|
||||
;; different mode. They are also fontified 'on the fly', but this is
|
||||
;; less reliable, since the syntax can depend on the context. It's as
|
||||
;; good as you would get outside ess-noweb-mode, though.
|
||||
;;
|
||||
;; To use it, you must add
|
||||
;; (require 'ess-noweb-font-lock-mode) to your .emacs file.
|
||||
;; Then, if you use either global-font-lock or turn-on-font-lock
|
||||
;; statements, any ess-noweb-mode buffers will be fontified
|
||||
;; appropriately. (We have to redefine turn-on-font-lock, but it
|
||||
;; saves breaking other packages (in particular ESS, which I use a
|
||||
;; lot), that assume that turn-on-font-lock is the way to turn on
|
||||
;; font locking.
|
||||
|
||||
;; Alternatively, you can turn ess-noweb-font-lock-mode on and off by
|
||||
;; using M-x ess-noweb-font-lock-mode. However, turning
|
||||
;; ess-noweb-font-lock-mode off when global-font-lock-mode is t makes it
|
||||
;; impossible to use font-locking in that buffer subsequently, other
|
||||
;; than by turning ess-noweb-font-lock-mode back on.
|
||||
|
||||
;; 2) The highlighting sometimes get confused, but this is no longer
|
||||
;; a noweb problem. Highlighting should work as well within a chunk
|
||||
;; as it does without ess-noweb-mode.
|
||||
;; There are some problems with, for example latex-mode: a `$' in a
|
||||
;; verbatim environment with throw the font-locking out.
|
||||
;; One slight blemish is that code-quotes are highlighted as comments
|
||||
;; as they are being entered. They are only highlighted correctly
|
||||
;; after `ess-noweb-font-lock-fontify-chunk' has been run, either as a
|
||||
;; command or through changing to a different chunk and back again
|
||||
;; (unless they lie on a single line, in which case they are
|
||||
;; fontified correctly once they are completed).
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'ess-noweb-mode)
|
||||
(require 'font-lock)
|
||||
|
||||
(defvar ess-noweb-font-lock-mode nil
|
||||
"Buffer local variable, t iff this buffer is using ess-noweb-font-lock-mode.")
|
||||
|
||||
(defvar ess-noweb-use-font-lock-mode t
|
||||
"DO NOT CHANGE THIS VARIABLE
|
||||
If you use nw-turn-on-font-lock to turn on font-locking, then turn it
|
||||
off again, it would come back on again of its own accord when you
|
||||
changed major-mode. This variable is used internally to stop it.")
|
||||
|
||||
(defvar ess-noweb-font-lock-mode-hook nil
|
||||
"Hook that is run after entering ess-noweb-font-lock mode.")
|
||||
|
||||
(defvar ess-noweb-font-lock-max-initial-chunks 30
|
||||
"Maximum number of chunks to fontify initially.
|
||||
If nil, will fontify the entire buffer when
|
||||
ess-noweb-font-lock-initial-fontify-buffer is called" )
|
||||
|
||||
;; (defvar old-beginning-of-syntax nil
|
||||
;; "Stores the function used to find the beginning of syntax in the
|
||||
;; current major mode. ess-noweb-font-lock-mode needs a different one." )
|
||||
|
||||
;; ;; (AJR) the next two lines were originally font-lock-warning-face
|
||||
;; ;; methods; XEmacs 20.4 doesn't define this, sigh... -- KLUDGE --.
|
||||
|
||||
(defvar ess-noweb-font-lock-doc-start-face font-lock-reference-face
|
||||
"Face to use to highlight the `@' at the start of each doc chunk")
|
||||
|
||||
(defvar ess-noweb-font-lock-brackets-face font-lock-reference-face
|
||||
"Face to use to highlight `<<', `>>' `[[' and `]]' ")
|
||||
|
||||
(defvar ess-noweb-font-lock-chunk-name-face font-lock-keyword-face
|
||||
"Face to use to highlight the between `<<' and `>>'")
|
||||
|
||||
(defvar ess-noweb-font-lock-code-quote-face font-lock-keyword-face
|
||||
"Face to use to highlight the between `[[' and `]]'")
|
||||
|
||||
;; Now we add [[ess-noweb-font-lock-mode]] to the list of existing minor
|
||||
;; modes. The string ``NWFL'' will be added to the mode-line: ugly, but
|
||||
;; brief.
|
||||
|
||||
(if (not (assq 'ess-noweb-font-lock-mode minor-mode-alist))
|
||||
(setq minor-mode-alist (append minor-mode-alist
|
||||
(list '(ess-noweb-font-lock-mode " NWFL")))))
|
||||
|
||||
;; An ugly kludge to get around problems with global-font-lock, which
|
||||
;; fontifies the entire buffer in the new major mode every time you
|
||||
;; change mode, which is time-consuming and makes a pigs trotters of
|
||||
;; it. Trying to stop it looks tricky, but using this function as your
|
||||
;; `font-lock-fontify-buffer' function stops it wasting your time
|
||||
|
||||
(defun nwfl-donowt()
|
||||
"This function does nothing at all")
|
||||
|
||||
;; The following function is just a wrapper for ess-noweb-font-lock-mode,
|
||||
;; enabling it to be called as ess-noweb-font-lock-minor-mode instead.
|
||||
|
||||
(defun ess-noweb-font-lock-minor-mode ( &optional arg)
|
||||
"Minor meta mode for managing syntax highlighting in noweb files.
|
||||
See ess-noweb-font-lock-mode."
|
||||
(interactive)
|
||||
(ess-noweb-font-lock-mode arg))
|
||||
|
||||
;; Here we get to the meat of the problem
|
||||
|
||||
(defun ess-noweb-font-lock-mode ( &optional arg)
|
||||
"Minor mode for syntax highlighting when using ess-noweb-mode to edit noweb files.
|
||||
Each chunk is fontified in accordance with its own mode"
|
||||
(interactive "P")
|
||||
(if (or ess-noweb-mode ess-noweb-font-lock-mode)
|
||||
(progn
|
||||
;; This bit is tricky: copied almost verbatim from bib-cite-mode.el
|
||||
;; It seems to ensure that the variable ess-noweb-font-lock-mode is made
|
||||
;; local to this buffer. It then sets ess-noweb-font-lock-mode to `t' if
|
||||
;; 1) It was called with a prefix argument greater than 0
|
||||
;; or 2) It was called with no argument, and ess-noweb-font-lock-mode is
|
||||
;; currently nil
|
||||
;; ess-noweb-font-lock-mode is nil if the prefix argument was <= 0 or there
|
||||
;; was no prefix argument and ess-noweb-font-lock-mode is currently `t'
|
||||
(set (make-local-variable 'ess-noweb-font-lock-mode)
|
||||
(if arg
|
||||
(> (prefix-numeric-value arg) 0)
|
||||
(not ess-noweb-font-lock-mode)))
|
||||
;; Now, if ess-noweb-font-lock-mode is true, we want to turn
|
||||
;; ess-noweb-font-lock-mode on
|
||||
(cond
|
||||
(ess-noweb-font-lock-mode ;Setup the minor-mode
|
||||
(when (and (boundp 'global-font-lock-mode) global-font-lock-mode)
|
||||
(mapc 'ess-noweb-make-variable-permanent-local
|
||||
'(font-lock-fontify-buffer-function
|
||||
font-lock-unfontify-buffer-function))
|
||||
(setq font-lock-fontify-buffer-function 'nwfl-donowt)
|
||||
(setq font-lock-unfontify-buffer-function 'nwfl-donowt))
|
||||
(mapcar 'ess-noweb-make-variable-permanent-local
|
||||
'(ess-noweb-font-lock-mode
|
||||
font-lock-dont-widen
|
||||
;; font-lock-beginning-of-syntax-function
|
||||
syntax-begin-function
|
||||
ess-noweb-use-font-lock-mode
|
||||
after-change-functions))
|
||||
(setq ess-noweb-font-lock-mode t
|
||||
font-lock-dont-widen t)
|
||||
(when (< emacs-major-version 21) ; needed for emacs < 21.1 only :
|
||||
(make-local-hook 'after-change-functions))
|
||||
(add-hook 'after-change-functions
|
||||
'font-lock-after-change-function nil t)
|
||||
(add-hook 'ess-noweb-font-lock-mode-hook 'ess-noweb-font-lock-mode-fn)
|
||||
(add-hook 'ess-noweb-changed-chunk-hook
|
||||
'ess-noweb-font-lock-fontify-this-chunk)
|
||||
(run-hooks 'ess-noweb-font-lock-mode-hook)
|
||||
(message "ess-noweb-font-lock mode: use `M-x ess-noweb-font-lock-describe-mode' for more info"))
|
||||
;; If we didn't do the above, then we want to turn ess-noweb-font-lock-mode
|
||||
;; off, no matter what (hence the condition `t')
|
||||
(t
|
||||
(when (and (boundp 'global-font-lock-mode) global-font-lock-mode)
|
||||
;; (setq font-lock-fontify-buffer-function
|
||||
;; 'font-lock-default-fontify-buffer)
|
||||
;; Get back our unfontify buffer function
|
||||
(setq font-lock-unfontify-buffer-function
|
||||
'font-lock-default-unfontify-buffer))
|
||||
(remove-hook 'ess-noweb-font-lock-mode-hook 'ess-noweb-font-lock-mode-fn)
|
||||
(remove-hook 'ess-noweb-changed-chunk-hook
|
||||
'ess-noweb-font-lock-fontify-this-chunk)
|
||||
(remove-hook 'after-change-functions
|
||||
'font-lock-after-change-function )
|
||||
(font-lock-default-unfontify-buffer)
|
||||
(setq ess-noweb-use-font-lock-mode nil)
|
||||
(message "ess-noweb-font-lock-mode removed"))))
|
||||
(message "ess-noweb-font-lock-mode can only be used with ess-noweb-mode")))
|
||||
|
||||
(defun ess-noweb-start-of-syntax ()
|
||||
"Go to the place to start fontifying from"
|
||||
(interactive)
|
||||
(goto-char (car (ess-noweb-chunk-region))))
|
||||
|
||||
(defun ess-noweb-font-lock-fontify-chunk-by-number ( chunk-num )
|
||||
"Fontify chunk chunk-num based on the current major mode."
|
||||
(save-excursion
|
||||
(font-lock-set-defaults)
|
||||
;; (setq old-beginning-of-syntax font-lock-beginning-of-syntax-function)
|
||||
(setq syntax-begin-function 'ess-noweb-start-of-syntax)
|
||||
(setq font-lock-keywords
|
||||
;; (append font-lock-keywords
|
||||
;; '(("\\(\\[\\[\\)\\([^]]*\\]*\\)\\(\\]\\]\\|\\$\\)"
|
||||
;; (1 ess-noweb-font-lock-brackets-face prepend )
|
||||
;; (2 ess-noweb-font-lock-code-quote-face prepend)
|
||||
;; (3 ess-noweb-font-lock-brackets-face prepend))
|
||||
;; ("^[ \t\n]*\\(<<\\)\\([^>]*\\)\\(>>=?\\)"
|
||||
;; (1 ess-noweb-font-lock-brackets-face prepend )
|
||||
;; (2 ess-noweb-font-lock-chunk-name-face prepend)
|
||||
;; (3 ess-noweb-font-lock-brackets-face prepend))
|
||||
;; ("^@[ \t\n]+"
|
||||
;; (0 ess-noweb-font-lock-doc-start-face prepend )))))
|
||||
(append font-lock-keywords
|
||||
'(("^[ \t\n]*\\(<<\\)\\([^>]*\\)\\(>>=?\\)"
|
||||
(1 font-lock-reference-face prepend )
|
||||
(2 font-lock-keyword-face prepend)
|
||||
(3 font-lock-reference-face prepend))
|
||||
("^@[ \t\n]+"
|
||||
(0 font-lock-reference-face prepend )))))
|
||||
|
||||
|
||||
(let ((r (cons (marker-position (cdr (aref ess-noweb-chunk-vector
|
||||
chunk-num)))
|
||||
(marker-position (cdr (aref ess-noweb-chunk-vector
|
||||
(1+ chunk-num))))))
|
||||
(font-latex-extend-region-functions nil);; don't extend anything
|
||||
(font-lock-extend-region-functions nil)) ;; this infloops :(
|
||||
(save-restriction
|
||||
(narrow-to-region (car r) (cdr r))
|
||||
;; (sit-for 3)
|
||||
(font-lock-fontify-region (car r) (cdr r)))
|
||||
t)))
|
||||
|
||||
|
||||
(defun ess-noweb-font-lock-fontify-this-chunk ()
|
||||
"Fontify this chunk according to its own major mode.
|
||||
Since we are in the chunk, the major mode will already have been set
|
||||
by ess-noweb-mode.el"
|
||||
(interactive)
|
||||
(ess-noweb-font-lock-fontify-chunk-by-number (ess-noweb-find-chunk-index-buffer)))
|
||||
|
||||
(defun ess-noweb-font-lock-initial-fontify-buffer ()
|
||||
"Applies syntax highlighting to some or all chunks in a noweb buffer.
|
||||
The number of chunks is set by ess-noweb-font-lock-max-initial-chunks: if
|
||||
this is nil, the entire buffer is fontified.
|
||||
It is intended to be called when first entering ess-noweb-font-lock-mode.
|
||||
For other purposes, use ess-noweb-font-lock-fontify-chunks."
|
||||
(interactive)
|
||||
;; This will be tricky. It will be very slow to go throught the chunks
|
||||
;; in order, switching major modes all the time.
|
||||
;; So, we will do the documentation in one pass, the code in a second
|
||||
;; pass. This could still be a little slow if we have to swap between
|
||||
;; different code modes regularly, but it should be bearable. It should
|
||||
;; only happen when the file is first read in, anyway
|
||||
(save-excursion
|
||||
(let (start-chunk end-chunk this-chunk chunk-counter)
|
||||
(setq this-chunk (ess-noweb-find-chunk-index-buffer))
|
||||
(if ess-noweb-font-lock-max-initial-chunks
|
||||
(progn
|
||||
(setq start-chunk
|
||||
(max 0
|
||||
(- this-chunk
|
||||
(/ ess-noweb-font-lock-max-initial-chunks 2))))
|
||||
;; Don't you just love hairy lisp syntax ? The above means set the
|
||||
;; starting chunk to the current chunk minus half of
|
||||
;; ess-noweb-font-lock-max-initial-chunks, unless that is negative in
|
||||
;; which case set it to 0
|
||||
(setq end-chunk (+ start-chunk ess-noweb-font-lock-max-initial-chunks))
|
||||
(if (> end-chunk (- (length ess-noweb-chunk-vector) 2))
|
||||
(setq end-chunk (- (length ess-noweb-chunk-vector) 2))))
|
||||
;; If ess-noweb-font-lock-max-initial-chunks is nil, do the whole buffer
|
||||
(progn
|
||||
(setq start-chunk 0)
|
||||
(setq end-chunk (- (length ess-noweb-chunk-vector) 2))))
|
||||
(ess-noweb-font-lock-fontify-chunks start-chunk end-chunk))))
|
||||
|
||||
(defun ess-noweb-font-lock-fontify-buffer ()
|
||||
"This function will fontify each chunk in the buffer appropriately."
|
||||
(interactive)
|
||||
(let ((start-chunk 0)
|
||||
(end-chunk (- (length ess-noweb-chunk-vector) 2)))
|
||||
(ess-noweb-font-lock-fontify-chunks start-chunk end-chunk)))
|
||||
|
||||
(defun ess-noweb-font-lock-fontify-chunks (start-chunk end-chunk)
|
||||
"Fontify a noweb file from start-chunk to end-chunk"
|
||||
(interactive)
|
||||
(let (chunk-counter)
|
||||
(save-excursion
|
||||
(message "Fontifying from %d to %d" start-chunk end-chunk)
|
||||
;; Want to set DOC mode for the first Doc chunk, not for the others
|
||||
(setq chunk-counter start-chunk)
|
||||
(while (stringp (car (aref ess-noweb-chunk-vector chunk-counter)))
|
||||
(setq chunk-counter (+ chunk-counter 1)))
|
||||
(goto-char (cdr (aref ess-noweb-chunk-vector chunk-counter)))
|
||||
(ess-noweb-select-mode)
|
||||
;; Now go through the chunks, fontifying the documentation ones.
|
||||
(while (<= chunk-counter end-chunk)
|
||||
(if (not (stringp (car (aref ess-noweb-chunk-vector chunk-counter))))
|
||||
(ess-noweb-font-lock-fontify-chunk-by-number chunk-counter))
|
||||
(message "Fontifying documentation chunks: chunk %d" chunk-counter)
|
||||
(setq chunk-counter (+ 1 chunk-counter)))
|
||||
;; Go back to the start and go through the chunks, fontifying the code ones.
|
||||
(setq chunk-counter start-chunk)
|
||||
(message "About to do code chunks")
|
||||
(while (<= chunk-counter end-chunk)
|
||||
(when (stringp (car (aref ess-noweb-chunk-vector chunk-counter)))
|
||||
;; It's a code chunk: goto it to set the correct code mode, then
|
||||
;; fontify it.
|
||||
(message "Fontifying code chunks: chunk %d" chunk-counter)
|
||||
(goto-char (cdr (aref ess-noweb-chunk-vector chunk-counter)))
|
||||
(ess-noweb-select-mode)
|
||||
(ess-noweb-font-lock-fontify-this-chunk))
|
||||
(setq chunk-counter (1+ chunk-counter))))
|
||||
(ess-noweb-select-mode)))
|
||||
|
||||
(defun ess-noweb-font-lock-mode-fn()
|
||||
"Function that is intended to be attached to ess-noweb-font-lock-mode-hook."
|
||||
(ess-noweb-font-lock-initial-fontify-buffer))
|
||||
|
||||
;; This is a wee bit of a hack. If people attach `turn-on-font-lock'
|
||||
;; to their major mode hook, it will play hell with
|
||||
;; ess-noweb-font-lock-mode. I had hoped that providing a replacement
|
||||
;; `nw-turn-on-font-lock' would solve the problem, but it didn't
|
||||
;; (sometimes turn-on-font-lock appears in places other than
|
||||
;; `.emacs', such as in ESS). So rather than have it fall over if
|
||||
;; turn-on-lock was around, I redefined turn-on-font-lock to do the
|
||||
;; right thing.
|
||||
|
||||
(defvar ess-noweb-old-turn-on-font-lock nil)
|
||||
|
||||
(defun nw-turn-on-font-lock ()
|
||||
"Turn on font-lock mode, with due regard to whether we are in ess-noweb-mode"
|
||||
(if (not ess-noweb-mode)
|
||||
(ess-noweb-old-turn-on-font-lock)
|
||||
(if (and (not ess-noweb-font-lock-mode) ess-noweb-use-font-lock-mode)
|
||||
(ess-noweb-font-lock-mode ))))
|
||||
|
||||
(unless (functionp 'ess-noweb-old-turn-on-font-lock)
|
||||
(fset 'ess-noweb-old-turn-on-font-lock (symbol-function 'turn-on-font-lock))
|
||||
(fset 'turn-on-font-lock (symbol-function 'nw-turn-on-font-lock)))
|
||||
|
||||
(provide 'ess-noweb-font-lock-mode)
|
||||
;; *****
|
||||
;;
|
||||
;; Adnan Yaqub (AYaqub@orga.com)
|
||||
;; ORGA Kartensysteme GmbH // An der Kapelle 2 // D-33104 Paderborn // Germany
|
||||
;; Tel. +49 5254 991-823 //Fax. +49 5254 991-749
|
||||
|
||||
|
||||
|
||||
;; Local Variables:
|
||||
;; mode:emacs-lisp
|
||||
;; End:
|
||||
|
||||
;;; ess-noweb-font-lock-mode.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-noweb-font-lock-mode.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-noweb-font-lock-mode.elc
Normal file
Binary file not shown.
1941
.emacs.d/elpa/ess-20160208.453/lisp/ess-noweb-mode.el
Normal file
1941
.emacs.d/elpa/ess-20160208.453/lisp/ess-noweb-mode.el
Normal file
File diff suppressed because it is too large
Load Diff
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-noweb-mode.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-noweb-mode.elc
Normal file
Binary file not shown.
150
.emacs.d/elpa/ess-20160208.453/lisp/ess-noweb.el
Normal file
150
.emacs.d/elpa/ess-20160208.453/lisp/ess-noweb.el
Normal file
@@ -0,0 +1,150 @@
|
||||
;;; ess-noweb.el --- support for Literate Data Analysis
|
||||
|
||||
;; Copyright (C) 1999 Mark Lunt
|
||||
;; Copyright (C) 1999--2004 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: Mark Lunt <mark.lunt@mrc-bsu.cam.ac.uk>
|
||||
;; A.J. Rossini <rossini@u.washington.edu>
|
||||
;; Created: April 18, 1999
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; Keywords: statistics, languages
|
||||
;; Summary: Noweb support for ESS
|
||||
|
||||
;; This file is part of ESS
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Code for ESS and Literate Data Analysis.
|
||||
|
||||
;;; Code:
|
||||
|
||||
; Requires and autoloads
|
||||
|
||||
(require 'ess-noweb-mode)
|
||||
;; still needed when user turns font-lock-mode *on* (from initial off):
|
||||
(autoload 'ess-noweb-font-lock-mode "ess-noweb-font-lock-mode")
|
||||
|
||||
; Variables
|
||||
|
||||
(defvar ess-noweb-use-font-lock font-lock-mode
|
||||
"Set to t if you want to use font-locking in ESS noweb buffers.")
|
||||
|
||||
;; this helps with XEmacs barfing, sigh...
|
||||
;; but is *NOT* okay to do *globally*: (setq global-font-lock-mode t)
|
||||
|
||||
(if ess-noweb-use-font-lock
|
||||
(require 'ess-noweb-font-lock-mode))
|
||||
|
||||
; Functions
|
||||
|
||||
;;*;; Code Chunk evaluation.
|
||||
|
||||
(defun ess-eval-chunk (vis)
|
||||
"Tangle the current chunk and send it to the inferior ESS process.
|
||||
Arg has same meaning as for `ess-eval-region'."
|
||||
(interactive "P")
|
||||
(let ((process-name ess-local-process-name)
|
||||
new-process-name
|
||||
(cbuf (current-buffer))
|
||||
(temp-buffer (ess-create-temp-buffer "Tangle Buffer")))
|
||||
(save-excursion
|
||||
(ess-noweb-tangle-chunk temp-buffer)
|
||||
(set-buffer temp-buffer)
|
||||
;; When the temp buffer is created, it does not inherit any value
|
||||
;; of ess-local-process-name from the .Rnw buffer, so we have to set it
|
||||
;; here. If ess-local-process-name is not set in the .Rnw buffer,
|
||||
;; it will inherit the value that is chosen here.
|
||||
(set (make-local-variable 'ess-local-process-name) process-name)
|
||||
(ess-eval-region (point-min) (point-max) vis "Eval Chunk")
|
||||
(if process-name
|
||||
(kill-buffer temp-buffer)
|
||||
;; if process-name was nil, source buffer did not have a local process
|
||||
;; so keep value from temp buffer before killing it.
|
||||
(setq new-process-name ess-local-process-name)
|
||||
(kill-buffer temp-buffer)
|
||||
(set-buffer cbuf)
|
||||
(set (make-local-variable 'ess-local-process-name) new-process-name)))))
|
||||
|
||||
|
||||
(defun ess-eval-chunk-and-step (&optional vis)
|
||||
"Tangle the current chunk and send it to the inferior ESS process and
|
||||
step to the next chunk"
|
||||
(interactive)
|
||||
(ess-eval-chunk vis)
|
||||
(ess-noweb-next-code-chunk 1))
|
||||
|
||||
(defun ess-eval-chunk-and-go (vis)
|
||||
"Tangle the current chunk, send to the ESS process, and go there.
|
||||
Arg has same meaning as for `ess-eval-region'."
|
||||
(interactive "P")
|
||||
(ess-eval-chunk vis)
|
||||
(ess-switch-to-ESS t))
|
||||
|
||||
;;*;; Thread code chunk evaluation
|
||||
|
||||
;;;
|
||||
;;; Threads are code chunks which fit into the same "buffer" (I'm (AJR)
|
||||
;;; abusing terminology, but what I mean is things like:
|
||||
;;; <<thing1>>=
|
||||
;;; code for thing1
|
||||
;;; @
|
||||
;;; Documentation
|
||||
;;; <<thing1>>=
|
||||
;;; continuing code for thing1
|
||||
;;; @
|
||||
;;;
|
||||
|
||||
(defun ess-eval-thread (vis)
|
||||
"Tangle all chunks in the current chunk-thread and send to the ESS process.
|
||||
Arg has same meaning as for `ess-eval-region'."
|
||||
(interactive "P")
|
||||
(let ((temp-buffer (ess-create-temp-buffer "Tangle Buffer")))
|
||||
(ess-noweb-tangle-current-thread temp-buffer)
|
||||
(set-buffer temp-buffer)
|
||||
(ess-eval-region (point-min) (point-max) vis "Eval buffer")
|
||||
(kill-buffer temp-buffer)))
|
||||
|
||||
(defun ess-eval-thread-and-go (vis)
|
||||
"Tangle all chunks in the current chunk-thread, send to ESS process,
|
||||
and go there. Arg has same meaning as for `ess-eval-region'."
|
||||
(interactive "P")
|
||||
(ess-eval-thread vis)
|
||||
(ess-switch-to-ESS t))
|
||||
|
||||
; Provide package
|
||||
|
||||
(provide 'ess-noweb)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; outline-minor-mode: nil
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-noweb.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-noweb.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-noweb.elc
Normal file
Binary file not shown.
126
.emacs.d/elpa/ess-20160208.453/lisp/ess-omg-d.el
Normal file
126
.emacs.d/elpa/ess-20160208.453/lisp/ess-omg-d.el
Normal file
@@ -0,0 +1,126 @@
|
||||
;;; ess-omg-d.el --- Omega customization
|
||||
|
||||
;; Copyright (C) 1999 A. J. Rossini
|
||||
;; Copyright (C) 2000--2004 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: A.J. Rossini <rossini@biostat.washington.edu>
|
||||
;; Created: 15 August 1999
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; Keywords: languages
|
||||
|
||||
;; This file is part of ESS.
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This file defines all the S-PLUS 3.x customizations for ess-mode.
|
||||
|
||||
;;; Code:
|
||||
|
||||
;;; Requires and Autoloads:
|
||||
|
||||
(require 'ess-omg-l)
|
||||
|
||||
(autoload 'inferior-ess "ess-inf" "Run an ESS process.")
|
||||
(autoload 'ess-mode "ess-mode" "Edit an ESS process.")
|
||||
|
||||
(defvar OMG-dialect-name "OMG"
|
||||
"Name of 'dialect' for Omega.") ;easily changeable in a user's .emacs
|
||||
|
||||
(defvar OMG-customize-alist
|
||||
'((ess-local-customize-alist . 'OMG-customize-alist)
|
||||
(ess-language . "OMG")
|
||||
(ess-dialect . "omegahat")
|
||||
(ess-suffix . "omg")
|
||||
(ess-loop-timeout . 5000)
|
||||
(ess-dump-filename-template . (ess-replace-regexp-in-string
|
||||
"S$" ess-suffix ; in the one from custom:
|
||||
ess-dump-filename-template-proto))
|
||||
(ess-mode-editing-alist . OMG-editing-alist)
|
||||
(ess-mode-syntax-table . OMG-syntax-table)
|
||||
(ess-change-sp-regexp . "");fixme (if omegahat ever ..)
|
||||
(ess-help-sec-regex . ess-help-S+-sec-regex)
|
||||
(ess-help-sec-keys-alist . ess-help-S+sec-keys-alist)
|
||||
(ess-object-name-db-file . "ess-omg-namedb.el" )
|
||||
(inferior-ess-program . inferior-OMG-program-name)
|
||||
(inferior-ess-objects-command . "objects(%d)\n")
|
||||
(inferior-ess-help-command . "help(\"%s\",pager=\"cat\",window=F)\n")
|
||||
(inferior-ess-exit-command . "q()\n")
|
||||
(inferior-ess-primary-prompt . "\\[[0-9]*\\]")
|
||||
(inferior-ess-secondary-prompt . ".. ?")
|
||||
(comint-use-prompt-regexp . t)
|
||||
(inferior-ess-start-file . nil) ;"~/.ess-omg")
|
||||
(inferior-ess-start-args . ""))
|
||||
"Variables to customize for OMG (Omegahat)")
|
||||
|
||||
|
||||
(defun OMG (&optional start-args) ; proc-name)
|
||||
"Call Omegahat, from the Omega Group for Statistical Computing."
|
||||
(interactive "P")
|
||||
(setq ess-customize-alist OMG-customize-alist)
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "\n(OMG): ess-dialect=%s, buf=%s\n"
|
||||
ess-dialect
|
||||
(current-buffer)))
|
||||
(let ((omg-start-args
|
||||
(concat inferior-ess-start-args
|
||||
(if start-args (read-string
|
||||
"Starting Args [possibly -CORBA] ? ")
|
||||
nil))))
|
||||
(inferior-ess omg-start-args)))
|
||||
|
||||
|
||||
|
||||
(fset 'omegahat 'OMG)
|
||||
|
||||
(defun OMG-mode (&optional proc-name)
|
||||
"Major mode for editing Omegahat source. NOT EVEN STARTED."
|
||||
(interactive)
|
||||
(setq ess-customize-alist OMG-customize-alist)
|
||||
(ess-mode OMG-customize-alist proc-name)
|
||||
;;(java-mode)
|
||||
(setq major-mode 'OMG-mode))
|
||||
|
||||
(fset 'omegahat-mode 'OMG-mode)
|
||||
|
||||
(defun OMG-transcript-mode ()
|
||||
"Omegahat transcript mode."
|
||||
(interactive)
|
||||
(ess-transcript-mode OMG-customize-alist))
|
||||
|
||||
; Provide package
|
||||
|
||||
(provide 'ess-omg-d)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; outline-minor-mode: nil
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-omg-d.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-omg-d.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-omg-d.elc
Normal file
Binary file not shown.
345
.emacs.d/elpa/ess-20160208.453/lisp/ess-omg-l.el
Normal file
345
.emacs.d/elpa/ess-20160208.453/lisp/ess-omg-l.el
Normal file
@@ -0,0 +1,345 @@
|
||||
;;; ess-omg-l.el --- Support for editing Omega source code
|
||||
|
||||
;; Copyright (C) 1999--2001 A.J. Rossini.
|
||||
;; Copyright (C) 2002--2004 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: A.J. Rossini <rossini@u.washington.edu>
|
||||
;; Created: 15 Aug 1999
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; This file is part of ESS (Emacs Speaks Statistics).
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Code for general editing Omega source code. This is initially
|
||||
;; based upon the similarities between Omega and S, but will need to
|
||||
;; diverge to incorporate the use of Java-style coding.
|
||||
|
||||
;;; Code:
|
||||
|
||||
; Requires and autoloads
|
||||
|
||||
|
||||
; Specialized functions
|
||||
|
||||
(defun OMG-comment-indent ()
|
||||
"Indentation for Omega comments."
|
||||
|
||||
(if (looking-at "////")
|
||||
(current-column)
|
||||
(if (looking-at "///")
|
||||
(let ((tem (ess-calculate-indent)))
|
||||
(if (listp tem) (car tem) tem))
|
||||
(skip-chars-backward " \t")
|
||||
(max (if (bolp) 0 (1+ (current-column)))
|
||||
comment-column))))
|
||||
|
||||
;; (defun OMG-indent-line ()
|
||||
;; "Indent current line as Omega code.
|
||||
;; Return the amount the indentation changed by."
|
||||
;; (let ((indent (ess-calculate-indent nil))
|
||||
;; beg shift-amt
|
||||
;; (case-fold-search nil)
|
||||
;; (pos (- (point-max) (point))))
|
||||
;; (beginning-of-line)
|
||||
;; (setq beg (point))
|
||||
;; (cond ((eq indent nil)
|
||||
;; (setq indent (current-indentation)))
|
||||
;; (t
|
||||
;; (skip-chars-forward " \t")
|
||||
;; (if (and ess-indent-with-fancy-comments (looking-at "////"))
|
||||
;; (setq indent 0))
|
||||
;; (if (and ess-indent-with-fancy-comments
|
||||
;; (looking-at "//")
|
||||
;; (not (looking-at "///")))
|
||||
;; (setq indent comment-column)
|
||||
;; (if (eq indent t) (setq indent 0))
|
||||
;; (if (listp indent) (setq indent (car indent)))
|
||||
;; (cond ((and (looking-at "else\\b")
|
||||
;; (not (looking-at "else\\s_")))
|
||||
;; (setq indent (save-excursion
|
||||
;; (ess-backward-to-start-of-if)
|
||||
;; (+ ess-else-offset
|
||||
;; (current-indentation)))))
|
||||
;; ((= (following-char) ?})
|
||||
;; (setq indent
|
||||
;; (+ indent
|
||||
;; (- ess-close-brace-offset ess-indent-offset))))
|
||||
;; ((= (following-char) ?{)
|
||||
;; (setq indent (+ indent ess-brace-offset)))))))
|
||||
;; (skip-chars-forward " \t")
|
||||
;; (setq shift-amt (- indent (current-column)))
|
||||
;; (if (zerop shift-amt)
|
||||
;; (if (> (- (point-max) pos) (point))
|
||||
;; (goto-char (- (point-max) pos)))
|
||||
;; (delete-region beg (point))
|
||||
;; (indent-to indent)
|
||||
;; ;; If initial point was within line's indentation,
|
||||
;; ;; position after the indentation.
|
||||
;; ;; Else stay at same point in text.
|
||||
;; (if (> (- (point-max) pos) (point))
|
||||
;; (goto-char (- (point-max) pos))))
|
||||
;; shift-amt))
|
||||
|
||||
|
||||
;; (defun OMG-calculate-indent (&optional parse-start)
|
||||
;; "Return appropriate indentation for current line as Omega code.
|
||||
;; In usual case returns an integer: the column to indent to.
|
||||
;; Returns nil if line starts inside a string, t if in a comment."
|
||||
;; (save-excursion
|
||||
;; (beginning-of-line)
|
||||
;; (let ((indent-point (point))
|
||||
;; (case-fold-search nil)
|
||||
;; state
|
||||
;; containing-sexp)
|
||||
;; (if parse-start
|
||||
;; (goto-char parse-start)
|
||||
;; (beginning-of-defun))
|
||||
;; (while (< (point) indent-point)
|
||||
;; (setq parse-start (point))
|
||||
;; (setq state (parse-partial-sexp (point) indent-point 0))
|
||||
;; (setq containing-sexp (car (cdr state))))
|
||||
;; (cond ((or (nth 3 state) (nth 4 state))
|
||||
;; ;; return nil or t if should not change this line
|
||||
;; (nth 4 state))
|
||||
;; ((null containing-sexp)
|
||||
;; ;; Line is at top level. May be data or function definition,
|
||||
;; (beginning-of-line)
|
||||
;; (if (and (/= (following-char) ?\{)
|
||||
;; (save-excursion
|
||||
;; (ess-backward-to-noncomment (point-min))
|
||||
;; (ess-continued-statement-p)))
|
||||
;; ess-continued-statement-offset
|
||||
;; 0)) ; Unless it starts a function body
|
||||
;; ((/= (char-after containing-sexp) ?{)
|
||||
;; ;; line is expression, not statement:
|
||||
;; ;; indent to just after the surrounding open.
|
||||
;; (goto-char containing-sexp)
|
||||
;; (let ((bol (save-excursion (beginning-of-line) (point))))
|
||||
|
||||
;; ;; modified by shiba@isac 7.3.1992
|
||||
;; (cond ((and (numberp ess-expression-offset)
|
||||
;; (re-search-backward "[ \t]*expression[ \t]*" bol t))
|
||||
;; ;; This regexp match every "expression".
|
||||
;; ;; modified by shiba
|
||||
;; ;;(forward-sexp -1)
|
||||
;; (beginning-of-line)
|
||||
;; (skip-chars-forward " \t")
|
||||
;; ;; End
|
||||
;; (+ (current-column) ess-expression-offset))
|
||||
;; ((and (numberp ess-arg-function-offset)
|
||||
;; (re-search-backward
|
||||
;; "=[ \t]*\\s\"*\\(\\w\\|\\s_\\)+\\s\"*[ \t]*"
|
||||
;; bol
|
||||
;; t))
|
||||
;; (forward-sexp -1)
|
||||
;; (+ (current-column) ess-arg-function-offset))
|
||||
;; ;; "expression" is searched before "=".
|
||||
;; ;; End
|
||||
|
||||
;; (t
|
||||
;; (progn (goto-char (1+ containing-sexp))
|
||||
;; (current-column))))))
|
||||
;; (t
|
||||
;; ;; Statement level. Is it a continuation or a new statement?
|
||||
;; ;; Find previous non-comment character.
|
||||
;; (goto-char indent-point)
|
||||
;; (ess-backward-to-noncomment containing-sexp)
|
||||
;; ;; Back up over label lines, since they don't
|
||||
;; ;; affect whether our line is a continuation.
|
||||
;; (while (eq (preceding-char) ?\,)
|
||||
;; (ess-backward-to-start-of-continued-exp containing-sexp)
|
||||
;; (beginning-of-line)
|
||||
;; (ess-backward-to-noncomment containing-sexp))
|
||||
;; ;; Now we get the answer.
|
||||
;; (if (ess-continued-statement-p)
|
||||
;; ;; This line is continuation of preceding line's statement;
|
||||
;; ;; indent ess-continued-statement-offset more than the
|
||||
;; ;; previous line of the statement.
|
||||
;; (progn
|
||||
;; (ess-backward-to-start-of-continued-exp containing-sexp)
|
||||
;; (+ ess-continued-statement-offset (current-column)
|
||||
;; (if (save-excursion (goto-char indent-point)
|
||||
;; (skip-chars-forward " \t")
|
||||
;; (eq (following-char) ?{))
|
||||
;; ess-continued-brace-offset 0)))
|
||||
;; ;; This line starts a new statement.
|
||||
;; ;; Position following last unclosed open.
|
||||
;; (goto-char containing-sexp)
|
||||
;; ;; Is line first statement after an open-brace?
|
||||
;; (or
|
||||
;; ;; If no, find that first statement and indent like it.
|
||||
;; (save-excursion
|
||||
;; (forward-char 1)
|
||||
;; (while (progn (skip-chars-forward " \t\n")
|
||||
;; (looking-at "//"))
|
||||
;; ;; Skip over comments following openbrace.
|
||||
;; (forward-line 1))
|
||||
;; ;; The first following code counts
|
||||
;; ;; if it is before the line we want to indent.
|
||||
;; (and (< (point) indent-point)
|
||||
;; (current-column)))
|
||||
;; ;; If no previous statement,
|
||||
;; ;; indent it relative to line brace is on.
|
||||
;; ;; For open brace in column zero, don't let statement
|
||||
;; ;; start there too. If ess-indent-offset is zero,
|
||||
;; ;; use ess-brace-offset + ess-continued-statement-offset instead.
|
||||
;; ;; For open-braces not the first thing in a line,
|
||||
;; ;; add in ess-brace-imaginary-offset.
|
||||
;; (+ (if (and (bolp) (zerop ess-indent-offset))
|
||||
;; (+ ess-brace-offset ess-continued-statement-offset)
|
||||
;; ess-indent-offset)
|
||||
;; ;; Move back over whitespace before the openbrace.
|
||||
;; ;; If openbrace is not first nonwhite thing on the line,
|
||||
;; ;; add the ess-brace-imaginary-offset.
|
||||
;; (progn (skip-chars-backward " \t")
|
||||
;; (if (bolp) 0 ess-brace-imaginary-offset))
|
||||
;; ;; If the openbrace is preceded by a parenthesized exp,
|
||||
;; ;; move to the beginning of that;
|
||||
;; ;; possibly a different line
|
||||
;; (progn
|
||||
;; (if (eq (preceding-char) ?\))
|
||||
;; (forward-sexp -1))
|
||||
;; ;; Get initial indentation of the line we are on.
|
||||
;; (current-indentation))))))))))
|
||||
|
||||
|
||||
|
||||
|
||||
(defvar OMG-syntax-table nil "Syntax table for Omegahat code.")
|
||||
(if S-syntax-table
|
||||
nil
|
||||
(setq S-syntax-table (make-syntax-table))
|
||||
(modify-syntax-entry ?\\ "\\" S-syntax-table)
|
||||
(modify-syntax-entry ?+ "." S-syntax-table)
|
||||
(modify-syntax-entry ?- "." S-syntax-table)
|
||||
(modify-syntax-entry ?= "." S-syntax-table)
|
||||
(modify-syntax-entry ?% "." S-syntax-table)
|
||||
(modify-syntax-entry ?< "." S-syntax-table)
|
||||
(modify-syntax-entry ?> "." S-syntax-table)
|
||||
(modify-syntax-entry ?& "." S-syntax-table)
|
||||
(modify-syntax-entry ?| "." S-syntax-table)
|
||||
(modify-syntax-entry ?\' "\"" S-syntax-table)
|
||||
;;FIXME: This fails (warning in compilation):
|
||||
;;F "//" are 2 characters; ?// is invalid
|
||||
;;F NEXT LINE IS BOGUS IN XEMACS, AJR
|
||||
;;F (modify-syntax-entry ?// "<" S-syntax-table) ; open comment
|
||||
;;F (modify-syntax-entry ?\n ">" S-syntax-table) ; close comment
|
||||
;;(modify-syntax-entry ?. "w" S-syntax-table) ; "." used in S obj names
|
||||
(modify-syntax-entry ?. "_" S-syntax-table) ; see above/below,
|
||||
; plus consider separation.
|
||||
(modify-syntax-entry ?$ "_" S-syntax-table) ; foo.bar$hack is 1 symbol
|
||||
(modify-syntax-entry ?_ "." S-syntax-table)
|
||||
(modify-syntax-entry ?* "." S-syntax-table)
|
||||
(modify-syntax-entry ?< "." S-syntax-table)
|
||||
(modify-syntax-entry ?> "." S-syntax-table)
|
||||
(modify-syntax-entry ?/ "." S-syntax-table))
|
||||
|
||||
|
||||
(defvar OMG-editing-alist
|
||||
'((paragraph-start . (concat "^$\\|" page-delimiter))
|
||||
(paragraph-separate . (concat "^$\\|" page-delimiter))
|
||||
(paragraph-ignore-fill-prefix . t)
|
||||
(require-final-newline . mode-require-final-newline)
|
||||
(comment-start . "//")
|
||||
(comment-start-skip . "//+ *")
|
||||
(comment-column . 40)
|
||||
;;(comment-indent-function . 'S-comment-indent)
|
||||
;;(ess-comment-indent . 'S-comment-indent)
|
||||
;;(ess-indent-line . 'S-indent-line)
|
||||
;;(ess-calculate-indent . 'ess-calculate-indent)
|
||||
(indent-line-function . 'ess-indent-line)
|
||||
(parse-sexp-ignore-comments . t)
|
||||
(ess-style . ess-default-style)
|
||||
(ess-local-process-name . nil)
|
||||
;;(ess-keep-dump-files . 'ask)
|
||||
(ess-mode-syntax-table . S-syntax-table)
|
||||
(font-lock-defaults . '(ess-OMG-font-lock-defaults
|
||||
nil nil ((?\. . "w")))))
|
||||
"General options for Omegahat source files.")
|
||||
|
||||
(defvar ess-OMG-font-lock-defaults
|
||||
(append (list
|
||||
(cons "\\b[0-9]+\\b" 'font-lock-type-face) ; numbers
|
||||
(cons (concat "\\<" (regexp-opt ess-S-keywords 'enc-paren) "\\>")
|
||||
'font-lock-keyword-face))
|
||||
(list
|
||||
(cons (regexp-opt ess-S-assign-ops)
|
||||
'font-lock-constant-face) ; assign
|
||||
(cons (concat "\\<" (regexp-opt ess-S-constants 'enc-paren) "\\>")
|
||||
'font-lock-type-face) ; constants
|
||||
(cons (concat "\\<" (regexp-opt ess-S-modifyiers 'enc-paren) "\\>")
|
||||
'font-lock-constant-face) ; modify search list or source
|
||||
|
||||
(cons ess-S-function-name-regexp
|
||||
'(1 font-lock-function-name-face keep))
|
||||
; function name
|
||||
(cons "\\s.\\|\\s(\\|\\s)" 'font-lock-function-name-face)
|
||||
;punctuation and parents (same as function not to cause vidual disturbance)
|
||||
)) ; keywords
|
||||
"Font-lock patterns used in `OMG' buffers.")
|
||||
|
||||
|
||||
;;; Changes from S to S-PLUS 3.x. (standard S3 should be in ess-s-l.el !).
|
||||
|
||||
(defconst OMG-help-sec-keys-alist
|
||||
'((?a . "ARGUMENTS:")
|
||||
(?b . "BACKGROUND:")
|
||||
(?B . "BUGS:")
|
||||
(?d . "DESCRIPTION:")
|
||||
(?D . "DETAILS:")
|
||||
(?e . "EXAMPLES:")
|
||||
(?n . "NOTE:")
|
||||
(?O . "OPTIONAL ARGUMENTS:")
|
||||
(?R . "REQUIRED ARGUMENTS:")
|
||||
(?r . "REFERENCES:")
|
||||
(?s . "SEE ALSO:")
|
||||
(?S . "SIDE EFFECTS:")
|
||||
(?u . "USAGE:")
|
||||
(?v . "VALUE:"))
|
||||
"Alist of (key . string) pairs for use in section searching.")
|
||||
;;; `key' indicates the keystroke to use to search for the section heading
|
||||
;;; `string' in an S help file. `string' is used as part of a
|
||||
;;; regexp-search, and so specials should be quoted.
|
||||
|
||||
(defconst ess-help-OMG-sec-regex "^[A-Z. ---]+:$"
|
||||
"Reg(ular) Ex(pression) of section headers in help file")
|
||||
|
||||
;;; S-mode extras of Martin Maechler, Statistik, ETH Zurich.
|
||||
|
||||
;;>> Moved things into --> ./ess-utils.el
|
||||
|
||||
(provide 'ess-omg-l)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; outline-minor-mode: nil
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-omg-l.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-omg-l.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-omg-l.elc
Normal file
Binary file not shown.
164
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-a.el
Normal file
164
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-a.el
Normal file
@@ -0,0 +1,164 @@
|
||||
;;; ess-r-a.el -- Possible local customizations for R with ESS.
|
||||
|
||||
;; Copyright (C) 1997--2005 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: A.J. Rossini <blindglobe@gmail.com>
|
||||
;; Created: 17 November 1999
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; Keywords: languages
|
||||
|
||||
;; This file is part of ESS
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; The purpose of this file is to demonstrate some of the extras that
|
||||
;; have been constructed for the ESS R mode; if they prove
|
||||
;; interesting, then they might be migrated to ess-r-d, the primary
|
||||
;; ESS R mode tools.
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; you can invoke ESS/R from emacs by typing
|
||||
;; C-u M-x essr
|
||||
;; with vsize set to (for example) 40M, and nsize set to 600000.
|
||||
(defalias 'essr
|
||||
(read-kbd-macro
|
||||
"C-u M-x R RET - - vsize = 40M SPC - - nsize = 600000 2*RET"))
|
||||
|
||||
(defun ess-r-do-region (start end &optional message)
|
||||
"Send the current region to R via AppleScript."
|
||||
(interactive "r\nP")
|
||||
(message "Starting evaluation...")
|
||||
(do-applescript (concat
|
||||
"try\n"
|
||||
"tell application \"R\"\n"
|
||||
"activate\n"
|
||||
"with timeout of 0 seconds\n"
|
||||
"cmd \"" (buffer-substring start end)
|
||||
"\"\n"
|
||||
"end timeout\n"
|
||||
"end tell\n"
|
||||
"end try\n"))
|
||||
(message "Finished evaluation"))
|
||||
|
||||
(defun ess-r-do-line ()
|
||||
"Send the current line to R via AppleScript."
|
||||
(interactive) ;; "r\nP")
|
||||
(message "Starting evaluation...")
|
||||
(save-excursion
|
||||
(let ((end (point)))
|
||||
(move-to-column 0)
|
||||
(do-applescript (concat
|
||||
"try\n"
|
||||
"tell application \"R\"\n"
|
||||
"activate\n"
|
||||
"with timeout of 0 seconds\n"
|
||||
"cmd \"" (buffer-substring (point) end)
|
||||
"\"\n"
|
||||
"end timeout\n"
|
||||
"end tell\n"
|
||||
"end try\n"))))
|
||||
(message "Finished evaluation"))
|
||||
|
||||
(defun ess-r-var (beg end)
|
||||
"Load the current region of numbers into an R variable. Prompts for
|
||||
a variable name. If none is given, it uses a default variable name,
|
||||
e. BEG and END denote the region in the current buffer to be sent."
|
||||
(interactive "r")
|
||||
(save-window-excursion
|
||||
(let ((tmp-file (make-temp-file "ess-r-var"))
|
||||
cmd
|
||||
var)
|
||||
(write-region beg end tmp-file)
|
||||
|
||||
;; Decide on the variable name to use in R; could use completion.
|
||||
(setq var (read-string "R Variable name (default e): "))
|
||||
(if (equal var "")
|
||||
(setq var "e"))
|
||||
|
||||
;; Command to send to the R process. Get R to delete the file
|
||||
;; rather than Emacs in case it takes R a long time to run the
|
||||
;; scan command.
|
||||
(setq cmd (concat var " <- scan(\"" tmp-file "\"); "
|
||||
"unlink(\"" tmp-file "\")" ))
|
||||
|
||||
;; Put the output from the scan command into the process buffer so
|
||||
;; the user has a record of it.
|
||||
(ess-execute cmd 'buffer))))
|
||||
|
||||
|
||||
;;; Peter Dalgaard's code.
|
||||
;;; This needs to be cleaned and validated!
|
||||
|
||||
(defun pd::set-up-demo ()
|
||||
|
||||
;; (if (not xemacs) (set-default-font "*courier-bold-r*--14**"))
|
||||
(R)
|
||||
(split-window-vertically 6)
|
||||
(find-file "demos.R")
|
||||
|
||||
;; Don't need to run this as a function -- ought to be fine if set
|
||||
;; just once.
|
||||
|
||||
(defun ajr::scroll-to-end::peterD (emacs)
|
||||
"Goal: map prompt to bottom of the screen after every command.
|
||||
Alternatively, use the scroll-in-place package, not sure where that
|
||||
is)."
|
||||
(interactive)
|
||||
(other-buffer 1)
|
||||
(if (= emacs "emacs")
|
||||
(setq scroll-up-aggressively t)
|
||||
(setq scroll-conservatively -4)) ;; <- change this
|
||||
(other-buffer -1))
|
||||
|
||||
(defun show-max-other-window ()
|
||||
(interactive)
|
||||
(other-window 1)
|
||||
(comint-show-maximum-output)
|
||||
(other-window -1))
|
||||
|
||||
;; call this once
|
||||
;; (ajr::scroll-to-end::peterD "xemacs")
|
||||
;; (ajr::scroll-to-end::peterD "emacs")
|
||||
|
||||
(global-set-key [f11] 'show-max-other-window)
|
||||
(global-set-key [f12] 'ess-eval-line-and-step))
|
||||
|
||||
|
||||
; Provide package
|
||||
|
||||
(provide 'ess-r-a)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; outline-minor-mode: nil
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-r-a.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-a.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-a.elc
Normal file
Binary file not shown.
331
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-args.el
Normal file
331
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-args.el
Normal file
@@ -0,0 +1,331 @@
|
||||
;;; ess-r-args.el --- Insert R function's arguments
|
||||
|
||||
;; Copyright (C) 2007 Sven Hartenstein <mail at svenhartenstein dot de>
|
||||
;; Copyright (C) 2007 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; This file is part of ESS
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;; Last update: 2012-02-27
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; == DOCUMENTATION ==
|
||||
|
||||
;; This file provides some functions that show or insert a
|
||||
;; R-function's arguments (and their default values) by using R's
|
||||
;; args() function. This code requires ESS (http://ess.r-project.org).
|
||||
;; For screenshots as well as information on requirements,
|
||||
;; installation, configuration and troubleshooting, please visit
|
||||
;; http://www.svenhartenstein.de/emacs-ess.php
|
||||
|
||||
;; Users of XEmacs (or maybe non-GNU-Emacs users): The code below must
|
||||
;; be slightly adapted in order to work in XEmacs (i.e. comment out
|
||||
;; the delete-trailing-whitespace function call by putting a semicolon
|
||||
;; at the beginning of the line). Furthermore, the tooltip option does
|
||||
;; NOT work in XEmacs (yet) (and will probably only ever work if the
|
||||
;; ESS-core team will adapt the code for XEmacs compatibility).
|
||||
|
||||
;; == Requirements ==
|
||||
|
||||
;; * ESS mode must be loaded and running.
|
||||
;; * A R process must be running within ESS.
|
||||
;; * For the tooltip option to work, Emacs must not run within a
|
||||
;; terminal but (directly) under the X window system (in case of
|
||||
;; GNU/Linux).
|
||||
;; * The tooltip option currently requires GNU Emacs (i.e. not XEmacs
|
||||
;; or a similar other derivate).
|
||||
|
||||
;; == Installation ==
|
||||
|
||||
;; To make Emacs aware of the functions defined in this file load it
|
||||
;; into Emacs by including something like the following in your
|
||||
;; ~/.emacs file (adapt "/PATH/TO"!).
|
||||
;;
|
||||
;; (add-hook 'ess-mode-hook (lambda () (load "/PATH/TO/ess-r-args.el")))
|
||||
;;
|
||||
;; This file is included with ESS; if you are reading this file as
|
||||
;; part of the ESS distribution, then you do not need to add the above
|
||||
;; line.
|
||||
|
||||
;; == Configuration ==
|
||||
|
||||
;; Configuration should be done by setting some variables in your
|
||||
;; ~/.emacs file, the following is an example only, adjust it to your
|
||||
;; needs.
|
||||
|
||||
;; ;; ess-r-args-noargsmsg is printed, if no argument information
|
||||
;; ;; could be found. You could set it to an empty string ("") for no
|
||||
;; ;; message.
|
||||
;; (setq ess-r-args-noargsmsg "No args found.")
|
||||
;;
|
||||
;; ;; ess-r-args-show-as determines how (where) the information is
|
||||
;; ;; displayed. Set it to 'tooltip little tooltip windows or to
|
||||
;; ;; 'message (the default) which will use the echo area at the bottom of
|
||||
;; ;; your Emacs frame.
|
||||
;; (setq ess-r-args-show-as nil)
|
||||
;;
|
||||
;; ;; ess-r-args-show-prefix is a string that is printed in front of
|
||||
;; ;; the arguments list. The default is "ARGS: ".
|
||||
;; (setq ess-r-args-show-prefix "ARGS: ")
|
||||
|
||||
;; == Usage ==
|
||||
|
||||
;; The functions should be called when point (text cursor) is between
|
||||
;; two parentheses of a R function call (see screenshots above). It
|
||||
;; will then (invisibly) query R for which arguments the respective
|
||||
;; function knows as well as their default values and show or insert
|
||||
;; the result.
|
||||
|
||||
;; There are currently two functions: ess-r-args-show echoes the
|
||||
;; arguments in the echo area or as tooltip, ess-r-args-insert prints
|
||||
;; the arguments at point.
|
||||
|
||||
;; In order to not having to type the whole function name each time
|
||||
;; you want to see the arguments list, you most probably want to bind
|
||||
;; the functions to a key which again should be done in your ~/.emacs
|
||||
;; file. You can also let Emacs call the function each time you insert
|
||||
;; an opening parenthesis ("(").
|
||||
|
||||
;; -----> do this below
|
||||
|
||||
;; Again, the following is an example only:
|
||||
|
||||
;; bind ess-r-args-show to F2
|
||||
;; (define-key ess-mode-map [f2] 'ess-r-args-show)
|
||||
|
||||
;; bind ess-r-args-insert to F3
|
||||
;; (define-key ess-mode-map [f3] 'ess-r-args-insert)
|
||||
|
||||
;; == Setting the tooltip position ==
|
||||
|
||||
;; Unfortunately (?), tooltips are by default shown at the mouse
|
||||
;; pointer's position, which is not necessarily where you are looking
|
||||
;; at. If you use Emacs' mouse-avoidance-mode with option "banish"
|
||||
;; then the mouse pointer will automatically be put at the upper right
|
||||
;; corner of the Emacs window so that you know where to look for the
|
||||
;; tooltip. Emacs also allows for setting the tooltip position
|
||||
;; relative to the upper left corner of your screen. If you know how
|
||||
;; to let Emacs determine the point (text cursor) position in pixels
|
||||
;; from the upper left corner of the screen, please let me know. It
|
||||
;; would then be possible to show the tooltip near the point, which I
|
||||
;; would consider preferably.
|
||||
;; SJE: see code at bottom 2009-01-30...
|
||||
|
||||
;; ;; Put mouse away when using keyboard
|
||||
;; (mouse-avoidance-mode 'banish)
|
||||
|
||||
;; ;; Set the tooltip position in absolute pixels from the upper left
|
||||
;; ;; corner of the screen
|
||||
;; (setq tooltip-frame-parameters
|
||||
;; '((name . "tooltip")
|
||||
;; (left . 20)
|
||||
;; (top . 20)))
|
||||
|
||||
;; == Changelog ==
|
||||
|
||||
;; * 2007-04-03: The function should now do nothing (instead of
|
||||
;; irritating cursor movement) if the current ESS process is
|
||||
;; anything but R.
|
||||
;; * 2007-04-05: Function names changed. Much more modular. GPLed. New
|
||||
;; prefix configuration variable. Minor changes.
|
||||
;; * 2007-04-30: Error handling added. Bugfix: Emacs used to lock up
|
||||
;; when function was called within parentheses following the "#"
|
||||
;; character (Thanks to John Bullock for his bug report!).
|
||||
|
||||
;; == Troubleshooting ==
|
||||
|
||||
;; Before sending reports of problems, please check the following.
|
||||
|
||||
;; * Doublecheck the requirements section above.
|
||||
;; * Please be sure you tried both the "tooltip" option and the "echo
|
||||
;; area" option and tell me whether both failed or just one.
|
||||
;; * Check whether it is a key binding problem. Run the function with
|
||||
;; M-x ess-r-args-show RET. If it works but not the key binding, try
|
||||
;; binding it to another key. Some window managers might not pass
|
||||
;; the function key keystrokes to Emacs.
|
||||
|
||||
;; If you encounter problems, please send me detailed bug reports.
|
||||
;; Please also indicate the ESS version you are running and the Emacs
|
||||
;; type (GNU vs. X) and operating system. I will do my best to help
|
||||
;; but please be aware that I'm everything but an emacs lisp expert.
|
||||
|
||||
;; == TODO ==
|
||||
|
||||
;; These are things that I would like to see improved. Please let me
|
||||
;; know if you know how it could be done.
|
||||
|
||||
;; * As mentioned above, I would like to place the tooltip near the
|
||||
;; point (text cursor) but I do not see how this could be done.
|
||||
;; * Both the message in the echo area and the tooltip automatically
|
||||
;; disappear as soon as a key is pressed. That is, you will need to
|
||||
;; call the function again if you have entered the first
|
||||
;; parameter(s) and wonder what additional parameters are possible.
|
||||
;; I would prefer the information to be shown, say, five seconds or
|
||||
;; so.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(eval-and-compile
|
||||
(require 'ess-custom))
|
||||
|
||||
(eval-when-compile
|
||||
(if ess-has-tooltip
|
||||
(require 'tooltip))); for tooltip-show
|
||||
|
||||
(require 'ess)
|
||||
|
||||
(defun ess-r-args-current-function ()
|
||||
"Returns the name of the R function assuming point is currently
|
||||
within the argument list or nil if no possible function name is
|
||||
found."
|
||||
(save-excursion
|
||||
(condition-case nil (up-list -1)
|
||||
(error (message "Can't find opening parenthesis.")))
|
||||
(let ((posend (point)))
|
||||
(backward-sexp 1)
|
||||
(let ((rfunname (buffer-substring-no-properties posend (point))))
|
||||
(if (posix-string-match "^[a-zA-Z0-9_\.]+$" rfunname)
|
||||
rfunname nil)))))
|
||||
|
||||
(defun ess-r-args-get (&optional function trim)
|
||||
"Returns string of arguments and their default values of R
|
||||
function FUNCTION or nil if no possible function name
|
||||
found. Calls `ess-r-args-current-function' if no argument given.
|
||||
If TRIM is non-nill remove tabs and newlines and replace ' = '
|
||||
with '=' (useful for display in minibuffer to avoid window and
|
||||
buffer readjustments for multiline string)."
|
||||
(if (null function)
|
||||
(setq function (ess-r-args-current-function)))
|
||||
(when (and function
|
||||
(or ess-current-process-name
|
||||
(interactive-p)))
|
||||
(ess-force-buffer-current "R process to use: ")
|
||||
;; ^^^^^^^^^^^^^^^ has own error handler
|
||||
(mapconcat (lambda (arg) (concat (car arg) "=" (cdr arg)))
|
||||
(cadr (ess-function-arguments function))
|
||||
", ")))
|
||||
|
||||
(defun ess-r-args-show (&optional function)
|
||||
"Show arguments and their default values of R function. Calls
|
||||
\\[ess-r-args-current-function] if called without argument."
|
||||
(interactive "*")
|
||||
(ess-message "(ess-r-args-show): start")
|
||||
(if (null function)
|
||||
(setq function (ess-r-args-current-function)))
|
||||
(ess-message ".... function='%s'" function)
|
||||
(when function
|
||||
(let* ((tt (and (equal ess-r-args-show-as 'tooltip)
|
||||
ess-has-tooltip))
|
||||
(args (concat ess-r-args-show-prefix
|
||||
(ess-r-args-get function (not tt)))))
|
||||
(ess-message "(ess-r-args-show): args='%s'" args)
|
||||
(when args
|
||||
(if (not tt)
|
||||
(message args)
|
||||
(require 'tooltip)
|
||||
;; value of 30 in next call is just a guess,
|
||||
;; should really be based
|
||||
;; on something like pixel height of 1-2 vertical
|
||||
;; lines of text
|
||||
(ess-tooltip-show-at-point args 0 30))
|
||||
))))
|
||||
|
||||
(defun ess-r-args-auto-show ()
|
||||
"Typically assigned to \"(\": If there's an ess-process, automatically show arguments
|
||||
and their default values of an R function. Built on \\[ess-r-args-show]."
|
||||
(interactive)
|
||||
(insert "("); (skeleton-pair-insert-maybe nil)
|
||||
(if (and (not eldoc-mode)
|
||||
ess-local-process-name ; has a process and it must still be running
|
||||
(ess-get-process ess-local-process-name))
|
||||
(ess-r-args-show)))
|
||||
|
||||
;; MM: I would strongly discourage use of the following:
|
||||
;; it leads to clueless newbie-users who indeed
|
||||
;; explicitly call a function with all its default arguments;
|
||||
;; instead of only setting the required arguments
|
||||
(defun ess-r-args-insert (&optional function)
|
||||
"Insert arguments and their default values of function. Calls
|
||||
ess-r-args-current-function if no argument given."
|
||||
(interactive "*")
|
||||
(if (null function)
|
||||
(setq function (ess-r-args-current-function)))
|
||||
(if function
|
||||
(let ((args (ess-r-args-get function))
|
||||
(pointpos (point)))
|
||||
(insert args)
|
||||
(goto-char pointpos))))
|
||||
|
||||
|
||||
;; (defvar ess-r-object-tooltip-alist
|
||||
;; '((numeric . "summary")
|
||||
;; (integer . "summary")
|
||||
;; (factor . "table")
|
||||
;; (lm . "summary")
|
||||
;; (other . "str"))
|
||||
;; "List of (<class> . <R-function>) to be used in \\[ess-r-object-tooltip].
|
||||
;; For example, when called while point is on a factor object, a table of that
|
||||
;; factor will be shown in the tooltip.
|
||||
;; The special key \"other\" in the alist defines which function to call when
|
||||
;; the class is not mached in the alist. The default, str(), is a fairly useful
|
||||
;; default for many, including data.frame and function objects.")
|
||||
|
||||
;; From Erik Iversion, slightly modified,
|
||||
;; http://www.sigmafield.org/2009/10/01/r-object-tooltips-in-ess/
|
||||
;; (defun ess-r-object-tooltip ()
|
||||
;; "Get info for object at point, and display it in a tooltip."
|
||||
;; (interactive)
|
||||
;; (let ((proc (ess-get-process))
|
||||
;; (objname (current-word))
|
||||
;; (curbuf (current-buffer))
|
||||
;; (tmpbuf (get-buffer-create " *ess-r-object-tooltip*"))
|
||||
;; bs)
|
||||
;; (when objname
|
||||
;; (ess-write-to-dribble-buffer
|
||||
;; (format "ess-r-object-tooltip: objname='%s'\n" objname))
|
||||
;; (ess-command (concat "class(" objname ")\n") tmpbuf nil nil nil proc)
|
||||
;; (with-current-buffer tmpbuf
|
||||
;; (goto-char (point-min))
|
||||
;; ;; CARE: The following can only work in an English language locale!
|
||||
;; ;; .lang. <- Sys.getenv("LANGUAGE"); Sys.setenv(LANGUAGE="en")
|
||||
;; ;; .lc. <- Sys.getlocale("LC_MESSAGES"); Sys.setlocale("LC_MESSAGES","en_US.utf-8")
|
||||
;; ;; and *afterward* Sys.setenv(LANGUAGE=.lang.); Sys.setlocale("LC_MESSAGES", .lc.)
|
||||
;; ;; but that fails sometimes, e.g., on Windows
|
||||
;; (unless (re-search-forward "\(object .* not found\)\|unexpected" nil t)
|
||||
;; (re-search-forward "\"\\(.*\\)\"" nil t)
|
||||
;; (let* ((objcls (match-string 1))
|
||||
;; (myfun (or (cdr (assoc-string objcls ess-r-object-tooltip-alist))
|
||||
;; (cdr (assoc 'other ess-r-object-tooltip-alist)))))
|
||||
;; (ess-command (concat myfun "(" objname ")\n") tmpbuf nil nil nil proc))
|
||||
;; (setq bs (buffer-string)))))
|
||||
;; (if bs
|
||||
;; (ess-tooltip-show-at-point bs 0 30))))
|
||||
|
||||
;; Erik: my default key map
|
||||
;;(define-key ess-mode-map "\C-c\C-g" 'ess-r-object-tooltip)
|
||||
|
||||
;; On http://www.sigmafield.org/2009/10/01/r-object-tooltips-in-ess/
|
||||
;; in the comments, "Charlie" recommended
|
||||
|
||||
;; (custom-set-faces
|
||||
;; '(tooltip ((t (:background "white" :foreground "blue" :foundry "fixed")))))
|
||||
|
||||
|
||||
|
||||
(provide 'ess-r-args)
|
||||
|
||||
;;; ess-r-args.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-args.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-args.elc
Normal file
Binary file not shown.
485
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-completion.el
Normal file
485
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-completion.el
Normal file
@@ -0,0 +1,485 @@
|
||||
;;; ess-r-completion.el --- R completion
|
||||
;;
|
||||
;; Copyright (C) 2015 A.J. Rossini, Richard M. Heiberger, Martin Maechler, Kurt
|
||||
;; Hornik, Rodney Sparapani, Stephen Eglen and Vitalie Spinu.
|
||||
;;
|
||||
;; Author: Vitalie Spinu
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
;;
|
||||
;; Keywords: languages, statistics
|
||||
;;
|
||||
;; This file is part of ESS.
|
||||
;;
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
;;
|
||||
;;; Commentary:
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
|
||||
;;; ElDoc
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
(require 'ess-utils)
|
||||
|
||||
(defun ess-R-eldoc-function ()
|
||||
"Return the doc string, or nil.
|
||||
If an ESS process is not associated with the buffer, do not try
|
||||
to look up any doc strings."
|
||||
(interactive)
|
||||
(let ((proc (ess-get-next-available-process)))
|
||||
(when proc
|
||||
(let ((funname (or (and ess-eldoc-show-on-symbol ;; aggressive completion
|
||||
(thing-at-point 'symbol))
|
||||
(car (ess--funname.start)))))
|
||||
(when funname
|
||||
(let* ((args (ess-function-arguments funname proc))
|
||||
(bargs (cadr args))
|
||||
(doc (mapconcat (lambda (el)
|
||||
(if (equal (car el) "...")
|
||||
"..."
|
||||
(concat (car el) "=" (cdr el))))
|
||||
bargs ", "))
|
||||
(margs (nth 2 args))
|
||||
(W (- (window-width (minibuffer-window)) (+ 4 (length funname))))
|
||||
doc1)
|
||||
(when doc
|
||||
(setq doc (ess-eldoc-docstring-format funname doc))
|
||||
(when (and margs (< (length doc1) W))
|
||||
(setq doc1 (concat doc (propertize " || " 'face font-lock-function-name-face)))
|
||||
(while (and margs (< (length doc1) W))
|
||||
(let ((head (pop margs)))
|
||||
(unless (assoc head bargs)
|
||||
(setq doc doc1
|
||||
doc1 (concat doc1 head "=, ")))))
|
||||
(when (equal (substring doc -2) ", ")
|
||||
(setq doc (substring doc 0 -2)))
|
||||
(when (and margs (< (length doc) W))
|
||||
(setq doc (concat doc " {--}"))))
|
||||
doc)))))))
|
||||
|
||||
(defun ess-eldoc-docstring-format (funname doc)
|
||||
(save-match-data
|
||||
(let* (;; (name (symbol-name sym))
|
||||
(truncate (or (not (eq t eldoc-echo-area-use-multiline-p))
|
||||
(eq ess-eldoc-abbreviation-style 'aggressive)))
|
||||
;; Subtract 1 from window width since will cause a wraparound and
|
||||
;; resize of the echo area.
|
||||
(W (1- (- (window-width (minibuffer-window))
|
||||
(+ 2 (length funname)))))
|
||||
newdoc
|
||||
)
|
||||
(setq doc
|
||||
(if (or (<= (length doc) W)
|
||||
(null ess-eldoc-abbreviation-style)
|
||||
(eq 'none ess-eldoc-abbreviation-style))
|
||||
doc
|
||||
;;MILD filter
|
||||
(setq doc (replace-regexp-in-string "TRUE" "T" doc))
|
||||
(setq doc (replace-regexp-in-string "FALSE" "F" doc))
|
||||
(if (or (<= (length doc) W)
|
||||
(eq 'mild ess-eldoc-abbreviation-style))
|
||||
doc
|
||||
;;NORMAL filter (deal with long defaults)
|
||||
(setq doc (replace-regexp-in-string
|
||||
;; function calls inside default docs foo(xxxx{..})
|
||||
"([^)]\\{8\\}\\([^)]\\{4,\\}\\))"
|
||||
"{.}" doc nil nil 1))
|
||||
(if (<= (length doc) W)
|
||||
doc
|
||||
(setq doc (replace-regexp-in-string
|
||||
" +[^ \t=,\"\]+=[^ \t]\\{10\\}\\([^ \t]\\{4,\\}\\)\\(,\\|\\'\\)"
|
||||
"{.}," doc nil nil 1))
|
||||
(if (<= (length doc) W)
|
||||
doc
|
||||
(setq doc (replace-regexp-in-string
|
||||
" +[^ \t=,\"]+=\\([^ \t]\\{10,\\}\\)\\(,\\|\\'\\)"
|
||||
"{.}," doc nil nil 1))
|
||||
(if (or (<= (length doc) W)
|
||||
(eq 'normal ess-eldoc-abbreviation-style))
|
||||
doc
|
||||
;;STRONG filter (replace defaults)
|
||||
(setq doc (replace-regexp-in-string
|
||||
" *[^ \t=,\"\\]* = \\([^ \t]\\{4,\\}\\)\\(,\\|\\'\\)"
|
||||
"{.}," doc nil nil 1))
|
||||
(if (<= (length doc) W)
|
||||
doc
|
||||
(setq doc (replace-regexp-in-string
|
||||
"\\(=[^FT0-9].+?\\)\\(, [^ =,\"\\]+=\\|\\'\\)"
|
||||
"" doc nil nil 1))
|
||||
(setq doc (replace-regexp-in-string
|
||||
"\\(=[^FT0-9].+?\\)\\(, [^ =,\"\\]+,\\|\\'\\)"
|
||||
"" doc nil nil 1))
|
||||
(if (or (<= (length doc) W)
|
||||
(eq 'strong ess-eldoc-abbreviation-style))
|
||||
doc
|
||||
;;AGGRESSIVE filter (truncate what is left)
|
||||
(concat (substring doc 0 (- W 4)) "{--}")))))))))
|
||||
(when (and truncate
|
||||
(> (length doc) W))
|
||||
(setq doc (concat (substring doc 0 (- W 4)) "{--}")))
|
||||
(format "%s: %s" (propertize funname 'face 'font-lock-function-name-face) doc))))
|
||||
|
||||
|
||||
;;; OBJECTS
|
||||
|
||||
(defun ess-R-object-completion ()
|
||||
"Return completions at point in a format required by `completion-at-point-functions'."
|
||||
(if (ess-make-buffer-current)
|
||||
(let* ((funstart (cdr (ess--funname.start)))
|
||||
(completions (ess-R-get-rcompletions funstart))
|
||||
(token (pop completions)))
|
||||
(when completions
|
||||
(list (- (point) (length token)) (point)
|
||||
completions)))
|
||||
(when (string-match "complete" (symbol-name last-command))
|
||||
(message "No ESS process associated with current buffer")
|
||||
nil)))
|
||||
|
||||
(defun ess-complete-object-name ()
|
||||
"Perform completion on `ess-language' object preceding point.
|
||||
Uses \\[ess-R-complete-object-name] when `ess-use-R-completion' is non-nil,
|
||||
or \\[ess-internal-complete-object-name] otherwise."
|
||||
(interactive)
|
||||
(if (ess-make-buffer-current)
|
||||
(if ess-use-R-completion
|
||||
(ess-R-complete-object-name)
|
||||
(ess-internal-complete-object-name))
|
||||
;; else give a message on second invocation
|
||||
(when (string-match "complete" (symbol-name last-command))
|
||||
(message "No ESS process associated with current buffer")
|
||||
nil)))
|
||||
|
||||
(defun ess-complete-object-name-deprecated ()
|
||||
"Gives a deprecated message "
|
||||
(interactive)
|
||||
(ess-complete-object-name)
|
||||
(message "C-c TAB is deprecated, completions has been moved to [M-TAB] (aka C-M-i)")
|
||||
(sit-for 2 t))
|
||||
|
||||
;; This one is needed for R <= 2.6.x -- hence *not* obsoleting it
|
||||
(defun ess-internal-complete-object-name ()
|
||||
"Perform completion on `ess-language' object preceding point.
|
||||
The object is compared against those objects known by
|
||||
`ess-get-object-list' and any additional characters up to ambiguity are
|
||||
inserted. Completion only works on globally-known objects (including
|
||||
elements of attached data frames), and thus is most suitable for
|
||||
interactive command-line entry, and not so much for function editing
|
||||
since local objects (e.g. argument names) aren't known.
|
||||
|
||||
Use \\[ess-resynch] to re-read the names of the attached directories.
|
||||
This is done automatically (and transparently) if a directory is
|
||||
modified (S only!), so the most up-to-date list of object names is always
|
||||
available. However attached dataframes are *not* updated, so this
|
||||
command may be necessary if you modify an attached dataframe."
|
||||
(interactive)
|
||||
(ess-make-buffer-current)
|
||||
(if (memq (char-syntax (preceding-char)) '(?w ?_))
|
||||
(let* ((comint-completion-addsuffix nil)
|
||||
(end (point))
|
||||
(buffer-syntax (syntax-table))
|
||||
(beg (unwind-protect
|
||||
(save-excursion
|
||||
(set-syntax-table ess-mode-syntax-table)
|
||||
(backward-sexp 1)
|
||||
(point))
|
||||
(set-syntax-table buffer-syntax)))
|
||||
(full-prefix (buffer-substring beg end))
|
||||
(pattern full-prefix)
|
||||
;; See if we're indexing a list with `$'
|
||||
(listname (if (string-match "\\(.+\\)\\$\\(\\(\\sw\\|\\s_\\)*\\)$"
|
||||
full-prefix)
|
||||
(progn
|
||||
(setq pattern
|
||||
(if (not (match-beginning 2)) ""
|
||||
(substring full-prefix
|
||||
(match-beginning 2)
|
||||
(match-end 2))))
|
||||
(substring full-prefix (match-beginning 1)
|
||||
(match-end 1)))))
|
||||
;; are we trying to get a slot via `@' ?
|
||||
(classname (if (string-match "\\(.+\\)@\\(\\(\\sw\\|\\s_\\)*\\)$"
|
||||
full-prefix)
|
||||
(progn
|
||||
(setq pattern
|
||||
(if (not (match-beginning 2)) ""
|
||||
(substring full-prefix
|
||||
(match-beginning 2)
|
||||
(match-end 2))))
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "(ess-C-O-Name : slots..) : patt=%s"
|
||||
pattern))
|
||||
(substring full-prefix (match-beginning 1)
|
||||
(match-end 1)))))
|
||||
(components (if listname
|
||||
(ess-object-names listname)
|
||||
(if classname
|
||||
(ess-slot-names classname)
|
||||
;; Default case: It hangs here when
|
||||
;; options(error=recover) :
|
||||
(ess-get-object-list ess-current-process-name)))))
|
||||
;; always return a non-nil value to prevent history expansions
|
||||
(or (comint-dynamic-simple-complete pattern components) 'none))))
|
||||
|
||||
(defun ess-R-get-rcompletions (&optional start end prefix)
|
||||
"Call R internal completion utilities (rcomp) for possible completions.
|
||||
Optional START and END delimit the entity to complete, default to
|
||||
bol and point. If PREFIX is given, perform completion on
|
||||
PREFIX. First element of the returned list is the completion
|
||||
token. Needs version of R>=2.7.0."
|
||||
(let* ((start (or start
|
||||
(if prefix
|
||||
0
|
||||
(save-excursion (comint-bol nil) (point)))))
|
||||
(end (or end (if prefix (length prefix) (point))))
|
||||
(prefix (or prefix (buffer-substring start end)))
|
||||
;; (opts1 (if no-args "op<-rc.options(args=FALSE)" ""))
|
||||
;; (opts2 (if no-args "rc.options(op)" ""))
|
||||
(cmd (format ".ess_get_completions(\"%s\", %d)\n"
|
||||
(ess-quote-special-chars prefix)
|
||||
(- end start))))
|
||||
(ess-get-words-from-vector cmd)))
|
||||
|
||||
(defun ess-R-complete-object-name ()
|
||||
"Completion in R via R's completion utilities (formerly 'rcompgen').
|
||||
To be used instead of ESS' completion engine for R versions >= 2.7.0."
|
||||
(interactive)
|
||||
(let ((possible-completions (ess-R-get-rcompletions))
|
||||
token-string)
|
||||
;; If there are no possible-completions, should return nil, so
|
||||
;; that when this function is called from
|
||||
;; comint-dynamic-complete-functions, other functions can also be
|
||||
;; tried.
|
||||
(when possible-completions
|
||||
(setq token-string (pop possible-completions))
|
||||
(or (comint-dynamic-simple-complete token-string
|
||||
possible-completions)
|
||||
'none))))
|
||||
|
||||
(defvar ess--cached-sp-objects nil)
|
||||
|
||||
(defun ess--get-cached-completions (prefix &optional point)
|
||||
(if (string-match-p "[]:$@[]" prefix)
|
||||
;; call proc for objects
|
||||
(cdr (ess-R-get-rcompletions nil nil prefix))
|
||||
;; else, get cached list of objects
|
||||
(with-ess-process-buffer 'no-error ;; use proc buf alist
|
||||
(ess-when-new-input last-cached-completions
|
||||
(if (and ess--cached-sp-objects
|
||||
(not (process-get *proc* 'sp-for-ac-changed?)))
|
||||
;; if global cache is already there, only re-read local .GlobalEnv
|
||||
(progn
|
||||
(unless ess-sl-modtime-alist
|
||||
;; initialize if empty
|
||||
(setq ess-sl-modtime-alist '((".GlobalEnv" nil))))
|
||||
;; fixme: Make adaptive. Not on all remotes are slow; For lots of
|
||||
;; objects in .GlobalEnv,locals could also be slow.
|
||||
(unless (file-remote-p default-directory)
|
||||
(ess-extract-onames-from-alist ess-sl-modtime-alist 1 'force)))
|
||||
(if ess--cached-sp-objects
|
||||
(ess-get-modtime-list 'ess--cached-sp-objects 'exclude-first)
|
||||
(ess-get-modtime-list)
|
||||
(setq ess--cached-sp-objects (cdr ess-sl-modtime-alist)))
|
||||
;; reread new package, but not rda, much faster and not needed anyways
|
||||
(process-put *proc* 'sp-for-ac-changed? nil)))
|
||||
(apply 'append
|
||||
(cddar ess-sl-modtime-alist) ; .GlobalEnv
|
||||
(mapcar 'cddr ess--cached-sp-objects)))))
|
||||
|
||||
|
||||
;;; ARGUMENTS
|
||||
|
||||
(defcustom ess-R-argument-suffix " = "
|
||||
"Suffix appended by `ac-source-R' and `ac-source-R-args' to candidates."
|
||||
:group 'R
|
||||
:type 'string)
|
||||
|
||||
(define-obsolete-variable-alias 'ess-ac-R-argument-suffix 'ess-R-argument-suffix "15.3")
|
||||
|
||||
(defvar ess-R--funargs-pre-cache
|
||||
'(("plot"
|
||||
(("graphics")
|
||||
(("x" . "") ("y" . "NULL") ("type" . "p") ("xlim" . "NULL") ("ylim" . "NULL") ("log" . "") ("main" . "NULL") ("sub" . "NULL") ("xlab" . "NULL") ("ylab" . "NULL")
|
||||
("ann" . "par(\"ann\")") ("axes" . "TRUE") ("frame.plot" . "axes") ("panel.first" . "NULL") ("panel.last" . "NULL") ("asp" . "NA") ("..." . ""))
|
||||
("x" "y" "..." "ci" "type" "xlab" "ylab" "ylim" "main" "ci.col" "ci.type" "max.mfrow" "ask" "mar" "oma" "mgp" "xpd" "cex.main" "verbose" "scale" "xlim" "log" "sub" "ann" "axes" "frame.plot"
|
||||
"panel.first" "panel.last" "asp" "center" "edge.root" "nodePar" "edgePar" "leaflab" "dLeaf" "xaxt" "yaxt" "horiz"
|
||||
"zero.line" "verticals" "col.01line" "pch" "legend.text" "formula" "data" "subset" "to" "from" "newpage" "vp" "labels"
|
||||
"hang" "freq" "density" "angle" "col" "border" "lty" "add" "predicted.values" "intervals" "separator" "col.predicted"
|
||||
"col.intervals" "col.separator" "lty.predicted" "lty.intervals" "lty.separator" "plot.type" "main2" "par.fit" "grid"
|
||||
"panel" "cex" "dimen" "abbrev" "which" "caption" "sub.caption" "id.n" "labels.id" "cex.id" "qqline" "cook.levels"
|
||||
"add.smooth" "label.pos" "cex.caption" "rows" "levels" "conf" "absVal" "ci.lty" "xval" "do.points" "col.points" "cex.points"
|
||||
"col.hor" "col.vert" "lwd" "set.pars" "range.bars" "col.range" "xy.labels" "xy.lines" "nc" "yax.flip" "mar.multi" "oma.multi")))
|
||||
("print"
|
||||
(("base")
|
||||
(("x" . "") ("digits" . "NULL") ("quote" . "TRUE") ("na.print" . "NULL") ("print.gap" . "NULL") ("right" . "FALSE") ("max" . "NULL") ("useSource" . "TRUE") ("..." . ""))
|
||||
("x" "..." "digits" "signif.stars" "intercept" "tol" "se" "sort" "verbose" "indent" "style" ".bibstyle" "prefix" "vsep" "minlevel" "quote" "right" "row.names" "max" "na.print" "print.gap"
|
||||
"useSource" "diag" "upper" "justify" "title" "max.levels" "width" "steps" "showEnv" "newpage" "vp" "cutoff" "max.level" "give.attr" "units" "abbrCollate" "print.x" "deparse" "locale" "symbolic.cor"
|
||||
"loadings" "zero.print" "calendar"))))
|
||||
"Alist of cached arguments for very time consuming functions.")
|
||||
|
||||
|
||||
;;; HELP
|
||||
|
||||
(defun ess-R-get-object-help-string (sym)
|
||||
"Help string for ac."
|
||||
(let ((proc (ess-get-next-available-process)))
|
||||
(if (null proc)
|
||||
"No free ESS process found"
|
||||
(let ((buf (get-buffer-create " *ess-command-output*")))
|
||||
(when (string-match ":+\\(.*\\)" sym)
|
||||
(setq sym (match-string 1 sym)))
|
||||
(with-current-buffer (process-buffer proc)
|
||||
(ess-with-current-buffer buf
|
||||
(ess--flush-help-into-current-buffer sym nil t)))
|
||||
(with-current-buffer buf
|
||||
(ess-help-underline)
|
||||
(goto-char (point-min))
|
||||
(buffer-string))))))
|
||||
|
||||
(defun ess-R-get-arg-help-string (sym &optional proc)
|
||||
"Help string for ac."
|
||||
(setq sym (replace-regexp-in-string " *= *\\'" "" sym))
|
||||
(let ((proc (or proc (ess-get-next-available-process))))
|
||||
(if (null proc)
|
||||
"No free ESS process found"
|
||||
(let ((fun (car ess--funname.start)))
|
||||
(with-current-buffer (ess-command (format ".ess_arg_help('%s','%s')\n" sym fun)
|
||||
nil nil nil nil proc)
|
||||
(goto-char (point-min))
|
||||
(forward-line)
|
||||
(buffer-substring-no-properties (point) (point-max)))))))
|
||||
|
||||
|
||||
;;; COMPANY
|
||||
;;; http://company-mode.github.io/
|
||||
|
||||
(defun company-R-objects (command &optional arg &rest ignored)
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-R-objects))
|
||||
(prefix (unless (ess-inside-string-or-comment-p)
|
||||
(let ((start (ess-symbol-start)))
|
||||
(when start
|
||||
(buffer-substring-no-properties start (point))))))
|
||||
(candidates (let ((proc (ess-get-next-available-process)))
|
||||
(when proc
|
||||
(with-current-buffer (process-buffer proc)
|
||||
(all-completions arg (ess--get-cached-completions arg))))))
|
||||
(doc-buffer (company-doc-buffer (ess-R-get-object-help-string arg)))))
|
||||
|
||||
(defun company-R-args (command &optional arg &rest ignored)
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'company-R-args))
|
||||
(prefix (unless (ess-inside-string-or-comment-p)
|
||||
(let ((start (ess-arg-start)))
|
||||
(when start
|
||||
(let ((prefix (buffer-substring-no-properties start (point))))
|
||||
(if ess-company-arg-prefix-length
|
||||
(cons prefix (>= (length prefix)
|
||||
ess-company-arg-prefix-length))
|
||||
prefix))))))
|
||||
(candidates (let* ((proc (ess-get-next-available-process))
|
||||
(args (delete "..." (nth 2 (ess-function-arguments
|
||||
(car ess--funname.start) proc))))
|
||||
(args (mapcar (lambda (a) (concat a ess-R-argument-suffix))
|
||||
args)))
|
||||
(all-completions arg args)))
|
||||
(meta (let ((proc (ess-get-next-available-process)))
|
||||
(when (and proc
|
||||
(with-current-buffer (process-buffer proc)
|
||||
(not (file-remote-p default-directory))))
|
||||
;; fixme: ideally meta should be fetched with args
|
||||
(let ((doc (ess-R-get-arg-help-string arg proc)))
|
||||
(replace-regexp-in-string "^ +\\| +$" ""
|
||||
(replace-regexp-in-string "[ \t\n]+" " " doc))))))
|
||||
(sorted t)
|
||||
(require-match 'never)
|
||||
(doc-buffer (company-doc-buffer (ess-R-get-arg-help-string arg)))))
|
||||
|
||||
|
||||
;;; AC SOURCES
|
||||
;;; http://cx4a.org/software/auto-complete/index.html
|
||||
|
||||
(defvar ac-source-R
|
||||
'((prefix . ess-ac-start)
|
||||
;; (requires . 0) ::)
|
||||
(candidates . ess-ac-candidates)
|
||||
;; (action . ess-ac-action-args) ;; interfere with ac-fallback mechanism on RET (which is extremely annoing in inferior buffers)
|
||||
(document . ess-ac-help))
|
||||
"Combined ad-completion source for R function arguments and R objects")
|
||||
|
||||
(defun ess-ac-start ()
|
||||
(when (ess-process-live-p)
|
||||
(or (ess-arg-start)
|
||||
(ess-symbol-start))))
|
||||
|
||||
(defun ess-ac-candidates ()
|
||||
"OBJECTS + ARGS"
|
||||
(let ((args (ess-ac-args)))
|
||||
;; sort of intrusive but right
|
||||
(if (and ac-auto-start
|
||||
(< (length ac-prefix) ac-auto-start))
|
||||
args
|
||||
(if args
|
||||
(append args (ess-ac-objects t))
|
||||
(ess-ac-objects)))))
|
||||
|
||||
(defun ess-ac-help (sym)
|
||||
(if (string-match-p "= *\\'" sym)
|
||||
(ess-R-get-arg-help-string sym)
|
||||
(ess-R-get-object-help-string sym)))
|
||||
|
||||
;; OBJECTS
|
||||
(defvar ac-source-R-objects
|
||||
'((prefix . ess-symbol-start)
|
||||
;; (requires . 2)
|
||||
(candidates . ess-ac-objects)
|
||||
(document . ess-R-get-object-help-string))
|
||||
"Auto-completion source for R objects")
|
||||
|
||||
(defun ess-ac-objects (&optional no-kill)
|
||||
"Get all cached objects"
|
||||
(let ((aprf ac-prefix))
|
||||
(when (and aprf (ess-process-live-p))
|
||||
(unless no-kill ;; workaround
|
||||
(kill-local-variable 'ac-use-comphist))
|
||||
(ess--get-cached-completions aprf ac-point))))
|
||||
|
||||
;; ARGS
|
||||
(defvar ac-source-R-args
|
||||
'((prefix . ess-arg-start)
|
||||
;; (requires . 0)
|
||||
(candidates . ess-ac-args)
|
||||
;; (action . ess-ac-action-args)
|
||||
(document . ess-R-get-arg-help-string))
|
||||
"Auto-completion source for R function arguments")
|
||||
|
||||
(defun ess-ac-args ()
|
||||
"Get the args of the function when inside parentheses."
|
||||
(when (and ess--funname.start ;; set in a call to ess-arg-start
|
||||
(ess-process-live-p))
|
||||
(let ((args (nth 2 (ess-function-arguments (car ess--funname.start)))))
|
||||
(if args
|
||||
(set (make-local-variable 'ac-use-comphist) nil)
|
||||
(kill-local-variable 'ac-use-comphist))
|
||||
(delete "..." args)
|
||||
(mapcar (lambda (a) (concat a ess-R-argument-suffix))
|
||||
args))))
|
||||
|
||||
(defvar ess--ac-help-arg-command
|
||||
"getArgHelp('%s','%s')")
|
||||
|
||||
(provide 'ess-r-completion)
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-completion.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-completion.elc
Normal file
Binary file not shown.
1849
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-d.el
Normal file
1849
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-d.el
Normal file
File diff suppressed because it is too large
Load Diff
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-d.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-d.elc
Normal file
Binary file not shown.
193
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-gui.el
Normal file
193
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-gui.el
Normal file
@@ -0,0 +1,193 @@
|
||||
;;; ess-r-gui.el --- Run Rgui on Windows as an inferior Emacs process
|
||||
|
||||
;; Copyright (C) 2008 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: Richard M. Heiberger <rmh@temple.edu>
|
||||
;; Created: 10 Mar 2008
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; This file is part of ESS
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;In Rgui:
|
||||
;> library(tcltk2) ## >= 1.0-6
|
||||
;> .ess.command <- function() source("c:/temp/ess-tempfile.R", echo=TRUE)
|
||||
;> tclFun(.ess.command)
|
||||
;[1] "R_call 0203A04C"
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'ess-dde) ;; needed here because we override several definitions
|
||||
|
||||
(defun ess-ddeclient-p ()
|
||||
"Returns the name of the ddeclient iff `ess-local-process-name'
|
||||
is associated with an `inferior-ess-ddeclient', and nil if the
|
||||
ess-process is running as an ordinary inferior process. Alway
|
||||
nil on Unix machines."
|
||||
(interactive)
|
||||
(if ess-microsoft-p
|
||||
(let ((ess-ddeclient (ess-get-process-variable 'inferior-ess-ddeclient)))
|
||||
(if (not (equal ess-ddeclient (default-value 'inferior-ess-ddeclient)))
|
||||
ess-ddeclient))))
|
||||
|
||||
(defun ess-eval-region-execdde (start end even-empty)
|
||||
"Loop through lines in region and send them to ESS via execdde."
|
||||
(setq ;; set the following variables for the current ddeESS process.
|
||||
inferior-ess-ddeclient (ess-get-process-variable 'inferior-ess-ddeclient)
|
||||
)
|
||||
(write-region start end ess-command-file nil nil 'no-message)
|
||||
(call-process-shell-command
|
||||
(concat inferior-ess-execdde ess-rgui-command))
|
||||
)
|
||||
|
||||
|
||||
(if (not (getenv "R_HOME")) (setenv "R_HOME" "c:/progra~1/R/R-2.6.1"))
|
||||
;; ^^^^^^^^^ FIXME! do something better
|
||||
(defvar inferior-Rgui-program-name "cmd" "Rgui program name")
|
||||
(defvar Rgui-pager "emacsclientw.exe" "Rgui pager program")
|
||||
(defvar ess-command-file "c:/temp/ess-tempfile.R"
|
||||
"file name for communication with Rgui")
|
||||
(defvar inferior-ess-execdde
|
||||
(concat (getenv "R_HOME") "/site-library/tcltk2/bin/execdde.exe")
|
||||
"Full pathname to execdde executable")
|
||||
(defvar ess-rgui-command " -s TclEval -t R -c .ess.command > NUL"
|
||||
"command to inferior-ess-execdde that will make Rgui read the command file")
|
||||
(defvar inferior-ess-language-start-rgui
|
||||
"options(chmhelp=FALSE, htmlhelp=FALSE, help_type='text'); require(tcltk2)"
|
||||
"additional arguments to rgui")
|
||||
|
||||
(defun ess-eval-region-ddeclient (start end even-empty)
|
||||
"Loop through lines in region and send them to ESS via ddeclient."
|
||||
(setq ;; set the following variables for the current ddeESS process.
|
||||
inferior-ess-ddeclient (ess-get-process-variable 'inferior-ess-ddeclient)
|
||||
inferior-ess-client-name (ess-get-process-variable 'inferior-ess-client-name)
|
||||
inferior-ess-client-command (ess-get-process-variable 'inferior-ess-client-command))
|
||||
(narrow-to-region start end)
|
||||
(goto-char (point-min))
|
||||
|
||||
(if (equal inferior-ess-ddeclient "execdde")
|
||||
(ess-eval-region-execdde start end even-empty)
|
||||
|
||||
(let ((beg))
|
||||
(while (or (< (point) (point-max))
|
||||
(and (= 1 (point-max)) even-empty))
|
||||
(setq beg (point))
|
||||
(end-of-line)
|
||||
;; call-process-region won't send over a 0-character line.
|
||||
;; We go outside the loop to create a 1-character line " " in the
|
||||
;; *ESS-temporary* buffer
|
||||
(if (= beg (point)) ;; do empty line outside loop
|
||||
(ess-eval-linewise-ddeclient " " nil 'eob t)
|
||||
(call-process-region
|
||||
beg (point)
|
||||
inferior-ess-ddeclient nil nil nil
|
||||
inferior-ess-client-name inferior-ess-client-command))
|
||||
(forward-line 1))))
|
||||
(widen))
|
||||
|
||||
|
||||
|
||||
(defvar Rgui-customize-alist
|
||||
(append
|
||||
'((ess-local-customize-alist . 'Rgui-customize-alist)
|
||||
(ess-dialect . "R")
|
||||
(ess-suffix . "R")
|
||||
(ess-dump-filename-template . (ess-replace-regexp-in-string
|
||||
"S$" ess-suffix ; in the one from custom:
|
||||
ess-dump-filename-template-proto))
|
||||
(ess-mode-syntax-table . R-syntax-table)
|
||||
(ess-mode-editing-alist . R-editing-alist)
|
||||
(ess-change-sp-regexp . ess-R-change-sp-regexp)
|
||||
(ess-help-sec-regex . ess-help-R-sec-regex)
|
||||
(ess-help-sec-keys-alist . ess-help-R-sec-keys-alist)
|
||||
(ess-loop-timeout . ess-S-loop-timeout);fixme: dialect spec.
|
||||
(ess-cmd-delay . ess-R-cmd-delay)
|
||||
(ess-function-pattern . ess-R-function-pattern)
|
||||
(ess-object-name-db-file . "ess-r-namedb.el" )
|
||||
(inferior-ess-program . inferior-Rgui-program-name)
|
||||
(inferior-ess-objects-command . inferior-R-objects-command)
|
||||
(inferior-ess-font-lock-keywords . 'inferior-R-font-lock-keywords)
|
||||
(inferior-ess-search-list-command . "search()\n")
|
||||
(inferior-ess-help-command . "help(\"%s\")\n")
|
||||
(inferior-ess-help-filetype . nil) ;; "chm") ;;?
|
||||
(inferior-ess-exit-command . "q()")
|
||||
(inferior-ess-exit-prompt . "Save workspace image? [y/n/c]: ")
|
||||
(inferior-ess-primary-prompt . "\\([A-Z/][][A-Za-z0-9./]*\\)*[>$] ")
|
||||
(inferior-ess-secondary-prompt . "+ ?")
|
||||
;;harmful for shell-mode's C-a: -- but "necessary" for ESS-help?
|
||||
(inferior-ess-start-file . nil) ;; "~/.ess-R"
|
||||
(inferior-ess-start-args . "")
|
||||
(inferior-ess-ddeclient . "execdde")
|
||||
(ess-STERM . "ddeSS")
|
||||
(ess-editor . R-editor)
|
||||
(ess-pager . Rgui-pager)
|
||||
)
|
||||
S-common-cust-alist)
|
||||
"Variables to customize for Rgui")
|
||||
|
||||
|
||||
(defun Rgui (&optional proc-name)
|
||||
"Call 'Rgui for Windows'. Put R in an independent MS-Window (R
|
||||
persists even if the '(ddeESS [R])' window is killed in emacs).
|
||||
Do this by creating a comint process that calls cmd. This is a
|
||||
placeholder buffer with mode '(ddeESS [R])'. Commands sent from
|
||||
an (ESS[S] [R]) buffer to this process will be sourced into the
|
||||
independent Rgui R Console."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(setq ess-customize-alist Rgui-customize-alist)
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "\n(Rgui): ess-dialect=%s, buf=%s\n" ess-dialect
|
||||
(current-buffer)))
|
||||
(setq ess-customize-alist ; change inferior-ess-primary-prompt
|
||||
(append ess-customize-alist '((inferior-ess-primary-prompt . "^"))))
|
||||
(let ((default-ddeclient (default-value 'inferior-ess-ddeclient)))
|
||||
(cd (w32-short-file-name (directory-file-name default-directory)))
|
||||
;; (setenv "S_PROJ" default-directory)
|
||||
(setq-default inferior-ess-ddeclient "execdde")
|
||||
(inferior-ess)
|
||||
(setq-default inferior-ess-ddeclient default-ddeclient)
|
||||
(sleep-for 2) ; need to wait, else working too fast!
|
||||
)
|
||||
(setq comint-process-echoes nil)
|
||||
|
||||
;; *R* buffer
|
||||
(goto-char (point-min))
|
||||
(insert
|
||||
"This is a placeholder buffer. You can't type anything here.\n
|
||||
You may ignore the 'options' error in this buffer.\n\n")
|
||||
(goto-char (point-max))
|
||||
(set-buffer-process-coding-system 'raw-text-dos 'raw-text-unix)
|
||||
(setq buffer-read-only t) ; force buffer to be read-only
|
||||
(setq mode-name "ddeESS")
|
||||
|
||||
;; initialization
|
||||
(set-buffer (find-file-noselect ess-command-file 'nowarn))
|
||||
(erase-buffer)
|
||||
(setq ;; set the following variables for the current ddeESS process.
|
||||
inferior-ess-language-start (ess-get-process-variable 'inferior-ess-language-start))
|
||||
(if inferior-ess-language-start
|
||||
(insert inferior-ess-language-start))
|
||||
(if inferior-ess-language-start-rgui
|
||||
(insert (concat "\n" inferior-ess-language-start-rgui)))
|
||||
(save-buffer 0)
|
||||
(call-process-shell-command
|
||||
(concat inferior-ess-execdde ess-rgui-command))
|
||||
))
|
||||
|
||||
;;; ess-r-gui.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-gui.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-gui.elc
Normal file
Binary file not shown.
1008
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-syntax.el
Normal file
1008
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-syntax.el
Normal file
File diff suppressed because it is too large
Load Diff
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-syntax.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-r-syntax.elc
Normal file
Binary file not shown.
542
.emacs.d/elpa/ess-20160208.453/lisp/ess-rd.el
Normal file
542
.emacs.d/elpa/ess-20160208.453/lisp/ess-rd.el
Normal file
@@ -0,0 +1,542 @@
|
||||
;; ess-rd.el --- Support for editing R documentation (Rd) source
|
||||
|
||||
;; Copyright (C) 1997--2005 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: KH <Kurt.Hornik@ci.tuwien.ac.at>
|
||||
;; Created: 25 July 1997
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; This file is part of ESS (Emacs Speaks Statistics).
|
||||
|
||||
;; This file is free software; you may redistribute it and/or modify it
|
||||
;; under the terms of the GNU General Public License as published by the
|
||||
;; Free Software Foundation; either version 2, or (at your option) any
|
||||
;; later version.
|
||||
;;
|
||||
;; This is distributed in the hope that it will be useful, but WITHOUT
|
||||
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
;; for more details.
|
||||
;;
|
||||
;; A copy of the GNU General Public License is available on the World
|
||||
;; Wide Web at http://www.gnu.org/copyleft/gpl.html. You can also
|
||||
;; obtain it by writing to the Free Software Foundation, Inc., 675 Mass
|
||||
;; Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; To stave off byte compiler errors
|
||||
(eval-when-compile (require 'ess-help))
|
||||
|
||||
(defvar essddr-version "0.9-1"
|
||||
"Current version of ess-rd.el.")
|
||||
|
||||
(defvar essddr-maintainer-address
|
||||
"ESS Core Team <ess-core@r-project.org>"
|
||||
"Current maintainer of ess-rd.el.")
|
||||
|
||||
(defun Rd-active-mark () nil) ;silence compiler.
|
||||
(if (featurep 'xemacs)
|
||||
;; Special support for XEmacs (curtesy of auctex):
|
||||
(defun Rd-active-mark ()
|
||||
(and zmacs-regions (mark)))
|
||||
|
||||
;; else: special support for GNU Emacs
|
||||
(defun Rd-active-mark ()
|
||||
(and transient-mark-mode mark-active))
|
||||
)
|
||||
|
||||
(autoload 'ess-eval-region "ess-inf" "[autoload]" t)
|
||||
(autoload 'ess-eval-line-and-step "ess-inf" "[autoload]" t)
|
||||
(autoload 'ess-switch-process "ess-inf" "[autoload]" t)
|
||||
(autoload 'ess-switch-to-ESS "ess-inf" "[autoload]" t)
|
||||
(autoload 'ess-switch-to-end-of-ESS "ess-inf" "[autoload]" t)
|
||||
|
||||
(autoload 'ess-help-mode "ess-help" "[autoload]" t)
|
||||
(autoload 'ess-help-underline "ess-help" "[autoload]" t)
|
||||
|
||||
(defvar Rd-mode-abbrev-table nil
|
||||
"Abbrev table for R documentation keywords.
|
||||
All Rd mode abbrevs start with a grave accent (`).")
|
||||
(if Rd-mode-abbrev-table
|
||||
()
|
||||
(define-abbrev-table 'Rd-mode-abbrev-table ())
|
||||
(define-abbrev Rd-mode-abbrev-table "`ag" "\\arguments")
|
||||
(define-abbrev Rd-mode-abbrev-table "`al" "\\alias")
|
||||
(define-abbrev Rd-mode-abbrev-table "`au" "\\author")
|
||||
(define-abbrev Rd-mode-abbrev-table "`bf" "\\bold")
|
||||
(define-abbrev Rd-mode-abbrev-table "`co" "\\code")
|
||||
(define-abbrev Rd-mode-abbrev-table "`de" "\\describe")
|
||||
(define-abbrev Rd-mode-abbrev-table "`dn" "\\description")
|
||||
(define-abbrev Rd-mode-abbrev-table "`dt" "\\details")
|
||||
(define-abbrev Rd-mode-abbrev-table "`em" "\\emph")
|
||||
(define-abbrev Rd-mode-abbrev-table "`en" "\\enumerate")
|
||||
(define-abbrev Rd-mode-abbrev-table "`ex" "\\examples")
|
||||
(define-abbrev Rd-mode-abbrev-table "`fi" "\\file")
|
||||
(define-abbrev Rd-mode-abbrev-table "`fo" "\\format")
|
||||
(define-abbrev Rd-mode-abbrev-table "`it" "\\item")
|
||||
(define-abbrev Rd-mode-abbrev-table "`iz" "\\itemize")
|
||||
(define-abbrev Rd-mode-abbrev-table "`kw" "\\keyword")
|
||||
(define-abbrev Rd-mode-abbrev-table "`li" "\\link")
|
||||
(define-abbrev Rd-mode-abbrev-table "`me" "\\method")
|
||||
(define-abbrev Rd-mode-abbrev-table "`na" "\\name")
|
||||
(define-abbrev Rd-mode-abbrev-table "`no" "\\note")
|
||||
(define-abbrev Rd-mode-abbrev-table "`re" "\\references")
|
||||
(define-abbrev Rd-mode-abbrev-table "`sa" "\\seealso")
|
||||
(define-abbrev Rd-mode-abbrev-table "`se" "\\section")
|
||||
(define-abbrev Rd-mode-abbrev-table "`so" "\\source")
|
||||
(define-abbrev Rd-mode-abbrev-table "`ss" "\\subsection")
|
||||
(define-abbrev Rd-mode-abbrev-table "`sy" "\\synopsis")
|
||||
(define-abbrev Rd-mode-abbrev-table "`ta" "\\tabular")
|
||||
(define-abbrev Rd-mode-abbrev-table "`ti" "\\title")
|
||||
(define-abbrev Rd-mode-abbrev-table "`us" "\\usage")
|
||||
(define-abbrev Rd-mode-abbrev-table "`va" "\\value"))
|
||||
|
||||
(defvar Rd-mode-syntax-table nil
|
||||
"Syntax table for Rd mode.")
|
||||
(if Rd-mode-syntax-table
|
||||
()
|
||||
(setq Rd-mode-syntax-table (copy-syntax-table text-mode-syntax-table))
|
||||
(modify-syntax-entry ?\\ "\\" Rd-mode-syntax-table)
|
||||
(modify-syntax-entry ?\{ "(}" Rd-mode-syntax-table)
|
||||
(modify-syntax-entry ?\} "){" Rd-mode-syntax-table)
|
||||
;; Nice for editing, not for parsing ...
|
||||
(modify-syntax-entry ?\( "()" Rd-mode-syntax-table)
|
||||
(modify-syntax-entry ?\) ")(" Rd-mode-syntax-table)
|
||||
(modify-syntax-entry ?\[ "(]" Rd-mode-syntax-table)
|
||||
(modify-syntax-entry ?\] ")[" Rd-mode-syntax-table)
|
||||
;; To get strings right
|
||||
;; (modify-syntax-entry ?\' "\"" Rd-mode-syntax-table)
|
||||
(modify-syntax-entry ?\" "\"" Rd-mode-syntax-table)
|
||||
;; To make abbrevs starting with a grave accent work ...
|
||||
(modify-syntax-entry ?\` "w" Rd-mode-syntax-table)
|
||||
;; Comments
|
||||
(modify-syntax-entry ?\% "<" Rd-mode-syntax-table)
|
||||
(modify-syntax-entry ?\n ">" Rd-mode-syntax-table))
|
||||
|
||||
(defvar Rd-mode-parse-syntax-table nil
|
||||
"Syntax table for parsing Rd mode.")
|
||||
(if Rd-mode-parse-syntax-table
|
||||
()
|
||||
(setq Rd-mode-parse-syntax-table
|
||||
(copy-syntax-table Rd-mode-syntax-table))
|
||||
;; To make parse-partial-sexps do the thing we want for computing
|
||||
;; indentations
|
||||
(modify-syntax-entry ?\( "_" Rd-mode-parse-syntax-table)
|
||||
(modify-syntax-entry ?\) "_" Rd-mode-parse-syntax-table)
|
||||
(modify-syntax-entry ?\[ "_" Rd-mode-parse-syntax-table)
|
||||
(modify-syntax-entry ?\] "_" Rd-mode-parse-syntax-table))
|
||||
|
||||
(defvar Rd-section-names
|
||||
'("Rdversion" "arguments" "alias" "author" "concept" "describe" "description"
|
||||
"details" "docType" "encoding" "enumerate" "examples" "format"
|
||||
"itemize" "keyword" "name" "note" "preformatted" "references"
|
||||
"seealso" "section" "source" "subsection" "synopsis"
|
||||
"tabular" "title" "usage"
|
||||
"value"))
|
||||
|
||||
(defvar Rd-keywords
|
||||
'(
|
||||
;; the next two lines: only valid in R <= 2.8.1
|
||||
;; commented out on 2011-01-14 for ESS version 5.13:
|
||||
;; "Alpha" "Gamma" "alpha" "beta" "epsilon" "lambda" "mu" "pi" "sigma"
|
||||
;; "ge" "le" "left" "right"
|
||||
;;
|
||||
"CRANpkg" "R" "RdOpts" "S3method" "S4method" "Sexpr" "acronym"
|
||||
"bold" "cite" "code" "command" "cr" "dQuote" "deqn" "dfn" "dontrun"
|
||||
"dontshow" "donttest" "dots" "email" "emph" "enc" "env" "eqn" "figure" "file"
|
||||
"href" "if" "ifelse"
|
||||
"item" "kbd" "ldots" "linkS4class" "link" "method"
|
||||
"newcommand" "option" "out"
|
||||
"pkg" "sQuote" "renewcommand"
|
||||
"samp" "strong" "tab" "url" "var" "verb"
|
||||
))
|
||||
|
||||
;; Need to fix Rd-bold-face problem.
|
||||
;;
|
||||
;; (defvar Rd-bold-face 'bold)
|
||||
;(defvar Rd-bold-face nil)
|
||||
;(make-face Rd-bold-face "R documentation bold face")
|
||||
;(make-face-bold Rd-bold-face
|
||||
|
||||
(defvar Rd-font-lock-keywords
|
||||
(list
|
||||
(cons
|
||||
(concat "\\\\\\("
|
||||
(mapconcat 'identity Rd-section-names "\\|")
|
||||
"\\>\\)")
|
||||
'font-lock-reference-face) ; Rd-bold-face
|
||||
(cons
|
||||
(concat "\\\\\\("
|
||||
(mapconcat 'identity Rd-keywords "\\|")
|
||||
"\\>\\)")
|
||||
'font-lock-keyword-face)
|
||||
'("^#\\(ifn?def\\)\\s-+\\(\\sw+\\)"
|
||||
(1 font-lock-builtin-face)
|
||||
(2 font-lock-variable-name-face nil t))
|
||||
'("^#\\(endif\\)" 1 font-lock-builtin-face))
|
||||
"Additional Rd expressions to highlight.")
|
||||
|
||||
(defvar Rd-indent-level 2
|
||||
"*Indentation of Rd code with respect to containing blocks.")
|
||||
|
||||
(defvar Rd-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map "\t" 'indent-according-to-mode)
|
||||
(define-key map "\C-j" 'reindent-then-newline-and-indent)
|
||||
(define-key map "\C-m" 'reindent-then-newline-and-indent)
|
||||
(define-key map "\C-c\C-p" 'Rd-preview-help)
|
||||
(define-key map "\C-c\C-j" 'Rd-mode-insert-item)
|
||||
(define-key map "\C-c\C-e" 'Rd-mode-insert-skeleton)
|
||||
(define-key map "\C-c\C-f" 'Rd-font)
|
||||
;; ^C^F ^E : \emph{ . }
|
||||
;; ^C^F ^C : \code{ . }
|
||||
;; ^C^F ^L : \link{ . }
|
||||
;; ^C^F L : \code{\link{ . }} etc
|
||||
(define-key map "\C-c\C-s" 'Rd-mode-insert-section)
|
||||
(define-key map "\C-ch" 'ess-handy-commands)
|
||||
(define-key map "\C-c\C-n" 'ess-eval-line-and-step)
|
||||
(define-key map "\C-c\C-r" 'ess-eval-region)
|
||||
(define-key map "\C-c\C-c" 'ess-eval-region-or-function-or-paragraph-and-step)
|
||||
(define-key map "\C-\M-x" 'ess-eval-region-or-function-or-paragraph)
|
||||
(define-key map "\C-c\C-v" 'ess-display-help-on-object)
|
||||
(define-key map "\C-c\C-w" 'ess-switch-process); is on C-c C-s in ess-mode..
|
||||
(define-key map "\C-c\C-y" 'ess-switch-to-ESS)
|
||||
(define-key map "\C-c\C-z" 'ess-switch-to-end-of-ESS)
|
||||
map)
|
||||
"Keymap used in Rd mode.")
|
||||
|
||||
(defvar Rd-mode-menu
|
||||
(list "Rd"
|
||||
["Markup [word]" Rd-font t]
|
||||
["Insert Item" Rd-mode-insert-item t]
|
||||
["Insert Section" Rd-mode-insert-section t]
|
||||
["Insert Skeleton" Rd-mode-insert-skeleton t]
|
||||
"-"
|
||||
["Preview" Rd-preview-help t]
|
||||
"-"
|
||||
["Eval Line" ess-eval-line-and-step t]
|
||||
["Eval Region" ess-eval-region t]
|
||||
["Switch to ESS Process" ess-switch-to-ESS t]
|
||||
["Switch the ESS Process" ess-switch-process t]
|
||||
["Switch to end{ESS Pr}" ess-switch-to-end-of-ESS t]
|
||||
"-"
|
||||
["Toggle Abbrev Mode" abbrev-mode t]
|
||||
["Toggle Auto-Fill Mode" auto-fill-mode t]
|
||||
"-"
|
||||
["Submit Bug Report" Rd-submit-bug-report t]
|
||||
"-"
|
||||
["Describe Rd Mode" Rd-describe-major-mode t])
|
||||
"Menu used in Rd mode.")
|
||||
|
||||
(defvar Rd-mode-hook nil
|
||||
"*Hook to be run when Rd mode is entered.")
|
||||
|
||||
(defvar Rd-to-help-command "R CMD Rd2txt"
|
||||
"*Shell command for converting R documentation source to help text.")
|
||||
|
||||
|
||||
(defvar Rd-font-list
|
||||
'((?\C-b "\\bold{" "}")
|
||||
(?\C-c "\\code{" "}")
|
||||
(?\C-e "\\emph{" "}")
|
||||
(?\C-l "\\link{" "}")
|
||||
(?l "\\code{\\link{" "}}")
|
||||
(?\C-m "\\email{" "}")
|
||||
(?\C-q "\\eqn{" "}")
|
||||
(?\C-u "\\url{" "}")
|
||||
)
|
||||
"List of ``fonts'' used by Rd-font.
|
||||
|
||||
Each entry is a list.
|
||||
The first element is the key to activate the font.
|
||||
The second element is the string to insert before point, and the third
|
||||
element is the string to insert after point."
|
||||
)
|
||||
|
||||
|
||||
;;;###autoload
|
||||
(defun Rd-mode ()
|
||||
"Major mode for editing R documentation source files.
|
||||
|
||||
This mode makes it easier to write R documentation by helping with
|
||||
indentation, doing some of the typing for you (with Abbrev mode) and by
|
||||
showing keywords, strings, etc. in different faces (with Font Lock mode
|
||||
on terminals that support it).
|
||||
|
||||
Type \\[list-abbrevs] to display the built-in abbrevs for Rd keywords.
|
||||
|
||||
Keybindings
|
||||
===========
|
||||
|
||||
\\{Rd-mode-map}
|
||||
|
||||
Variables you can use to customize Rd mode
|
||||
==========================================
|
||||
|
||||
`Rd-indent-level'
|
||||
Indentation of Rd code with respect to containing blocks.
|
||||
Default is 2.
|
||||
|
||||
Turning on Rd mode runs the hook `Rd-mode-hook'.
|
||||
|
||||
To automatically turn on the abbrev(iate) features, add the
|
||||
following lines to your `.emacs' file:
|
||||
|
||||
(add-hook 'Rd-mode-hook
|
||||
(lambda ()
|
||||
(abbrev-mode 1)))
|
||||
"
|
||||
|
||||
(interactive)
|
||||
(text-mode)
|
||||
(kill-all-local-variables)
|
||||
(ess-setq-vars-local R-customize-alist) ;same functionality is available as in R buffers
|
||||
(use-local-map Rd-mode-map)
|
||||
(setq mode-name "Rd")
|
||||
(setq major-mode 'Rd-mode)
|
||||
(setq local-abbrev-table Rd-mode-abbrev-table)
|
||||
(set-syntax-table Rd-mode-syntax-table)
|
||||
|
||||
(set (make-local-variable 'indent-line-function) 'Rd-mode-indent-line)
|
||||
(set (make-local-variable 'fill-column) 72)
|
||||
(set (make-local-variable 'comment-start-skip) "\\s<+\\s-*")
|
||||
(set (make-local-variable 'comment-start) "% ")
|
||||
(set (make-local-variable 'comment-end) "")
|
||||
(set (make-local-variable 'font-lock-defaults)
|
||||
'(Rd-font-lock-keywords nil nil))
|
||||
;; (set (make-local-variable 'parse-sexp-ignore-comments) t)
|
||||
|
||||
(require 'easymenu)
|
||||
(easy-menu-define Rd-mode-menu-map Rd-mode-map
|
||||
"Menu keymap for Rd mode." Rd-mode-menu)
|
||||
(easy-menu-add Rd-mode-menu-map Rd-mode-map)
|
||||
|
||||
(turn-on-auto-fill)
|
||||
(message "Rd mode version %s" essddr-version)
|
||||
(setq ess-language "S" ess-dialect "R"); (buffer local)
|
||||
(run-hooks 'Rd-mode-hook))
|
||||
|
||||
;; FIXME: The following should be moved to ess-utils.el, no? (MM thinks)
|
||||
(defun ess-point (position)
|
||||
"Returns the value of point at certain positions."
|
||||
(save-excursion
|
||||
(cond
|
||||
((eq position 'bol) (beginning-of-line))
|
||||
((eq position 'eol) (end-of-line))
|
||||
((eq position 'boi) (back-to-indentation))
|
||||
((eq position 'bonl) (forward-line 1))
|
||||
((eq position 'bopl) (forward-line -1))
|
||||
(t (error "unknown buffer position requested: %s" position)))
|
||||
(point)))
|
||||
|
||||
(defun Rd-describe-major-mode ()
|
||||
"Describe the current major mode."
|
||||
(interactive)
|
||||
(describe-function major-mode))
|
||||
|
||||
(defun Rd-mode-in-verbatim-p ()
|
||||
(let ((pos (point)))
|
||||
(save-excursion
|
||||
(if (and (re-search-backward
|
||||
"\\\\\\(usage\\|examples\\|synopsis\\)" nil t)
|
||||
(re-search-forward "\\s(" nil t))
|
||||
(condition-case ()
|
||||
(progn
|
||||
(up-list 1)
|
||||
(< pos (point)))
|
||||
(error t))
|
||||
nil))))
|
||||
|
||||
(defun Rd-mode-in-preprocessor-line-p ()
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(looking-at "[ \t]*#\\(ifdef\\|endif\\)")))
|
||||
|
||||
(defun Rd-mode-calculate-indent ()
|
||||
"Return appropriate indentation for current line in Rd mode."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(cond
|
||||
((Rd-mode-in-verbatim-p)
|
||||
;; Don't do anything in verbatims
|
||||
nil)
|
||||
((Rd-mode-in-preprocessor-line-p)
|
||||
;; Indent to 0
|
||||
0)
|
||||
(t
|
||||
(let ((p (progn
|
||||
(re-search-forward "[ \t]*\\s)*" (ess-point 'eol) t)
|
||||
(point))))
|
||||
(if (or (< (forward-line -1) 0)
|
||||
(Rd-mode-in-verbatim-p))
|
||||
0
|
||||
(set-syntax-table Rd-mode-parse-syntax-table)
|
||||
(while (and (or (looking-at "[ \t]*$")
|
||||
(Rd-mode-in-preprocessor-line-p))
|
||||
(not (bobp)))
|
||||
(forward-line -1))
|
||||
(re-search-forward "[ \t]*\\s)*" (ess-point 'eol) t)
|
||||
(prog1
|
||||
(+ (current-indentation)
|
||||
(* (car (parse-partial-sexp (point) p))
|
||||
Rd-indent-level))
|
||||
(set-syntax-table Rd-mode-syntax-table))))))))
|
||||
|
||||
(defun Rd-mode-indent-line ()
|
||||
"Indent current line as Rd source."
|
||||
(interactive)
|
||||
(let ((ic (Rd-mode-calculate-indent))
|
||||
(rp (- (current-column) (current-indentation))))
|
||||
(if ic ; Not inside a verbatim
|
||||
(if (< ic 0)
|
||||
(error "Unmatched parenthesis")
|
||||
(indent-line-to ic)
|
||||
(if (> rp 0)
|
||||
(move-to-column (+ ic rp)))))))
|
||||
|
||||
(defun Rd-mode-insert-item ()
|
||||
(interactive)
|
||||
(reindent-then-newline-and-indent)
|
||||
(insert "\\item{")
|
||||
)
|
||||
|
||||
(defun Rd-mode-insert-section ()
|
||||
(interactive)
|
||||
(let ((s (ess-completing-read
|
||||
"Insert section: "
|
||||
(mapcar (lambda (x) (cons x x)) Rd-section-names)
|
||||
nil t)))
|
||||
(if (string= s "")
|
||||
(progn (insert "\\section{}{") (backward-char 2))
|
||||
(insert (format "\\%s{" s)))))
|
||||
|
||||
(defun Rd-mode-insert-skeleton ()
|
||||
(interactive)
|
||||
;; Hmm: in theory this should be kept in sync with prompt()
|
||||
;; --- maybe using prompt() [or promptClass()...] would be better anyway?!
|
||||
(insert "\\name{}\n")
|
||||
(insert "\\alias{}\n")
|
||||
(insert "\\title{}\n")
|
||||
(insert "\\description{\n}\n")
|
||||
(insert "\\usage{\n}\n")
|
||||
(insert "\\arguments{\n}\n")
|
||||
(insert "\\value{\n}\n")
|
||||
(insert "\\details{\n}\n")
|
||||
(insert "\\references{\n}\n")
|
||||
(insert "\\seealso{\n}\n")
|
||||
(insert "\\examples{\n}\n")
|
||||
(insert "\\author{}\n")
|
||||
(insert "\\keyword{}\n"))
|
||||
|
||||
;; This is an `easy' version of (defun TeX-font ..) in AUCtex's tex.el ;
|
||||
;; see TeX-font-list and also LaTeX-font-list in latex.el
|
||||
|
||||
(defun Rd-font (what)
|
||||
"Insert template for font command.
|
||||
WHAT determines the font to use, as specified by `Rd-font-list'."
|
||||
(interactive "c")
|
||||
;;TeX had : (Rd-update-style)
|
||||
(let* ((entry (assoc what Rd-font-list))
|
||||
(before (nth 1 entry))
|
||||
(after (nth 2 entry)))
|
||||
(cond ((null entry) ;; help on possibilities :
|
||||
(let ((help
|
||||
(concat
|
||||
"Rd Markup (available from C-c C-f):\n\n\t"
|
||||
"KEY Rd-Markup\n\n"
|
||||
(mapconcat
|
||||
(lambda (entry)
|
||||
;; A textual description of an ENTRY in TeX-font-list.
|
||||
(concat (format "%11s "
|
||||
(key-description
|
||||
(char-to-string (nth 0 entry))))
|
||||
(format "%14s %-3s"
|
||||
(nth 1 entry) (nth 2 entry))))
|
||||
Rd-font-list "\n"))))
|
||||
(with-output-to-temp-buffer "*Help*"
|
||||
(set-buffer "*Help*")
|
||||
(insert help))))
|
||||
|
||||
((Rd-active-mark)
|
||||
(save-excursion
|
||||
(cond ((> (mark) (point))
|
||||
(insert before)
|
||||
(goto-char (mark))
|
||||
(insert after))
|
||||
(t
|
||||
(insert after)
|
||||
(goto-char (mark))
|
||||
(insert before)))))
|
||||
(t
|
||||
(insert before)
|
||||
(save-excursion
|
||||
(insert after))))))
|
||||
|
||||
(defun Rd-preview-help (&optional via-shell)
|
||||
"Preview the current Rd buffer contents as help.
|
||||
If optional VIA-SHELL is set, using `Rd-to-help-command'.
|
||||
If the current buffer is not associated with a file, create a
|
||||
temporary one in `temporary-file-directory'.
|
||||
"
|
||||
(interactive "P")
|
||||
(require 'ess-help)
|
||||
(let ((file buffer-file-name)
|
||||
(pbuf (get-buffer-create "R Help Preview"))
|
||||
del-p)
|
||||
(unless file
|
||||
(setq file (make-temp-file "RD_" nil ".Rd"))
|
||||
(write-region (point-min) (point-max) file)
|
||||
(setq del-p t))
|
||||
|
||||
(if via-shell ;; FIXME eventually get rid of this option
|
||||
;; only method in ESS <= 14.09 -- calls "R" even if in "R-devel"; slower
|
||||
(let ((shcmd (format "%s '%s'" Rd-to-help-command file)))
|
||||
(set-buffer pbuf)
|
||||
(erase-buffer)
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "Rd-preview-help: (shell-command |%s| t)" shcmd))
|
||||
(shell-command shcmd t))
|
||||
;; else directly:
|
||||
(ess-force-buffer-current "R process to use: ")
|
||||
(ess-command (format "tools::Rd2txt(\"%s\")\n" file) pbuf)
|
||||
(set-buffer pbuf))
|
||||
|
||||
;; FIXME(2): once got rid of via-shell, consider
|
||||
;; (ess--flush-help-into-current-buffer file "tools::Rd2txt(\"%s\")\n")
|
||||
;; instead of all this :
|
||||
(ess-setq-vars-local R-customize-alist)
|
||||
(setq ess-help-sec-regex ess-help-R-sec-regex
|
||||
ess-help-sec-keys-alist ess-help-R-sec-keys-alist)
|
||||
;; mostly cut'n'paste from ess--flush-help* (see FIXME(2)):
|
||||
(ess-help-underline)
|
||||
(ess-help-mode)
|
||||
(goto-char (point-min))
|
||||
(set-buffer-modified-p 'nil)
|
||||
(setq buffer-read-only t)
|
||||
(setq truncate-lines nil)
|
||||
(when del-p (delete-file file))
|
||||
(unless (get-buffer-window pbuf 'visible)
|
||||
(display-buffer pbuf t))))
|
||||
|
||||
;; Bug reporting
|
||||
(defun Rd-submit-bug-report ()
|
||||
"Submit a bug report on Rd mode via mail."
|
||||
(interactive)
|
||||
(require 'reporter)
|
||||
(and
|
||||
(y-or-n-p "Do you want to submit a bug report? ")
|
||||
(reporter-submit-bug-report
|
||||
essddr-maintainer-address
|
||||
(concat "Emacs version " emacs-version)
|
||||
(list
|
||||
'essddr-version
|
||||
'Rd-indent-level))))
|
||||
|
||||
|
||||
;; Provide ourself
|
||||
(provide 'essddr)
|
||||
|
||||
;; ess-rd.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-rd.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-rd.elc
Normal file
Binary file not shown.
508
.emacs.d/elpa/ess-20160208.453/lisp/ess-rdired.el
Normal file
508
.emacs.d/elpa/ess-20160208.453/lisp/ess-rdired.el
Normal file
@@ -0,0 +1,508 @@
|
||||
;;; ess-rdired.el --- prototype object browser for R, looks like dired mode.
|
||||
|
||||
;; Copyright (C) 2002--2004 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: Stephen Eglen <stephen@anc.ed.ac.uk>
|
||||
;; Created: Thu 24 Oct 2002
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; This file is part of ESS
|
||||
|
||||
;; This file is not part of GNU Emacs.
|
||||
|
||||
;; ess-rdired.el is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; ess-rdired.el is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;; This provides a dired-like buffer for R objects. Instead of
|
||||
;; operating on files, we operate on R objects in the current
|
||||
;; environment. Objects can be viewed, edited, deleted, plotted and
|
||||
;; so on.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Installation and usage.
|
||||
;;
|
||||
;; Load in this library, e.g. with the command:
|
||||
;; (autoload 'ess-rdired "ess-rdired" "View *R* objects in a dired-like buffer." t)
|
||||
;;
|
||||
;; After loading this file, do "M-x R" to start an R session, then
|
||||
;; create a few variables:
|
||||
;; s <- sin(seq(from=0, to=8*pi, length=100))
|
||||
;; x <- c(1, 4, 9)
|
||||
;; y <- rnorm(20)
|
||||
;; z <- TRUE
|
||||
|
||||
;; Then in Emacs, do "M-x ess-rdired" and you should see the following in
|
||||
;; the buffer *R dired*:
|
||||
;; mode length
|
||||
;; s numeric 100
|
||||
;; x numeric 3
|
||||
;; y numeric 20
|
||||
;; z logical 1
|
||||
|
||||
;; Type "?" in the buffer to see the documentation. e.g. when the
|
||||
;; cursor is on the line for `s', type 'p' to plot it, or `v' to view
|
||||
;; its contents in a buffer. Then type 'd' to mark it for deletion.
|
||||
|
||||
;; How it works.
|
||||
|
||||
;; Most of the hardwork is done by the R routine .rdired.objects(),
|
||||
;; which, when called, produces the list of objects in a tidy format.
|
||||
;; This function is stored within the lisp variable `ess-rdired-objects',
|
||||
;; and can be altered to provide other information if you so need it.
|
||||
;; (Martin Maechler suggested providing output from str() here.)
|
||||
|
||||
;; Tested on Emacs 21.2, 21.3 pretest and XEmacs 21.1.14, using R 1.6.
|
||||
|
||||
;; Todo - compare functionality with ess-mouse-me (ess-mous.el).
|
||||
|
||||
;; Todo - How to select alternative environments? Currently only
|
||||
;; shows objects in the .GlobalEnv? See BrowseEnv() in 1.6.x for way
|
||||
;; of browsing other environments.
|
||||
|
||||
;; Todo - problem with fix -- have to wait for fix() command to return
|
||||
;; before *R* buffer can be used again. This can get stuck, umm. not
|
||||
;; sure what is going wrong here. Maybe add a hook to the temp buffer
|
||||
;; so that when buffer is killed, we send an instruction to R to
|
||||
;; update the value of the variable to the contents of the buffer.
|
||||
;; This way *R* doesn't have to wait.
|
||||
|
||||
;; Todo - small bug in .rdired.objects -- if we have a variable called
|
||||
;; `my.x', its value is replaced by the value of my.x used in the
|
||||
;; sapply() calls within .rdired.objects().
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defvar ess-rdired-objects "{.rdired.objects <- function(objs) {
|
||||
if (length(objs)==0) {
|
||||
\"No objects to view!\"
|
||||
} else {
|
||||
mode <- sapply(objs, function(my.x) {
|
||||
eval( parse( text=sprintf('data.class(get(\"%s\"))', my.x))) })
|
||||
length <- sapply(objs, function(my.x) {
|
||||
eval( parse( text=sprintf('length(get(\"%s\"))', my.x))) })
|
||||
size <- sapply(objs, function(my.x) {
|
||||
eval( parse( text=sprintf('object.size(get(\"%s\"))', my.x))) })
|
||||
d <- data.frame(mode, length, size)
|
||||
|
||||
var.names <- row.names(d)
|
||||
|
||||
## If any names contain spaces, we need to quote around them.
|
||||
quotes = rep('', length(var.names))
|
||||
spaces = grep(' ', var.names)
|
||||
if (any(spaces))
|
||||
quotes[spaces] <- '\"'
|
||||
var.names = paste(quotes, var.names, quotes, sep='')
|
||||
row.names(d) <- paste(' ', var.names, sep='')
|
||||
d
|
||||
}
|
||||
}; cat('\n'); print(.rdired.objects(ls()))}\n"
|
||||
"Function to call within R to print information on objects. The last
|
||||
line of this string should be the instruction to call the
|
||||
function which prints the output for rdired.")
|
||||
|
||||
(defvar ess-rdired-buffer "*R dired*"
|
||||
"Name of buffer for displaying R objects.")
|
||||
|
||||
(defvar ess-rdired-mode-map
|
||||
(let ((ess-rdired-mode-map (make-sparse-keymap)))
|
||||
(if (require 'hide-lines nil t)
|
||||
(define-key ess-rdired-mode-map "/" 'hide-lines))
|
||||
(define-key ess-rdired-mode-map "?" 'ess-rdired-help)
|
||||
(define-key ess-rdired-mode-map "d" 'ess-rdired-delete)
|
||||
(define-key ess-rdired-mode-map "u" 'ess-rdired-undelete)
|
||||
(define-key ess-rdired-mode-map "x" 'ess-rdired-expunge)
|
||||
;; editing requires a little more work.
|
||||
;;(define-key ess-rdired-mode-map "e" 'ess-rdired-edit)
|
||||
(define-key ess-rdired-mode-map "v" 'ess-rdired-view)
|
||||
(define-key ess-rdired-mode-map "V" 'ess-rdired-View)
|
||||
(define-key ess-rdired-mode-map "p" 'ess-rdired-plot)
|
||||
(define-key ess-rdired-mode-map "s" 'ess-rdired-sort)
|
||||
(define-key ess-rdired-mode-map "r" 'ess-rdired-reverse)
|
||||
(define-key ess-rdired-mode-map "q" 'ess-rdired-quit)
|
||||
(define-key ess-rdired-mode-map "y" 'ess-rdired-type) ;what type?
|
||||
(define-key ess-rdired-mode-map " " 'ess-rdired-next-line)
|
||||
(define-key ess-rdired-mode-map [backspace] 'ess-rdired-previous-line)
|
||||
(define-key ess-rdired-mode-map "\C-n" 'ess-rdired-next-line)
|
||||
(define-key ess-rdired-mode-map "\C-p" 'ess-rdired-previous-line)
|
||||
;; (define-key ess-rdired-mode-map "n" 'ess-rdired-next-line)
|
||||
;; (define-key ess-rdired-mode-map "p" 'ess-rdired-previous-line)
|
||||
|
||||
;; R mode keybindings.
|
||||
(define-key ess-rdired-mode-map "\C-c\C-s" 'ess-rdired-switch-process)
|
||||
(define-key ess-rdired-mode-map "\C-c\C-y" 'ess-switch-to-ESS)
|
||||
(define-key ess-rdired-mode-map "\C-c\C-z" 'ess-switch-to-end-of-ESS)
|
||||
|
||||
(define-key ess-rdired-mode-map [down] 'ess-rdired-next-line)
|
||||
(define-key ess-rdired-mode-map [up] 'ess-rdired-previous-line)
|
||||
(define-key ess-rdired-mode-map "g" 'revert-buffer)
|
||||
(if (featurep 'xemacs)
|
||||
(define-key ess-rdired-mode-map [button2] 'ess-rdired-mouse-view)
|
||||
(define-key ess-rdired-mode-map [mouse-2] 'ess-rdired-mouse-view)
|
||||
)
|
||||
ess-rdired-mode-map))
|
||||
|
||||
(defun ess-rdired-mode ()
|
||||
"Major mode for output from `ess-rdired'.
|
||||
`ess-rdired' provides a dired-like mode for R objects. It shows the
|
||||
list of current objects in the current environment, one-per-line. You
|
||||
can then examine these objects, plot them, and so on.
|
||||
\\{ess-rdired-mode-map}"
|
||||
;; (kill-all-local-variables)
|
||||
(make-local-variable 'revert-buffer-function)
|
||||
(setq revert-buffer-function 'ess-rdired-revert-buffer)
|
||||
(use-local-map ess-rdired-mode-map)
|
||||
(setq major-mode 'ess-rdired-mode)
|
||||
(setq mode-name (concat "RDired " ess-local-process-name))
|
||||
(run-mode-hooks 'ess-rdired-mode-hook))
|
||||
|
||||
(defun ess-rdired-mode-hook nil
|
||||
"Run upon entering `ess-rdired-mode'.")
|
||||
|
||||
(defvar ess-rdired-sort-num nil) ;silence the compiler.
|
||||
;; but see following defun -- maybe it should be buffer local.
|
||||
|
||||
(defun ess-rdired ()
|
||||
"Run dired-like mode on R objects.
|
||||
This is the main function. See documentation for `ess-rdired-mode' though
|
||||
for more information!"
|
||||
(interactive)
|
||||
(let ((proc ess-local-process-name)
|
||||
(buff (get-buffer-create ess-rdired-buffer)))
|
||||
|
||||
(ess-command ess-rdired-objects buff)
|
||||
(ess-setq-vars-local (symbol-value ess-local-customize-alist) buff)
|
||||
|
||||
(with-current-buffer buff
|
||||
(setq ess-local-process-name proc)
|
||||
(ess-rdired-mode)
|
||||
|
||||
;; When definiting the function .rdired.objects(), a "+ " is printed
|
||||
;; for every line of the function definition; these are deleted
|
||||
;; here.
|
||||
(goto-char (point-min))
|
||||
(delete-region (point-min) (1+ (point-at-eol)))
|
||||
|
||||
;; todo: not sure how to make ess-rdired-sort-num buffer local?
|
||||
;;(set (make-local-variable 'ess-rdired-sort-num) 2)
|
||||
;;(make-variable-buffer-local 'ess-rdired-sort-num)
|
||||
(setq ess-rdired-sort-num 1)
|
||||
(ess-rdired-insert-set-properties (save-excursion
|
||||
(goto-char (point-min))
|
||||
(forward-line 1)
|
||||
(point))
|
||||
(point-max))
|
||||
(setq buffer-read-only t)
|
||||
)
|
||||
|
||||
(pop-to-buffer buff)
|
||||
))
|
||||
|
||||
|
||||
(defun ess-rdired-object ()
|
||||
"Return name of object on current line.
|
||||
Handle special case when object contains spaces."
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(forward-char 2)
|
||||
|
||||
(cond ((looking-at " ") ; First line?
|
||||
nil)
|
||||
((looking-at "\"") ; Object name contains spaces?
|
||||
(let (beg)
|
||||
(setq beg (point))
|
||||
(forward-char 1)
|
||||
(search-forward "\"")
|
||||
(buffer-substring-no-properties beg (point))))
|
||||
(t ;should be a regular object.
|
||||
(let (beg)
|
||||
(setq beg (point))
|
||||
(search-forward " ") ;assume space follows object name.
|
||||
(buffer-substring-no-properties beg (1- (point))))))))
|
||||
|
||||
(defun ess-rdired-edit ()
|
||||
"Edit (fix) the object at point."
|
||||
(interactive)
|
||||
(let ((objname (ess-rdired-object)))
|
||||
(ess-command (concat "edit(" objname ")\n"))))
|
||||
|
||||
(defun ess-rdired-view ()
|
||||
"View the object at point."
|
||||
(interactive)
|
||||
(let ((objname (ess-rdired-object)))
|
||||
(ess-execute (ess-rdired-get objname)
|
||||
nil "R view" )))
|
||||
|
||||
(defun ess-rdired-get (name)
|
||||
"Generate R code to get the value of the variable name.
|
||||
This is complicated because some variables might have spaces in their names.
|
||||
Otherwise, we could just pass the variable name directly to *R*."
|
||||
(concat "get(" (ess-rdired-quote name) ")")
|
||||
)
|
||||
|
||||
(defun ess-rdired-quote (name)
|
||||
"Quote name if not already quoted."
|
||||
(if (equal (substring name 0 1) "\"")
|
||||
name
|
||||
(concat "\"" name "\"")))
|
||||
|
||||
|
||||
(defun ess-rdired-View ()
|
||||
"View the object at point in its own buffer.
|
||||
Like `ess-rdired-view', but the object gets its own buffer name."
|
||||
(interactive)
|
||||
(let ((objname (ess-rdired-object)))
|
||||
(ess-execute (ess-rdired-get objname)
|
||||
nil (concat "R view " objname ))))
|
||||
|
||||
(defun ess-rdired-plot ()
|
||||
"Plot the object on current line."
|
||||
(interactive)
|
||||
(let ((objname (ess-rdired-object)))
|
||||
(ess-eval-linewise (format "plot(%s)" (ess-rdired-get objname)))))
|
||||
|
||||
(defun ess-rdired-type ()
|
||||
"Run the mode() on command at point.
|
||||
Named type because of similarity with the dired command bound to
|
||||
y key."
|
||||
(interactive)
|
||||
(let ((objname (ess-rdired-object))
|
||||
;; create a temp buffer, and then show output in echo area
|
||||
(tmpbuf (get-buffer-create "**ess-rdired-mode**")))
|
||||
(if objname
|
||||
(progn
|
||||
(ess-command (concat "mode(" (ess-rdired-get objname) ")\n")
|
||||
tmpbuf )
|
||||
(set-buffer tmpbuf)
|
||||
(message (concat
|
||||
objname ": "
|
||||
(buffer-substring (+ 4 (point-min)) (1- (point-max)))))
|
||||
(kill-buffer tmpbuf)))))
|
||||
|
||||
(defun ess-rdired-delete (arg)
|
||||
"Mark the current (or next ARG) objects for deletion.
|
||||
If point is on first line, all objects are marked for deletion."
|
||||
(interactive "p")
|
||||
(ess-rdired-mark "D" arg))
|
||||
|
||||
(defun ess-rdired-undelete (arg)
|
||||
"Unmark the current (or next ARG) objects.
|
||||
If point is on first line, all objects will be unmarked."
|
||||
(interactive "p")
|
||||
(ess-rdired-mark " " arg))
|
||||
|
||||
(defun ess-rdired-mark (mark-char arg)
|
||||
"Mark the object, using MARK-CHAR, on current line (or next ARG lines)."
|
||||
;; If we are on first line, mark all lines.
|
||||
(let ((buffer-read-only nil)
|
||||
move)
|
||||
(if (eq (point-min)
|
||||
(save-excursion (beginning-of-line) (point)))
|
||||
(progn
|
||||
;; we are on first line, so make a note of point, and count
|
||||
;; how many objects we want to delete. Then at end of defun,
|
||||
;; restore point.
|
||||
(setq move (point))
|
||||
(forward-line 1)
|
||||
(setq arg (count-lines (point) (point-max)))))
|
||||
(while (and (> arg 0) (not (eobp)))
|
||||
(setq arg (1- arg))
|
||||
(beginning-of-line)
|
||||
(progn
|
||||
(insert mark-char)
|
||||
(delete-char 1)
|
||||
(forward-line 1)))
|
||||
(if move
|
||||
(goto-char move))))
|
||||
|
||||
|
||||
(defun ess-rdired-expunge ()
|
||||
"Delete the marked objects.
|
||||
User is queried first to check that objects should really be deleted."
|
||||
(interactive)
|
||||
(let ((objs "rm(")
|
||||
(count 0))
|
||||
(save-excursion
|
||||
(goto-char (point-min)) (forward-line 1)
|
||||
(while (< (count-lines (point-min) (point))
|
||||
(count-lines (point-min) (point-max)))
|
||||
(beginning-of-line)
|
||||
(if (looking-at "^D ")
|
||||
(setq count (1+ count)
|
||||
objs (concat objs (ess-rdired-object) ", " )))
|
||||
(forward-line 1)
|
||||
))
|
||||
(if (> count 0)
|
||||
;; found objects to delete
|
||||
(progn
|
||||
(setq objs (concat
|
||||
(substring objs 0 (- (length objs) 2))
|
||||
")\n"))
|
||||
(if (yes-or-no-p (format "Delete %d %s " count
|
||||
(if (> count 1) "objects" "object")))
|
||||
(progn
|
||||
(ess-eval-linewise objs nil nil nil 'wait)
|
||||
(ess-rdired)
|
||||
)))
|
||||
;; else nothing to delete
|
||||
(message "no objects set to delete")
|
||||
)))
|
||||
|
||||
;; Fancy delete method, based on dired. Bit too much for our needs?
|
||||
;; (defun ess-rdired-expunge ()
|
||||
;; "Delete the marked objects.
|
||||
;; User is queried first to check that objects should really be deleted."
|
||||
;; (interactive)
|
||||
;; (let ((objs)
|
||||
;; (cmd "rm("))
|
||||
;; (save-excursion
|
||||
;; (goto-line 2)
|
||||
;; (while (< (count-lines (point-min) (point))
|
||||
;; (count-lines (point-min) (point-max)))
|
||||
;; (beginning-of-line)
|
||||
;; (if (looking-at "^D ")
|
||||
;; (progn
|
||||
;; (setq objs (cons (ess-rdired-object) objs ))
|
||||
;; (setq cmd (concat cmd (ess-rdired-object) ", "))
|
||||
;; ))
|
||||
;; (forward-line 1)
|
||||
;; ))
|
||||
;; (if (> (length objs) 0)
|
||||
;; ;; found objects to delete
|
||||
;; (if
|
||||
;; (dired-mark-pop-up "*RDired deletions*" 'delete
|
||||
;; objs dired-deletion-confirmer
|
||||
;; (format "delete %s "
|
||||
;; (dired-mark-prompt nil objs)))
|
||||
;; ;; should delete the objects.
|
||||
;; (progn
|
||||
;; (setq cmd (concat (substring cmd 0 (- (length cmd) 2))
|
||||
;; ")\n"))
|
||||
;; (ess-command cmd)
|
||||
;; (ess-rdired)))
|
||||
;; ;; else nothing to delete
|
||||
;; (message "no objects set to delete")
|
||||
;; )))
|
||||
|
||||
(defun ess-rdired-quit ()
|
||||
"Quit the R dired buffer."
|
||||
(interactive)
|
||||
(kill-buffer ess-rdired-buffer))
|
||||
|
||||
(defun ess-rdired-revert-buffer (ignore noconfirm)
|
||||
"Update the buffer list (in case object list has changed).
|
||||
Arguments IGNORE and NOCONFIRM currently not used."
|
||||
(ess-rdired))
|
||||
|
||||
(defun ess-rdired-help ()
|
||||
"Show help for `ess-rdired-mode'."
|
||||
(interactive)
|
||||
(describe-function 'ess-rdired-mode))
|
||||
|
||||
(defun ess-rdired-sort ()
|
||||
"Sort the rdired output according to one of the columns.
|
||||
Rotate between the alternative sorting methods."
|
||||
(interactive)
|
||||
(setq ess-rdired-sort-num (1+ ess-rdired-sort-num))
|
||||
(let ((buffer-read-only nil)
|
||||
(beg (save-excursion
|
||||
(goto-char (point-min))
|
||||
(forward-line 1)
|
||||
(point)))
|
||||
(end (point-max)))
|
||||
(if (> ess-rdired-sort-num 4)
|
||||
(setq ess-rdired-sort-num 1))
|
||||
(cond ((eq ess-rdired-sort-num 1)
|
||||
(sort-fields 1 beg end))
|
||||
((eq ess-rdired-sort-num 2)
|
||||
(sort-fields 2 beg end))
|
||||
((eq ess-rdired-sort-num 3)
|
||||
(sort-numeric-fields 3 beg end))
|
||||
((eq ess-rdired-sort-num 4)
|
||||
(sort-numeric-fields 4 beg end)))))
|
||||
|
||||
(defun ess-rdired-reverse ()
|
||||
"Reverse the current sort order."
|
||||
(interactive)
|
||||
(let ((buffer-read-only nil)
|
||||
(beg (save-excursion
|
||||
(goto-char (point-min))
|
||||
(forward-line 1)
|
||||
(point)))
|
||||
(end (point-max)))
|
||||
(reverse-region beg end)))
|
||||
|
||||
(defun ess-rdired-next-line (arg)
|
||||
"Move down lines then position at object.
|
||||
Optional prefix ARG says how many lines to move; default is one line."
|
||||
(interactive "p")
|
||||
(forward-line arg)
|
||||
(ess-rdired-move-to-object))
|
||||
|
||||
(defun ess-rdired-previous-line (arg)
|
||||
"Move up lines then position at object.
|
||||
Optional prefix ARG says how many lines to move; default is one line."
|
||||
(interactive "p")
|
||||
(forward-line (- (or arg 1))) ; -1 if arg was nil
|
||||
(ess-rdired-move-to-object))
|
||||
|
||||
(defun ess-rdired-move-to-object ()
|
||||
"Put point at start of object."
|
||||
(beginning-of-line)
|
||||
(forward-char 2)
|
||||
)
|
||||
|
||||
(defun ess-rdired-mouse-view (event)
|
||||
"In rdired, visit the object on the line you click on."
|
||||
(interactive "e")
|
||||
(let (window pos)
|
||||
(save-excursion
|
||||
(if (featurep 'xemacs)
|
||||
;; XEmacs
|
||||
(setq window (event-window event)
|
||||
pos (event-point event))
|
||||
;; Emacs
|
||||
(setq window (posn-window (event-end event))
|
||||
pos (posn-point (event-end event))))
|
||||
(if (not (windowp window))
|
||||
(error "No file chosen"))
|
||||
(set-buffer (window-buffer window))
|
||||
(goto-char pos)
|
||||
(ess-rdired-view))))
|
||||
|
||||
(defun ess-rdired-insert-set-properties (beg end)
|
||||
"Add mouse highlighting to each object name in the R dired buffer."
|
||||
(save-excursion
|
||||
(goto-char beg)
|
||||
(while (< (point) end)
|
||||
(ess-rdired-move-to-object)
|
||||
(add-text-properties
|
||||
(point)
|
||||
(save-excursion
|
||||
(search-forward " ")
|
||||
(1- (point)))
|
||||
'(mouse-face highlight
|
||||
help-echo "mouse-2: view object in other window"))
|
||||
(forward-line 1))))
|
||||
|
||||
(defun ess-rdired-switch-process ()
|
||||
"Switch to examine different *R* process.
|
||||
If you have multiple R processes running, e.g. *R*, *R:2*, *R:3*, you can
|
||||
use this command to choose which R process you would like to examine.
|
||||
After switching to a new process, the buffer is updated."
|
||||
(interactive)
|
||||
(ess-switch-process)
|
||||
(ess-rdired))
|
||||
|
||||
;;; ess-rdired.el ends here.
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-rdired.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-rdired.elc
Normal file
Binary file not shown.
884
.emacs.d/elpa/ess-20160208.453/lisp/ess-roxy.el
Normal file
884
.emacs.d/elpa/ess-20160208.453/lisp/ess-roxy.el
Normal file
@@ -0,0 +1,884 @@
|
||||
;;; ess-roxy.el --- convenient editing of in-code roxygen documentation
|
||||
;;
|
||||
;; Copyright (C) 2009--2012 Henning Redestig, A.J. Rossini, Richard
|
||||
;; M. Heiberger, Martin Maechler, Kurt Hornik, Rodney Sparapani, Stephen
|
||||
;; Eglen and Vitalie Spinu.
|
||||
;;
|
||||
;; Author: Henning Redestig <henning.red * go0glemail c-m>
|
||||
;; Keywords: convenience, tools
|
||||
;;
|
||||
;; This file is part of ESS
|
||||
;;
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 3 of the
|
||||
;; License, or (at your option) any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful, but
|
||||
;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;; General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program. If not, see
|
||||
;; <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Lots of inspiration from doc-mode,
|
||||
;; http://nschum.de/src/emacs/doc-mode/
|
||||
;;
|
||||
;; Features::
|
||||
;;
|
||||
;; - basic highlighting
|
||||
;; - generating and updating templates from function definition and customized default template
|
||||
;; - C-c C-o C-o :: update template
|
||||
;; - navigating and filling roxygen fields
|
||||
;; - C-c TAB, M-q, C-a, ENTER, M-h :: advised tag completion, fill-paragraph,
|
||||
;; move-beginning-of-line, newline-and-indent
|
||||
;; - C-c C-o n,p :: next, previous roxygen entry
|
||||
;; - C-c C-o C-c :: Unroxygen region. Convenient for editing examples.
|
||||
;; - folding visibility using hs-minor-mode
|
||||
;; - TAB :: advised ess-ident-command, hide entry if in roxygen doc.
|
||||
;; - preview
|
||||
;; - C-c C-o C-r :: create a preview of the Rd file as generated
|
||||
;; using roxygen
|
||||
;; - C-c C-o C-t :: create a preview of the Rd HTML file as generated
|
||||
;; using roxygen and the tools package
|
||||
;; - C-c C-o t :: create a preview of the Rd text file
|
||||
;;
|
||||
;; Known issues:
|
||||
;;
|
||||
;; - hideshow mode does not work very well. In particular, if ordinary
|
||||
;; comments precede a roxygen entry, then both will be hidden in the
|
||||
;; same overlay from start and not unfoldable using TAB since the
|
||||
;; roxygen prefix is not present. The planned solution is implement
|
||||
;; a replacement for hideshow.
|
||||
;; - only limited functionality for S4 documentation.
|
||||
|
||||
;; this *is* enabled now via ess-mode-hook in ./ess-site.el
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'ess-custom)
|
||||
(require 'hideshow)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
(autoload 'Rd-preview-help "ess-rd" "[autoload]" t)
|
||||
|
||||
;; ------------------
|
||||
(defvar ess-roxy-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(if ess-roxy-hide-show-p
|
||||
(define-key map (kbd "C-c C-o h") 'ess-roxy-hide-all))
|
||||
;; short version (*first*: -> key binding shown in menu):
|
||||
(define-key map (kbd "C-c C-o n") 'ess-roxy-next-entry)
|
||||
(define-key map (kbd "C-c C-o p") 'ess-roxy-previous-entry)
|
||||
;; For consistency (e.g. C-c C-o C-h !): kept here *in* addition to above
|
||||
(define-key map (kbd "C-c C-o C-o") 'ess-roxy-update-entry)
|
||||
(define-key map (kbd "C-c C-o C-r") 'ess-roxy-preview-Rd)
|
||||
(define-key map (kbd "C-c C-o C-w") 'ess-roxy-preview-HTML)
|
||||
(define-key map (kbd "C-c C-o C-t") 'ess-roxy-preview-text)
|
||||
(define-key map (kbd "C-c C-o C-c") 'ess-roxy-toggle-roxy-region)
|
||||
map)
|
||||
)
|
||||
|
||||
;; (defvar ess-roxy-font-lock-keywords nil)
|
||||
|
||||
(defvar ess-roxy-font-lock-keywords
|
||||
`((,(concat ess-roxy-re " *\\([@\\]"
|
||||
(regexp-opt ess-roxy-tags-param t)
|
||||
"\\)\\>")
|
||||
(1 'font-lock-keyword-face prepend))
|
||||
(,(concat ess-roxy-re " *\\([@\\]"
|
||||
(regexp-opt '("param" "importFrom" "importClassesFrom"
|
||||
"importMethodsFrom") t)
|
||||
"\\)\\>\\(?:[ \t]+\\(\\sw+\\)\\)?")
|
||||
(1 'font-lock-keyword-face prepend)
|
||||
(3 'font-lock-variable-name-face prepend))
|
||||
(,(concat "[@\\]" (regexp-opt ess-roxy-tags-noparam t) "\\>")
|
||||
(0 'font-lock-variable-name-face prepend))
|
||||
(,(concat ess-roxy-re)
|
||||
(0 'bold prepend))))
|
||||
|
||||
(define-minor-mode ess-roxy-mode
|
||||
"Minor mode for editing in-code documentation."
|
||||
;; :lighter " Rox"
|
||||
:keymap ess-roxy-mode-map
|
||||
(if ess-roxy-mode
|
||||
(progn
|
||||
(unless (featurep 'xemacs) ;; does not exist in xemacs:
|
||||
(font-lock-add-keywords nil ess-roxy-font-lock-keywords))
|
||||
(if (and (featurep 'emacs) (>= emacs-major-version 24))
|
||||
(add-to-list 'completion-at-point-functions 'ess-roxy-tag-completion)
|
||||
(add-to-list 'comint-dynamic-complete-functions 'ess-roxy-complete-tag))
|
||||
(if ess-roxy-hide-show-p
|
||||
(progn
|
||||
;(setq hs-c-start-regexp "s")
|
||||
(if (condition-case nil
|
||||
(if (and (symbolp hs-minor-mode)
|
||||
(symbol-value hs-minor-mode))
|
||||
nil t) (error t) )
|
||||
(progn
|
||||
(hs-minor-mode)))
|
||||
(if ess-roxy-start-hidden-p
|
||||
(ess-roxy-hide-all)))))
|
||||
(if ess-roxy-hide-show-p
|
||||
(if hs-minor-mode
|
||||
(progn
|
||||
(hs-show-all)
|
||||
(hs-minor-mode))))
|
||||
(unless (featurep 'xemacs)
|
||||
(font-lock-remove-keywords nil ess-roxy-font-lock-keywords)))
|
||||
(when font-lock-mode
|
||||
(font-lock-fontify-buffer))
|
||||
;; for auto fill functionality
|
||||
(make-local-variable 'paragraph-start)
|
||||
(setq paragraph-start (concat "\\(" ess-roxy-re "\\)*" paragraph-start))
|
||||
(make-local-variable 'paragraph-separate)
|
||||
(setq paragraph-separate (concat "\\(" ess-roxy-re "\\)*" paragraph-separate))
|
||||
(make-local-variable 'adaptive-fill-function)
|
||||
(setq adaptive-fill-function 'ess-roxy-adaptive-fill-function)
|
||||
(add-hook 'ess-presend-filter-functions 'ess-roxy-remove-roxy-re nil 'local)
|
||||
)
|
||||
|
||||
|
||||
;; (setq hs-c-start-regexp ess-roxy-str)
|
||||
;; (make-variable-buffer-local 'hs-c-start-regexp)
|
||||
|
||||
|
||||
;;; Function definitions
|
||||
|
||||
(defun ess-back-to-roxy ()
|
||||
"Go to roxy prefix"
|
||||
(progn
|
||||
(end-of-line)
|
||||
(re-search-backward (concat ess-roxy-re " ?") (point-at-bol))
|
||||
(goto-char (match-end 0))))
|
||||
|
||||
(defun ess-roxy-beg-of-entry ()
|
||||
"Get point number at start of current entry, 0 if not in entry"
|
||||
(save-excursion
|
||||
(let (beg)
|
||||
(beginning-of-line)
|
||||
(setq beg -1)
|
||||
(if (not (ess-roxy-entry-p))
|
||||
(setq beg 0)
|
||||
(setq beg (point)))
|
||||
(while (and (= (forward-line -1) 0) (ess-roxy-entry-p))
|
||||
(setq beg (point)))
|
||||
beg)))
|
||||
|
||||
(defun ess-roxy-in-header-p ()
|
||||
"true if point is the description / details field"
|
||||
(save-excursion
|
||||
(let ((res t)
|
||||
(cont (ess-roxy-entry-p)))
|
||||
(beginning-of-line)
|
||||
(while cont
|
||||
(if (looking-at (concat ess-roxy-re " *[@].+"))
|
||||
(progn (setq res nil)
|
||||
(setq cont nil)))
|
||||
(setq cont (and (= (forward-line -1) 0) (ess-roxy-entry-p)))
|
||||
)res)))
|
||||
|
||||
(defun ess-roxy-beg-of-field ()
|
||||
"Get point number at beginning of current field, 0 if not in entry"
|
||||
(save-excursion
|
||||
(let (cont beg)
|
||||
(beginning-of-line)
|
||||
(setq beg 0)
|
||||
(setq cont t)
|
||||
(while (and (ess-roxy-entry-p) cont)
|
||||
(setq beg (point))
|
||||
(if (looking-at (concat ess-roxy-re " *[@].+"))
|
||||
(setq cont nil))
|
||||
(if (ess-roxy-in-header-p)
|
||||
(if (looking-at (concat ess-roxy-re " *$"))
|
||||
(progn
|
||||
(forward-line 1)
|
||||
(setq beg (point))
|
||||
(setq cont nil))))
|
||||
(if cont (setq cont (= (forward-line -1) 0))))
|
||||
beg)))
|
||||
|
||||
(defun ess-roxy-end-of-entry ()
|
||||
" get point number at end of current entry, 0 if not in entry"
|
||||
(save-excursion
|
||||
(let ((end))
|
||||
(end-of-line)
|
||||
(setq end -1)
|
||||
(if (not (ess-roxy-entry-p))
|
||||
(setq end 0)
|
||||
(setq end (point)))
|
||||
(while (and (= (forward-line 1) 0) (ess-roxy-entry-p))
|
||||
(end-of-line)
|
||||
(setq end (point)))
|
||||
end)))
|
||||
|
||||
(defun ess-roxy-end-of-field ()
|
||||
"get point number at end of current field, 0 if not in entry"
|
||||
(save-excursion
|
||||
(let ((end nil)
|
||||
(cont nil))
|
||||
(setq end 0)
|
||||
(if (ess-roxy-entry-p) (progn (end-of-line) (setq end (point))))
|
||||
(beginning-of-line)
|
||||
(forward-line 1)
|
||||
(setq cont t)
|
||||
(while (and (ess-roxy-entry-p) cont)
|
||||
(save-excursion
|
||||
(end-of-line)
|
||||
(setq end (point)))
|
||||
(if (or (and (ess-roxy-in-header-p)
|
||||
(looking-at (concat ess-roxy-re " *$")))
|
||||
(looking-at (concat ess-roxy-re " *[@].+")))
|
||||
(progn
|
||||
(forward-line -1)
|
||||
(end-of-line)
|
||||
(setq end (point))
|
||||
(setq cont nil)))
|
||||
(if cont (setq cont (= (forward-line 1) 0))))
|
||||
end)))
|
||||
|
||||
(defun ess-roxy-entry-p ()
|
||||
"True if point is in a roxy entry"
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(looking-at (concat ess-roxy-re))))
|
||||
|
||||
(defun ess-roxy-narrow-to-field ()
|
||||
"Go to to the start of current field"
|
||||
(interactive)
|
||||
(let ((beg (ess-roxy-beg-of-field))
|
||||
(end (ess-roxy-end-of-field)))
|
||||
(narrow-to-region beg end)))
|
||||
|
||||
(defun ess-roxy-adaptive-fill-function ()
|
||||
"Return prefix for filling paragraph or nil if not determined."
|
||||
(when (ess-roxy-entry-p)
|
||||
(let ((roxy-str (car (split-string (ess-roxy-guess-str) "'"))))
|
||||
(if (ess-roxy-in-header-p)
|
||||
(save-excursion
|
||||
(ess-back-to-roxy)
|
||||
(re-search-forward "\\([ \t]*\\)" (line-end-position) t)
|
||||
(concat roxy-str "' " (match-string 1)))
|
||||
(concat roxy-str "' " (make-string ess-indent-offset ? ))))))
|
||||
|
||||
(defun ess-roxy-current-field ()
|
||||
"Return the name of the field at point."
|
||||
(and (not (ess-roxy-in-header-p))
|
||||
(save-excursion
|
||||
(goto-char (ess-roxy-beg-of-field))
|
||||
(if (re-search-forward (concat ess-roxy-re
|
||||
"[ \t]+@\\([[:alpha:]]+\\)")
|
||||
(line-end-position) t)
|
||||
(match-string-no-properties 1)))))
|
||||
|
||||
(defun ess-roxy-maybe-indent-line ()
|
||||
"Indent line when point is in a field, but not in its first line."
|
||||
(when (and (not (ess-roxy-in-header-p))
|
||||
(not (equal (ess-roxy-current-field) "examples"))
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(let ((line-n (count-lines 1 (point))))
|
||||
(goto-char (ess-roxy-beg-of-field))
|
||||
(not (equal line-n (count-lines 1 (point)))))))
|
||||
(ess-roxy-should-indent-line-p)
|
||||
(ess-back-to-roxy)
|
||||
(delete-region (point) (progn (skip-chars-forward " \t") (point)))
|
||||
(insert (make-string ess-indent-offset ? ))))
|
||||
|
||||
(defun ess-roxy-goto-func-def ()
|
||||
"put point at start of function either that the point is in or
|
||||
below the current roxygen entry, error otherwise"
|
||||
(if (ess-roxy-entry-p)
|
||||
(progn
|
||||
(ess-roxy-goto-end-of-entry)
|
||||
(forward-line 1)
|
||||
(beginning-of-line))
|
||||
(goto-char (car (ess-end-of-function)))))
|
||||
|
||||
(defun ess-roxy-get-args-list-from-def ()
|
||||
"get args list for current function"
|
||||
(save-excursion
|
||||
(ess-roxy-goto-func-def)
|
||||
(let ((args (ess-roxy-get-function-args)))
|
||||
(mapcar (lambda (x) (cons x '(""))) args))))
|
||||
|
||||
(defun ess-roxy-insert-args (args &optional here)
|
||||
"Insert an args list to the end of the roxygen entry for the
|
||||
function at point. if here is supplied start inputting
|
||||
`here'. Finish at end of line."
|
||||
(let* ((arg-des nil)
|
||||
(roxy-str (ess-roxy-guess-str)))
|
||||
(if (or (not here) (< here 1))
|
||||
(progn
|
||||
(ess-roxy-goto-end-of-entry)
|
||||
(beginning-of-line)
|
||||
(if (not (looking-at "\="))
|
||||
(progn
|
||||
(end-of-line))))
|
||||
(goto-char here))
|
||||
(while (stringp (car (car args)))
|
||||
(setq arg-des (pop args))
|
||||
(unless (string= (car arg-des) "")
|
||||
(progn
|
||||
(insert (concat "\n"
|
||||
roxy-str " @param " (car arg-des) " "))
|
||||
(insert
|
||||
(ess-replace-in-string (concat (car (cdr arg-des))) "\n"
|
||||
(concat "\n" roxy-str)))
|
||||
(if ess-roxy-fill-param-p
|
||||
(fill-paragraph))
|
||||
)))))
|
||||
|
||||
(defun ess-roxy-merge-args (fun ent)
|
||||
"Take two args lists (alists) and return their union. Result
|
||||
holds all keys from both fun and ent but no duplicates and
|
||||
association from ent are preferred over entries from fun. Also,
|
||||
drop entries from ent that are not in fun and are associated with
|
||||
the empty string."
|
||||
(let ((res-arg nil)
|
||||
(arg-des))
|
||||
(while (stringp (car (car fun)))
|
||||
(setq arg-des (pop fun))
|
||||
(if (assoc (car arg-des) ent)
|
||||
(setq res-arg
|
||||
(cons (cons (car arg-des) (cdr (assoc (car arg-des) ent))) res-arg))
|
||||
(setq res-arg (cons (cons (car arg-des) '("")) res-arg))))
|
||||
(while (stringp (car (car ent)))
|
||||
(setq arg-des (pop ent))
|
||||
(if (and (not (assoc (car arg-des) res-arg)) (not (string= (car (cdr arg-des)) "")))
|
||||
(setq res-arg (cons (cons (car arg-des) (cdr arg-des)) res-arg))))
|
||||
(nreverse res-arg)))
|
||||
|
||||
(defun ess-roxy-update-entry ()
|
||||
"Update the entry at the point or the entry above the function
|
||||
which the point is in. Add a template empty roxygen documentation
|
||||
if no roxygen entry is available. The template can be customized
|
||||
via the variable `ess-roxy-template-alist'. The parameter
|
||||
descriptions can are filled if `ess-roxy-fill-param-p' is
|
||||
non-nil."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(let* ((args-fun (ess-roxy-get-args-list-from-def))
|
||||
(args-ent (ess-roxy-get-args-list-from-entry))
|
||||
(args (ess-roxy-merge-args args-fun args-ent))
|
||||
(roxy-str (ess-roxy-guess-str))
|
||||
(line-break "")
|
||||
here key template tag-def)
|
||||
(ess-roxy-goto-func-def)
|
||||
(if (not (= (forward-line -1) 0))
|
||||
(progn
|
||||
(insert "\n")
|
||||
(forward-line -1)))
|
||||
(if (and (not (looking-at "^\n")) (not (ess-roxy-entry-p)))
|
||||
(progn
|
||||
(end-of-line)
|
||||
(insert "\n")))
|
||||
(if (ess-roxy-entry-p)
|
||||
(progn
|
||||
(setq here (1- (ess-roxy-delete-args)))
|
||||
(ess-roxy-insert-args args here))
|
||||
(setq template (copy-sequence ess-roxy-template-alist))
|
||||
(while (stringp (car (car template)))
|
||||
(setq tag-def (pop template))
|
||||
(if (string= (car tag-def) "param")
|
||||
(ess-roxy-insert-args args (point))
|
||||
(if (string= (car tag-def) "description")
|
||||
(insert (concat line-break roxy-str " "
|
||||
(cdr tag-def) "\n" roxy-str))
|
||||
(if (string= (car tag-def) "details")
|
||||
(insert (concat line-break roxy-str " " (cdr tag-def)))
|
||||
(insert (concat line-break roxy-str " @"
|
||||
(car tag-def) " " (cdr tag-def))))
|
||||
))
|
||||
(setq line-break "\n")
|
||||
)))))
|
||||
|
||||
(defun ess-roxy-goto-end-of-entry ()
|
||||
"Put point at the top of the entry at point or above the
|
||||
function at point. Return t if the point is left in a roxygen
|
||||
entry, otherwise nil. Error if point is not in function or
|
||||
roxygen entry."
|
||||
(if (not (ess-roxy-entry-p))
|
||||
(progn
|
||||
(goto-char (nth 0 (ess-end-of-function)))
|
||||
(forward-line -1)))
|
||||
(if (ess-roxy-entry-p)
|
||||
(progn
|
||||
(goto-char (ess-roxy-end-of-entry))
|
||||
t) (forward-line) nil))
|
||||
|
||||
(defun ess-roxy-goto-beg-of-entry ()
|
||||
"put point at the top of the entry at point or above the
|
||||
function at point. Return t if the point is left in a roxygen
|
||||
entry, otherwise nil. Error if point is not in function or
|
||||
roxygen entry."
|
||||
(if (not (ess-roxy-entry-p))
|
||||
(progn
|
||||
(goto-char (nth 0 (ess-end-of-function)))
|
||||
(forward-line -1)))
|
||||
(if (ess-roxy-entry-p)
|
||||
(progn
|
||||
(goto-char (ess-roxy-beg-of-entry))
|
||||
t) (forward-line) nil))
|
||||
|
||||
(defun ess-roxy-delete-args ()
|
||||
"remove all args from the entry at point or above the function
|
||||
at point. Return 0 if no deletions were made other wise the point
|
||||
at where the last deletion ended"
|
||||
(save-excursion
|
||||
(let* ((args nil)
|
||||
(cont t)
|
||||
(field-beg 0)
|
||||
entry-beg entry-end field-end)
|
||||
(ess-roxy-goto-end-of-entry)
|
||||
(setq entry-beg (ess-roxy-beg-of-entry))
|
||||
(setq entry-end (ess-roxy-end-of-entry))
|
||||
(goto-char entry-end)
|
||||
(beginning-of-line)
|
||||
(while (and (<= entry-beg (point)) (> entry-beg 0) cont)
|
||||
(if (looking-at
|
||||
(concat ess-roxy-re " *@param"))
|
||||
(progn
|
||||
(setq field-beg (ess-roxy-beg-of-field))
|
||||
(setq field-end (ess-roxy-end-of-field))
|
||||
(delete-region field-beg (+ field-end 1))))
|
||||
(setq cont nil)
|
||||
(if (= (forward-line -1) 0)
|
||||
(setq cont t)))
|
||||
field-beg)))
|
||||
|
||||
(defun ess-roxy-get-args-list-from-entry ()
|
||||
"fill an args list from the entry above the function where the
|
||||
point is"
|
||||
(save-excursion
|
||||
(let* (args entry-beg field-beg field-end args-text arg-name desc)
|
||||
(if (ess-roxy-goto-end-of-entry)
|
||||
(progn
|
||||
(setq roxy-str (ess-roxy-guess-str))
|
||||
(beginning-of-line)
|
||||
(setq entry-beg (ess-roxy-beg-of-entry))
|
||||
(while (and (< entry-beg (point)) (> entry-beg 0))
|
||||
(if (looking-at
|
||||
(concat ess-roxy-re " *@param"))
|
||||
(progn
|
||||
(setq field-beg (ess-roxy-beg-of-field))
|
||||
(setq field-end (ess-roxy-end-of-field))
|
||||
(setq args-text (buffer-substring-no-properties
|
||||
field-beg field-end))
|
||||
(setq args-text
|
||||
(ess-replace-in-string args-text roxy-str ""))
|
||||
(setq args-text
|
||||
(ess-replace-in-string
|
||||
args-text "[[:space:]]*@param *" ""))
|
||||
;; (setq args-text
|
||||
;; (ess-replace-in-string args-text "\n" ""))
|
||||
(string-match "[^[:space:]]*" args-text)
|
||||
(setq arg-name (match-string 0 args-text))
|
||||
(setq desc (replace-regexp-in-string
|
||||
(concat "^" (regexp-quote arg-name) " *") "" args-text))
|
||||
(setq args (cons (list (concat arg-name)
|
||||
(concat desc)) args))))
|
||||
(forward-line -1))
|
||||
args)
|
||||
nil))))
|
||||
|
||||
(defun ess-roxy-toggle-roxy-region (beg end)
|
||||
"Remove prefix roxy string in this region if point is in a roxy
|
||||
region, otherwise prefix all lines with the roxy
|
||||
string. Convenient for editing example fields."
|
||||
(interactive "r")
|
||||
(unless (use-region-p)
|
||||
(error "region is not active"))
|
||||
(ess-roxy-roxy-region beg end (ess-roxy-entry-p)))
|
||||
|
||||
(defun ess-roxy-roxy-region (beg end &optional on)
|
||||
(save-excursion
|
||||
(let (RE to-string
|
||||
(roxy-str (ess-roxy-guess-str)))
|
||||
(narrow-to-region beg (- end 1))
|
||||
(if on
|
||||
(progn (setq RE (concat ess-roxy-re " +?"))
|
||||
(setq to-string ""))
|
||||
(setq RE "^")
|
||||
(setq to-string (concat roxy-str " ")))
|
||||
(goto-char beg)
|
||||
(while (re-search-forward RE (point-max) 'noerror)
|
||||
(replace-match to-string))
|
||||
(widen))))
|
||||
|
||||
(defun ess-roxy-preview ()
|
||||
"Use a (possibly newly) connected R session and the roxygen package
|
||||
`ess-roxy-package' to generate the Rd code for entry at point, place it
|
||||
in a temporary buffer and return that buffer."
|
||||
(let ((beg (ess-roxy-beg-of-entry))
|
||||
(tmpf (make-temp-file "ess-roxy"))
|
||||
(roxy-buf (get-buffer-create " *RoxygenPreview*"))
|
||||
(out-rd-roclet
|
||||
(cond ((string= "roxygen" ess-roxy-package)
|
||||
"make.Rd2.roclet()$parse")
|
||||
;; must not line break strings to avoid getting +s in the output
|
||||
((string= "roxygen2" ess-roxy-package)
|
||||
"(function(P) { if(compareVersion(paste(packageVersion('roxygen2')), '3.0.0') < 0) { ..results <- roxygen2:::roc_process(rd_roclet(), parse.files(P), \"\");cat(vapply(..results, FUN.VALUE=character(1), function(x) { roxygen2:::rd_out_cache$compute(x, format(x))})) } else {..results <- roc_proc_text(rd_roclet(), readChar(P, file.info(P)$size));cat(vapply(..results, format, FUN.VALUE = character(1))) } })")
|
||||
(t (error "need to hard code the roclet output call for roxygen package '%s'"
|
||||
ess-roxy-package))))
|
||||
)
|
||||
(if (= beg 0)
|
||||
(error "Point is not in a Roxygen entry"))
|
||||
(save-excursion
|
||||
(goto-char (ess-roxy-end-of-entry))
|
||||
(forward-line 1)
|
||||
(if (ess-end-of-function nil t)
|
||||
(append-to-file beg (point) tmpf)
|
||||
(while (and (forward-line 1) (not (looking-at "^$"))
|
||||
(not (looking-at ess-roxy-re))))
|
||||
(append-to-file beg (point) tmpf))
|
||||
(ess-force-buffer-current)
|
||||
(ess-command (concat "print(suppressWarnings(require(" ess-roxy-package
|
||||
", quietly=TRUE)))\n") roxy-buf)
|
||||
(with-current-buffer roxy-buf
|
||||
(goto-char 1)
|
||||
(if (search-forward-regexp "FALSE" nil t)
|
||||
(error (concat "Failed to load the " ess-roxy-package " package; "
|
||||
"in R, try install.packages(\"" ess-roxy-package "\")"))))
|
||||
(ess-command (concat out-rd-roclet "(\"" tmpf "\")\n") roxy-buf))
|
||||
(delete-file tmpf)
|
||||
roxy-buf))
|
||||
|
||||
(defun ess-roxy-preview-HTML (&optional visit-instead-of-browse)
|
||||
"Use a (possibly newly) connected R session and the roxygen package to
|
||||
generate a HTML page for the roxygen entry at point and open that
|
||||
buffer in a browser. Visit the HTML file instead of showing it in
|
||||
a browser if `visit-instead-of-browse' is non-nil."
|
||||
(interactive "P")
|
||||
(let* ((roxy-buf (ess-roxy-preview))
|
||||
(rd-tmp-file (make-temp-file "ess-roxy-" nil ".Rd"))
|
||||
(html-tmp-file (make-temp-file "ess-roxy-" nil ".html"))
|
||||
(rd-to-html (concat "Rd2HTML(\"" rd-tmp-file "\",\""
|
||||
html-tmp-file "\", stages=c(\"render\"))"))
|
||||
)
|
||||
(with-current-buffer roxy-buf
|
||||
(set-visited-file-name rd-tmp-file)
|
||||
(save-buffer)
|
||||
(kill-buffer roxy-buf))
|
||||
(ess-force-buffer-current)
|
||||
(ess-command "print(suppressWarnings(require(tools, quietly=TRUE)))\n")
|
||||
(if visit-instead-of-browse
|
||||
(progn
|
||||
(ess-command (concat rd-to-html "\n"))
|
||||
(find-file html-tmp-file))
|
||||
(ess-command (concat "browseURL(" rd-to-html ")\n")))))
|
||||
|
||||
(defun ess-roxy-preview-text ()
|
||||
"Use the connected R session and the roxygen package to
|
||||
generate the text help page of the roxygen entry at point."
|
||||
(interactive)
|
||||
(with-current-buffer (ess-roxy-preview)
|
||||
(Rd-preview-help)))
|
||||
|
||||
(defun ess-roxy-preview-Rd (&optional name-file)
|
||||
"Use the connected R session and the roxygen package to
|
||||
generate the Rd code for the roxygen entry at point. If called
|
||||
with a non-nil `name-file' (e.g. universal argument C-u),
|
||||
also set the visited file name of the created buffer to
|
||||
facilitate saving that file."
|
||||
(interactive "P")
|
||||
(let ((roxy-buf (ess-roxy-preview)))
|
||||
(pop-to-buffer roxy-buf)
|
||||
(if name-file
|
||||
(save-excursion
|
||||
(goto-char 1)
|
||||
(search-forward-regexp "name{\\(.+\\)}")
|
||||
(set-visited-file-name (concat (match-string 1) ".Rd"))))
|
||||
(Rd-mode)))
|
||||
|
||||
(defun ess-roxy-guess-str (&optional not-here)
|
||||
"guess the prefix used in the current roxygen block. If
|
||||
`not-here' is non-nil, guess the prefix for nearest roxygen
|
||||
block before the point"
|
||||
(save-excursion
|
||||
(if (ess-roxy-entry-p)
|
||||
(progn
|
||||
(goto-char (point-at-bol))
|
||||
(search-forward-regexp ess-roxy-re))
|
||||
(if not-here
|
||||
(search-backward-regexp ess-roxy-re)))
|
||||
(if (or not-here (ess-roxy-entry-p))
|
||||
(match-string 0)
|
||||
ess-roxy-str)))
|
||||
|
||||
(defun ess-roxy-hide-block ()
|
||||
"hide current roxygen comment block"
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(let ((end-of-entry (ess-roxy-end-of-entry))
|
||||
(beg-of-entry (ess-roxy-beg-of-entry)))
|
||||
(hs-hide-block-at-point nil (list beg-of-entry end-of-entry)))))
|
||||
|
||||
(defun ess-roxy-toggle-hiding ()
|
||||
"Toggle hiding/showing of a block.
|
||||
See `hs-show-block' and `ess-roxy-hide-block'."
|
||||
(interactive)
|
||||
(hs-life-goes-on
|
||||
(if (hs-overlay-at (point-at-eol))
|
||||
(hs-show-block)
|
||||
(ess-roxy-hide-block))))
|
||||
|
||||
(defun ess-roxy-show-all ()
|
||||
"Hide all Roxygen entries in current buffer. "
|
||||
(interactive)
|
||||
(ess-roxy-hide-all t))
|
||||
|
||||
(defun ess-roxy-hide-all (&optional show)
|
||||
"Hide all Roxygen entries in current buffer. "
|
||||
(interactive)
|
||||
(hs-life-goes-on
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward (concat ess-roxy-re) (point-max) t 1)
|
||||
(let ((end-of-entry (ess-roxy-end-of-entry)))
|
||||
(if show
|
||||
(hs-show-block)
|
||||
(ess-roxy-hide-block))
|
||||
(goto-char end-of-entry)
|
||||
(forward-line 1))))))
|
||||
|
||||
(defun ess-roxy-previous-entry ()
|
||||
"Go to beginning of previous Roxygen entry. "
|
||||
(interactive)
|
||||
(if (ess-roxy-entry-p)
|
||||
(progn
|
||||
(goto-char (ess-roxy-beg-of-entry))
|
||||
(forward-line -1)))
|
||||
(search-backward-regexp ess-roxy-re (point-min) t 1)
|
||||
(goto-char (ess-roxy-beg-of-entry)))
|
||||
|
||||
(defun ess-roxy-next-entry ()
|
||||
"Go to beginning of next Roxygen entry. "
|
||||
(interactive)
|
||||
(if (ess-roxy-entry-p)
|
||||
(progn
|
||||
(goto-char (ess-roxy-end-of-entry))
|
||||
(forward-line 1)))
|
||||
(search-forward-regexp ess-roxy-re (point-max) t 1)
|
||||
(goto-char (ess-roxy-beg-of-entry)))
|
||||
|
||||
(defun ess-roxy-get-function-args ()
|
||||
"Return the arguments specified for the current function as a
|
||||
list of strings."
|
||||
(save-excursion
|
||||
(let ((args-txt
|
||||
(progn
|
||||
(ess-beginning-of-function)
|
||||
(buffer-substring-no-properties
|
||||
(progn
|
||||
(search-forward-regexp "\\([=,-]+ *function *\\|^\s*function\\)" nil nil 1)
|
||||
(+ (point) 1))
|
||||
(progn
|
||||
(ess-roxy-match-paren)
|
||||
(point))))))
|
||||
(setq args-txt (replace-regexp-in-string "#+[^\"']*\n" "" args-txt))
|
||||
(setq args-txt (replace-regexp-in-string "([^)]+)" "" args-txt))
|
||||
(setq args-txt (replace-regexp-in-string "=[^,]+" "" args-txt))
|
||||
(setq args-txt (replace-regexp-in-string "[ \t\n]+" "" args-txt))
|
||||
(split-string args-txt ","))))
|
||||
|
||||
(defun ess-roxy-match-paren ()
|
||||
"Go to the matching parenthesis"
|
||||
(cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
|
||||
((looking-at "\\s\)") (forward-char 1) (backward-list 1))))
|
||||
|
||||
(defun ess-roxy-complete-tag ()
|
||||
"complete the tag at point"
|
||||
(let ((token-string (thing-at-point 'symbol)))
|
||||
(when (and token-string (string-match "@.+" token-string))
|
||||
(comint-dynamic-simple-complete
|
||||
(replace-regexp-in-string "^@" "" token-string)
|
||||
(append ess-roxy-tags-noparam ess-roxy-tags-param)))))
|
||||
|
||||
(defun ess-roxy-tag-completion ()
|
||||
"Completion data for emacs >= 24"
|
||||
(when (save-excursion (re-search-backward "@\\<\\(\\w*\\)" (point-at-bol) t))
|
||||
(let ((token (match-string-no-properties 1))
|
||||
(beg (match-beginning 1))
|
||||
(end (match-end 1)))
|
||||
(when (and end (= end (point)))
|
||||
(list beg end (append ess-roxy-tags-noparam ess-roxy-tags-param) :exclusive 'no)))))
|
||||
|
||||
(defun ess-roxy-remove-roxy-re (string)
|
||||
"Remove the `ess-roxy-str' before sending to R process. Useful
|
||||
for sending code from example section. This function is placed
|
||||
in `ess-presend-filter-functions'.
|
||||
"
|
||||
(if (ess-roxy-entry-p)
|
||||
(replace-regexp-in-string ess-roxy-re "" string)
|
||||
string))
|
||||
(add-hook 'ess-presend-filter-functions 'ess-roxy-remove-roxy-re nil)
|
||||
|
||||
(defun ess-roxy-find-par-end (stop-point &rest stoppers)
|
||||
(mapc #'(lambda (stopper)
|
||||
(when (and (> stop-point (point))
|
||||
(save-excursion
|
||||
(re-search-forward stopper stop-point t)))
|
||||
(setq stop-point (match-beginning 0))))
|
||||
stoppers)
|
||||
(save-excursion
|
||||
(goto-char stop-point)
|
||||
(line-end-position 0)))
|
||||
|
||||
(defmacro ess-roxy-with-filling-context (&rest body)
|
||||
(declare (indent 0) (debug (&rest form)))
|
||||
`(let ((comment-start "#+'[ \t]+#")
|
||||
(comment-start-skip "#+'[ \t]+# *")
|
||||
(comment-use-syntax nil)
|
||||
(adaptive-fill-first-line-regexp (concat ess-roxy-re "[ \t]*"))
|
||||
(temp-table (make-syntax-table S-syntax-table))
|
||||
(paragraph-start (concat "\\(" ess-roxy-re "\\(" paragraph-start
|
||||
"\\|[ \t]*@" "\\)" "\\)\\|\\(" paragraph-start "\\)")))
|
||||
;; Prevent the roxy prefix to be interpreted as comment or string
|
||||
;; starter
|
||||
(modify-syntax-entry ?# "w" temp-table)
|
||||
(modify-syntax-entry ?' "w" temp-table)
|
||||
;; Neutralise (comment-normalize-vars) because it modifies the
|
||||
;; comment-start regexp in such a way that paragraph filling of
|
||||
;; comments in @examples fields does not work
|
||||
(cl-letf (((symbol-function 'comment-normalize-vars) #'ignore))
|
||||
(with-syntax-table temp-table
|
||||
,@body))))
|
||||
|
||||
(defadvice ess-eval-line-and-step (around ess-eval-line-and-step-roxy)
|
||||
"evaluate line but do not skip over comment (roxy) lines"
|
||||
(if (ess-roxy-entry-p)
|
||||
(let ((simple-next t))
|
||||
ad-do-it)
|
||||
ad-do-it))
|
||||
|
||||
(defadvice ess-indent-command (around ess-roxy-toggle-hiding)
|
||||
"hide this block if we are at the beginning of the line"
|
||||
(if (and (= (point) (point-at-bol)) (ess-roxy-entry-p) 'ess-roxy-hide-show-p)
|
||||
(progn (ess-roxy-toggle-hiding))
|
||||
ad-do-it))
|
||||
|
||||
(defadvice fill-paragraph (around ess-roxy-fill-advise)
|
||||
"Fill roxygen paragraphs."
|
||||
(cond
|
||||
;; Regular case
|
||||
((not (and (eq major-mode 'ess-mode)
|
||||
(string= ess-dialect "R")))
|
||||
ad-do-it)
|
||||
;; Filling of code comments in @examples roxy field
|
||||
((and (ess-roxy-entry-p)
|
||||
(save-excursion
|
||||
(back-to-indentation)
|
||||
(looking-at "#")))
|
||||
(ess-roxy-with-filling-context
|
||||
ad-do-it))
|
||||
((and (not (ess-roxy-entry-p))
|
||||
(ess-point-in-comment-p))
|
||||
ad-do-it)
|
||||
;; Filling of call arguments with point on call name
|
||||
((and ess-fill-calls
|
||||
(ess-point-on-call-name-p))
|
||||
(save-excursion
|
||||
(skip-chars-forward "^([")
|
||||
(forward-char)
|
||||
(ess-fill-args)))
|
||||
;; Filling of continuations
|
||||
((and ess-fill-continuations
|
||||
(ess-point-in-continuation-p))
|
||||
(ess-fill-continuations))
|
||||
;; Filling of call arguments
|
||||
((and ess-fill-calls
|
||||
(ess-point-in-call-p))
|
||||
(ess-fill-args))
|
||||
;; Filling of roxy blocks
|
||||
((ess-roxy-entry-p)
|
||||
(save-excursion
|
||||
(let* ((saved-pos (point))
|
||||
(saved-line (line-number-at-pos))
|
||||
(saved-col (current-column))
|
||||
(buffer (current-buffer))
|
||||
(par-start (save-excursion
|
||||
(if (save-excursion
|
||||
(and (backward-paragraph)
|
||||
(forward-paragraph)
|
||||
(<= (point) saved-pos)))
|
||||
(line-beginning-position)
|
||||
(progn (backward-paragraph) (point)))))
|
||||
(par-end (ess-roxy-find-par-end
|
||||
(save-excursion
|
||||
(forward-paragraph)
|
||||
(point))
|
||||
(concat ess-roxy-re "[ \t]*@examples\\b") "^[^#]")))
|
||||
;; Refill the whole structural paragraph sequentially, field by
|
||||
;; field, stopping at @examples
|
||||
(ess-roxy-with-filling-context
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(narrow-to-region par-start par-end)
|
||||
(goto-char 0)
|
||||
(while (< (point) (point-max))
|
||||
(ess-roxy-maybe-indent-line)
|
||||
ad-do-it
|
||||
(forward-paragraph))))))))
|
||||
(t
|
||||
ad-do-it)))
|
||||
|
||||
(defadvice move-beginning-of-line (around ess-roxy-beginning-of-line)
|
||||
"move to start"
|
||||
(if (ess-roxy-entry-p)
|
||||
(let ((new-pos (save-excursion
|
||||
(end-of-line)
|
||||
(and (re-search-backward (concat ess-roxy-re " ?") (point-at-bol) t)
|
||||
(match-end 0)))))
|
||||
(if (or (bolp)
|
||||
(< new-pos (point)))
|
||||
(goto-char new-pos)
|
||||
ad-do-it))
|
||||
ad-do-it))
|
||||
|
||||
(defadvice back-to-indentation (around ess-roxy-back-to-indentation)
|
||||
"Handle back-to-indentation in roxygen doc"
|
||||
(if (ess-roxy-entry-p)
|
||||
(progn
|
||||
(end-of-line)
|
||||
(re-search-backward (concat ess-roxy-re " *") (point-at-bol) t)
|
||||
(goto-char (match-end 0)))
|
||||
ad-do-it))
|
||||
|
||||
(defun ess-roxy-indent-new-comment-line ()
|
||||
(if (not (ess-roxy-entry-p))
|
||||
(indent-new-comment-line)
|
||||
(ess-roxy-indent-on-newline)))
|
||||
|
||||
(defun ess-roxy-newline-and-indent ()
|
||||
(if (or (not (ess-roxy-entry-p))
|
||||
(not ess-roxy-insert-prefix-on-newline))
|
||||
(newline-and-indent)
|
||||
(ess-roxy-indent-on-newline)))
|
||||
|
||||
(defun ess-roxy-indent-on-newline ()
|
||||
"Insert a newline in a roxygen field."
|
||||
(cond
|
||||
;; Point at beginning of first line of entry; do nothing
|
||||
((= (point) (ess-roxy-beg-of-entry))
|
||||
(newline-and-indent))
|
||||
;; Otherwise: skip over roxy comment string if necessary and then
|
||||
;; newline and then inset new roxy comment string
|
||||
(t
|
||||
(let ((point-after-roxy-string
|
||||
(save-excursion (forward-line 0)
|
||||
(ess-back-to-roxy)
|
||||
(point))))
|
||||
(goto-char (max (point) point-after-roxy-string)))
|
||||
(newline-and-indent)
|
||||
(insert (concat (ess-roxy-guess-str t) " ")))))
|
||||
|
||||
|
||||
(provide 'ess-roxy)
|
||||
|
||||
;;; ess-roxy.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-roxy.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-roxy.elc
Normal file
Binary file not shown.
452
.emacs.d/elpa/ess-20160208.453/lisp/ess-rutils.el
Normal file
452
.emacs.d/elpa/ess-20160208.453/lisp/ess-rutils.el
Normal file
@@ -0,0 +1,452 @@
|
||||
;;; ess-rutils.el --- R functions and keybindings to use in iESS.
|
||||
|
||||
;; Author: Sebastian Luque <sluque@gmail.com>
|
||||
;; Created: Thu Nov 10 02:20:36 2004 (UTC)
|
||||
;; Last-Updated: 2013-09-22T16:08:47+0000
|
||||
;; By: Sebastian P. Luque
|
||||
;; Version: $Id$
|
||||
;; Compatibility: GNU Emacs >= 22.0.50.1
|
||||
|
||||
;; Copyright (c) 2005-2013 Sebastian P. Luque
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This library provides key bindings for performing basic R functions,
|
||||
;; such as loading and managing packages, as well as object manipulation
|
||||
;; (listing, viewing, and deleting), and an alternative to RSiteSearch()
|
||||
;; that uses the browse-url function. Load the library with the method you
|
||||
;; prefer (e.g. M-x load-file), but the easiest is probably to: a) make
|
||||
;; sure your load-path variable includes the directory where ess-rutils.el
|
||||
;; resides, and b) include (require 'ess-rutils) statement in your
|
||||
;; ~/.emacs.
|
||||
;;
|
||||
;; Usage:
|
||||
;;
|
||||
;; Once R is started with M-x R, you should have the key bindings defined
|
||||
;; at the end of this file working in your iESS process buffers. Simply
|
||||
;; type the desired key binding.
|
||||
;;
|
||||
;; Acknowledgements:
|
||||
;;
|
||||
;; I am grateful to John Fox for having written his init.el file for
|
||||
;; XEmacs, which motivated this Emacs alternative. I wanted to add some
|
||||
;; object management comforts and came across Stephen Eglen's
|
||||
;; ess-rdired.el, which provides a lot of these. ess-rutils.el builds upon
|
||||
;; on a *lot* of ideas from ess-rdired.el.
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; Autoloads and requires
|
||||
(autoload 'ess-rdired "ess-rdired" "View *R* objects in a dired-like buffer." t)
|
||||
(require 'ess-site)
|
||||
|
||||
(defvar ess-rutils-buf "*R temp*"
|
||||
"Name of temporary R buffer.")
|
||||
|
||||
(defvar ess-rutils-mode-map nil
|
||||
"Keymap for the *R temp* buffer.")
|
||||
|
||||
(defvar ess-rutils-rhtml-fn
|
||||
(expand-file-name "ess-rutils-help-start.R" ess-etc-directory)
|
||||
"Path to the file defining the R function .rutils.help.start().
|
||||
This file is loaded into the inferior R process so that
|
||||
`ess-rutils-html-docs' can use .rutils.help.start().")
|
||||
|
||||
(if ess-rutils-mode-map
|
||||
()
|
||||
(setq ess-rutils-mode-map (make-sparse-keymap))
|
||||
(define-key ess-rutils-mode-map "l" 'ess-rutils-loadpkg)
|
||||
(define-key ess-rutils-mode-map "i" 'ess-rutils-mark-install)
|
||||
(define-key ess-rutils-mode-map "I" 'ess-rutils-install)
|
||||
(define-key ess-rutils-mode-map "u" 'ess-rutils-unmark)
|
||||
(define-key ess-rutils-mode-map "q" 'ess-rutils-quit)
|
||||
(define-key ess-rutils-mode-map "?" 'ess-rutils-help))
|
||||
|
||||
(defun ess-rutils-mode ()
|
||||
"Major mode for output from `ess-rutils-local-pkgs' and `ess-rutils-repos-pkgs'.
|
||||
Useful bindings to handle package loading and installing.
|
||||
\\{ess-rutils-mode-map}"
|
||||
(kill-all-local-variables)
|
||||
(use-local-map ess-rutils-mode-map)
|
||||
(setq major-mode 'ess-rutils-mode)
|
||||
(setq mode-name (concat "R utils " ess-local-process-name)))
|
||||
|
||||
(defun ess-rutils-local-pkgs ()
|
||||
"List all packages in all libraries."
|
||||
(interactive)
|
||||
(if (get-buffer ess-rutils-buf)
|
||||
(progn
|
||||
(set-buffer ess-rutils-buf)
|
||||
(setq buffer-read-only nil)))
|
||||
(ess-execute
|
||||
"writeLines(paste(' ', sort(.packages(all.available=TRUE)), sep=''))"
|
||||
nil
|
||||
(substring ess-rutils-buf 1 (- (length ess-rutils-buf) 1)))
|
||||
(pop-to-buffer ess-rutils-buf)
|
||||
(save-excursion
|
||||
(beginning-of-line) (open-line 1)
|
||||
(insert "**Available packages in all local R libraries**"))
|
||||
(setq buffer-read-only t)
|
||||
(ess-rutils-mode)
|
||||
(if (featurep 'fit-frame)
|
||||
(fit-frame)))
|
||||
|
||||
(defun ess-rutils-namepkg ()
|
||||
"Return name of the package on current line."
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(if (looking-at "*")
|
||||
nil
|
||||
(forward-char 2)
|
||||
(let (beg)
|
||||
(setq beg (point))
|
||||
(end-of-line) ;assume package names are separated by newlines.
|
||||
(buffer-substring-no-properties beg (point))))))
|
||||
|
||||
(defun ess-rutils-loadpkg ()
|
||||
"Load package from a library."
|
||||
(interactive)
|
||||
(let ((oklocal nil))
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(if (search-forward "libraries**" nil t)
|
||||
(setq oklocal t)))
|
||||
(if oklocal
|
||||
(progn
|
||||
(setq pkg (ess-rutils-namepkg))
|
||||
(ess-execute (concat "library('" pkg "', character.only=TRUE)")
|
||||
'buffer))
|
||||
nil)))
|
||||
|
||||
(defun ess-rutils-repos-pkgs ()
|
||||
"List available packages from the repositories as listed by
|
||||
getOptions(\"repos\") in the current R session."
|
||||
(interactive)
|
||||
(if (get-buffer ess-rutils-buf)
|
||||
(progn
|
||||
(set-buffer ess-rutils-buf)
|
||||
(setq buffer-read-only nil)))
|
||||
(ess-execute (concat "writeLines(paste(' \"', "
|
||||
"rownames(available.packages()), '\"', sep=''))")
|
||||
nil
|
||||
(substring ess-rutils-buf 1 (- (length ess-rutils-buf) 1)))
|
||||
(pop-to-buffer ess-rutils-buf)
|
||||
(save-excursion
|
||||
(kill-line 5)
|
||||
(insert "**packages available to install**\n"))
|
||||
(setq buffer-read-only t)
|
||||
(ess-rutils-mode)
|
||||
(if (featurep 'fit-frame)
|
||||
(fit-frame)))
|
||||
|
||||
(defun ess-rutils-mark-install (arg)
|
||||
"Mark the current package for installing.
|
||||
ARG lines to mark is passed to `ess-rutils-mark'."
|
||||
(interactive "p")
|
||||
;; if this is not an install package buffer return nil.
|
||||
(let ((okmark nil))
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(if (search-forward "install**" nil t)
|
||||
(setq okmark t)))
|
||||
(if okmark
|
||||
(ess-rutils-mark "I" arg)
|
||||
nil)))
|
||||
|
||||
(defun ess-rutils-unmark (arg)
|
||||
"Unmark the packages, passing ARG lines to unmark to `ess-rutils-mark'."
|
||||
(interactive "p")
|
||||
(ess-rutils-mark " " arg))
|
||||
|
||||
;; The next two functions almost verbatim from ess-rdired.el.
|
||||
(defun ess-rutils-mark (mark-char arg)
|
||||
"Use MARK-CHAR to mark package on current line, or next ARG lines."
|
||||
;; If we are on first line, mark all lines.
|
||||
(let ((buffer-read-only nil)
|
||||
move)
|
||||
(if (eq (point-min)
|
||||
(save-excursion (beginning-of-line) (point)))
|
||||
(progn
|
||||
;; we are on first line, so make a note of point, and count
|
||||
;; how many objects we want to delete. Then at end of defun,
|
||||
;; restore point.
|
||||
(setq move (point))
|
||||
(forward-line 1)
|
||||
(setq arg (count-lines (point) (point-max)))))
|
||||
(while (and (> arg 0) (not (eobp)))
|
||||
(setq arg (1- arg))
|
||||
(beginning-of-line)
|
||||
(progn
|
||||
(insert mark-char)
|
||||
(delete-char 1)
|
||||
(forward-line 1)))
|
||||
(if move
|
||||
(goto-char move))))
|
||||
|
||||
(defun ess-rutils-install ()
|
||||
"Install all packages flagged for installation, and return to the iESS buffer.
|
||||
User is asked for confirmation."
|
||||
(interactive)
|
||||
(let ((inst "install.packages(c(")
|
||||
(count 0))
|
||||
(save-excursion
|
||||
(goto-line 2)
|
||||
;; as long as number of lines between buffer start and point is smaller
|
||||
;; than the total number of lines in buffer, go to the beginning of the
|
||||
;; line, check if line is flagged, and if it is, advance the counter by
|
||||
;; one, create the root of install function, add the package name,
|
||||
;; insert a comma, and move forward a line.
|
||||
(while (< (count-lines (point-min) (point))
|
||||
(count-lines (point-min) (point-max)))
|
||||
(beginning-of-line)
|
||||
(if (looking-at "^I ")
|
||||
(setq count (1+ count)
|
||||
inst (concat inst (ess-rutils-namepkg) ", " )))
|
||||
(forward-line 1)))
|
||||
(if (> count 0) ;found packages to install
|
||||
(progn
|
||||
;; Fix the install function created before and close it.
|
||||
(setq inst (concat
|
||||
(substring inst 0 (- (length inst) 2)) "))"))
|
||||
;;
|
||||
(if (yes-or-no-p (format "Install %d %s " count
|
||||
(if (> count 1) "packages" "package")))
|
||||
(progn
|
||||
(ess-execute inst 'buffer)
|
||||
(ess-rutils-quit))))
|
||||
;; else nothing to install
|
||||
(message "no packages flagged to install"))))
|
||||
|
||||
(defun ess-rutils-update-pkgs (lib repos)
|
||||
"Update packages in library LIB and repos REPOS. Defaults are the first
|
||||
element returned by .libPaths() for LIB, and the repository named CRAN
|
||||
returned by getOption(\"repos\") for REPOS. This also uses checkBuilt=TRUE
|
||||
to rebuild installed packages if needed."
|
||||
(interactive "DPath to library to update: \nsrepos: ")
|
||||
(if (string= "" lib)
|
||||
(setq lib
|
||||
(car (ess-get-words-from-vector
|
||||
"as.character(.libPaths())\n"))))
|
||||
(if (string= "" repos)
|
||||
(setq repos
|
||||
(car (ess-get-words-from-vector
|
||||
"as.character(getOption(\"repos\")[\"CRAN\"])\n"))))
|
||||
(ess-execute (concat "update.packages(lib.loc='"
|
||||
lib "', repos='" repos
|
||||
"', ask=FALSE, checkBuilt=TRUE)") 'buffer))
|
||||
|
||||
(defun ess-rutils-apropos (string)
|
||||
"Search for STRING using apropos."
|
||||
(interactive "sApropos search for? ")
|
||||
(if (get-buffer ess-rutils-buf)
|
||||
(progn
|
||||
(set-buffer ess-rutils-buf)
|
||||
(setq buffer-read-only nil)))
|
||||
(ess-execute (concat "apropos('" string "')")
|
||||
nil
|
||||
(substring ess-rutils-buf 1 (- (length ess-rutils-buf) 1)))
|
||||
(pop-to-buffer ess-rutils-buf)
|
||||
(setq buffer-read-only t)
|
||||
(ess-rutils-mode))
|
||||
|
||||
(defun ess-rutils-rm-all ()
|
||||
"Remove all R objects."
|
||||
(interactive)
|
||||
(if (y-or-n-p "Delete all objects? ")
|
||||
(ess-execute "rm(list=ls())" 'buffer)))
|
||||
|
||||
(defun ess-rutils-objs ()
|
||||
"Manipulate R objects; wrapper for `ess-rdired'."
|
||||
(interactive)
|
||||
(ess-rdired)
|
||||
(if (featurep 'fit-frame)
|
||||
(fit-frame)))
|
||||
|
||||
(defun ess-rutils-load-wkspc (file)
|
||||
"Load workspace FILE into R."
|
||||
(interactive "fFile with workspace to load: ")
|
||||
(ess-execute (concat "load('" file "')") 'buffer))
|
||||
|
||||
(defun ess-rutils-save-wkspc (file)
|
||||
"Save FILE workspace.
|
||||
File extension not required."
|
||||
(interactive "FSave workspace to file (no extension): ")
|
||||
(ess-execute (concat "save.image('" file ".RData')") 'buffer))
|
||||
|
||||
(defun ess-rutils-quit ()
|
||||
"Kill the ess-rutils buffer and return to the iESS buffer."
|
||||
(interactive)
|
||||
(ess-switch-to-end-of-ESS)
|
||||
(kill-buffer ess-rutils-buf))
|
||||
|
||||
(defun ess-rutils-html-docs (&optional remote)
|
||||
"Use `browse-url' to navigate R html documentation.
|
||||
Documentation is produced by a modified help.start(), that returns the URL
|
||||
produced by GNU R's http server. This function is defined in a file given
|
||||
by the path in variable `ess-rutils-rhtml-fn'. If called with a prefix,
|
||||
the modified help.start() is called with update=TRUE. The optional REMOTE
|
||||
argument should be a string with a valid URL for the 'R_HOME' directory on
|
||||
a remote server (defaults to NULL)."
|
||||
(interactive)
|
||||
(let* ((update (if current-prefix-arg "update=TRUE" "update=FALSE"))
|
||||
(remote (if (or (and remote (not (string= "" remote))))
|
||||
(concat "remote=" remote) "remote=NULL"))
|
||||
(rhtml (format ".rutils.help.start(%s, %s)\n" update remote))
|
||||
(tmpbuf (get-buffer-create "**ess-rutils-mode**")))
|
||||
(ess-command rhtml tmpbuf)
|
||||
(set-buffer tmpbuf)
|
||||
(let* ((begurl (search-backward "http://"))
|
||||
(endurl (search-forward "index.html"))
|
||||
(url (buffer-substring-no-properties begurl endurl)))
|
||||
(browse-url url))
|
||||
(kill-buffer tmpbuf)))
|
||||
|
||||
(defun ess-rutils-rsitesearch (string)
|
||||
"Search the R archives for STRING, using default criteria, and show results
|
||||
using `browse-url'. If called with a prefix, options are offered (with
|
||||
completion) for matches per page, sections of the archives to search,
|
||||
displaying results in long or short formats, and sorting by any given field.
|
||||
Options should be separated by value of `crm-default-separator'."
|
||||
(interactive "sSearch string: ")
|
||||
(let ((site "http://search.r-project.org/cgi-bin/namazu.cgi?query=")
|
||||
(okstring (ess-replace-regexp-in-string " +" "+" string)))
|
||||
(if current-prefix-arg
|
||||
(let ((mpp (concat
|
||||
"&max="
|
||||
(completing-read
|
||||
"Matches per page: "
|
||||
'(("20" 1) ("30" 2) ("40" 3) ("50" 4) ("100" 5)))))
|
||||
(format (concat
|
||||
"&result="
|
||||
(completing-read
|
||||
"Format: " '(("normal" 1) ("short" 2))
|
||||
nil t "normal" nil "normal")))
|
||||
(sortby (concat
|
||||
"&sort="
|
||||
(completing-read
|
||||
"Sort by: "
|
||||
'(("score" 1) ("date:late" 2) ("date:early" 3)
|
||||
("field:subject:ascending" 4)
|
||||
("field:subject:decending" 5)
|
||||
("field:from:ascending" 6) ("field:from:decending" 7)
|
||||
("field:size:ascending" 8) ("field:size:decending" 9))
|
||||
nil t "score" nil "score")))
|
||||
(restrict (concat
|
||||
"&idxname="
|
||||
(mapconcat
|
||||
'identity
|
||||
(completing-read-multiple
|
||||
"Limit search to: "
|
||||
'(("Rhelp02a" 1) ("functions" 2)
|
||||
("docs" 3) ("Rhelp01" 4))
|
||||
nil t "Rhelp02a,functions,docs" nil
|
||||
"Rhelp02a,functions,docs") "&idxname="))))
|
||||
(browse-url (concat site okstring mpp format sortby restrict)))
|
||||
(browse-url (concat site okstring "&max=20&result=normal&sort=score"
|
||||
"&idxname=Rhelp02a&idxname=functions&idxname=docs")))))
|
||||
|
||||
(defun ess-rutils-help ()
|
||||
"Show help on `ess-rutils-mode'."
|
||||
(interactive)
|
||||
(describe-function 'ess-rutils-mode))
|
||||
|
||||
(defun ess-rutils-help-search (string)
|
||||
"Search for STRING using help.search()."
|
||||
(interactive "sString to search for? ")
|
||||
(if (get-buffer ess-rutils-buf)
|
||||
(progn
|
||||
(set-buffer ess-rutils-buf)
|
||||
(setq buffer-read-only nil)))
|
||||
(ess-execute (concat "help.search('" string "')")
|
||||
nil
|
||||
(substring ess-rutils-buf 1 (- (length ess-rutils-buf) 1)))
|
||||
(pop-to-buffer ess-rutils-buf)
|
||||
(setq buffer-read-only t)
|
||||
(ess-rutils-mode))
|
||||
|
||||
;; Customizable variable to allow ess-rutils-keys to activate default key bindings.
|
||||
;; Suggested by Richard M. Heiberger.
|
||||
(defcustom ess-rutils-keys t
|
||||
"Non-nil means activate ess-rutils keybindings and menu."
|
||||
:group 'ess-R
|
||||
:type 'boolean)
|
||||
|
||||
;; Keybindings
|
||||
(defun ess-rutils-keys ()
|
||||
"Provide key bindings."
|
||||
(interactive)
|
||||
(when ess-rutils-keys
|
||||
(define-key inferior-ess-mode-map [(control c) (control \.) (l)]
|
||||
'ess-rutils-local-pkgs)
|
||||
(define-key inferior-ess-mode-map [(control c) (control \.) (r)]
|
||||
'ess-rutils-repos-pkgs)
|
||||
(define-key inferior-ess-mode-map [(control c) (control \.) (u)]
|
||||
'ess-rutils-update-pkgs)
|
||||
(define-key inferior-ess-mode-map [(control c) (control \.) (a)]
|
||||
'ess-rutils-apropos)
|
||||
(define-key inferior-ess-mode-map [(control c) (control \.) (m)]
|
||||
'ess-rutils-rm-all)
|
||||
(define-key inferior-ess-mode-map [(control c) (control \.) (o)]
|
||||
'ess-rutils-objs)
|
||||
(define-key inferior-ess-mode-map [(control c) (control \.) (w)]
|
||||
'ess-rutils-load-wkspc)
|
||||
(define-key inferior-ess-mode-map [(control c) (control \.) (s)]
|
||||
'ess-rutils-save-wkspc)
|
||||
(define-key inferior-ess-mode-map [(control c) (control \.) (d)]
|
||||
'ess-change-directory)
|
||||
(define-key inferior-ess-mode-map [(control c) (control \.) (H)]
|
||||
'ess-rutils-html-docs)))
|
||||
|
||||
(easy-menu-define ess-rutils-mode-menu inferior-ess-mode-menu
|
||||
"Submenu of `inferior-ess-mode' to use with RUtils."
|
||||
'("RUtils"
|
||||
["Manage objects" ess-rutils-objs t]
|
||||
["Remove objects" ess-rutils-rm-all t]
|
||||
"------"
|
||||
["Local packages" ess-rutils-local-pkgs t]
|
||||
["Packages in repositories" ess-rutils-repos-pkgs t]
|
||||
["Update packages" ess-rutils-update-pkgs t]
|
||||
"------"
|
||||
["Load workspace" ess-rutils-load-wkspc t]
|
||||
["Save workspace" ess-rutils-save-wkspc t]
|
||||
["Change directory" ess-change-directory t]
|
||||
"------"
|
||||
["Browse HTML" ess-rutils-html-docs t]
|
||||
["Apropos" ess-rutils-apropos t]))
|
||||
|
||||
(when (featurep 'xemacs)
|
||||
(defun ess-rutils-mode-xemacs-menu ()
|
||||
"Hook to install `ess-rutils-mode' menu for XEmacs (with easymenu)."
|
||||
(if 'inferior-ess-mode
|
||||
;; Why does using nil for 2nd arg put menu at top level?
|
||||
(easy-menu-add-item inferior-ess-mode-menu nil
|
||||
ess-rutils-mode-menu)
|
||||
(easy-menu-remove-item inferior-ess-mode-menu nil
|
||||
ess-rutils-mode-menu)))
|
||||
(add-hook 'inferior-ess-mode-hook 'ess-rutils-mode-xemacs-menu t))
|
||||
|
||||
(unless (featurep 'xemacs)
|
||||
(easy-menu-add-item inferior-ess-mode-menu nil
|
||||
ess-rutils-mode-menu))
|
||||
|
||||
(add-hook 'inferior-ess-mode-hook 'ess-rutils-keys t)
|
||||
(add-hook 'ess-R-post-run-hook
|
||||
(lambda ()
|
||||
(ess--inject-code-from-file ess-rutils-rhtml-fn)) t)
|
||||
|
||||
|
||||
(provide 'ess-rutils)
|
||||
|
||||
;;; ess-rutils.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-rutils.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-rutils.elc
Normal file
Binary file not shown.
903
.emacs.d/elpa/ess-20160208.453/lisp/ess-s-l.el
Normal file
903
.emacs.d/elpa/ess-20160208.453/lisp/ess-s-l.el
Normal file
@@ -0,0 +1,903 @@
|
||||
;;; ess-s-l.el --- Support for editing S source code
|
||||
|
||||
;; Copyright (C) 1989-1997 D. Bates, Kademan, Ritter, D.M. Smith, K. Hornik,
|
||||
;; R.M. Heiberger, M. Maechler, and A.J. Rossini.
|
||||
;; Copyright (C) 1998-2015 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: A.J. Rossini <rossini@biostat.washington.edu>
|
||||
;; Created: 26 Aug 1997
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; This file is part of ESS (Emacs Speaks Statistics).
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Code for general editing S source code (specializes to S, S+, R).
|
||||
|
||||
;;; Code:
|
||||
|
||||
; Requires and autoloads
|
||||
|
||||
(ess-message "[ess-s-l:] (def** ) only ...")
|
||||
|
||||
; Configuration variables
|
||||
|
||||
(defvar S-syntax-table
|
||||
(let ((S-syntax-table (make-syntax-table)))
|
||||
(modify-syntax-entry ?\\ "\\" S-syntax-table)
|
||||
(modify-syntax-entry ?+ "." S-syntax-table)
|
||||
(modify-syntax-entry ?- "." S-syntax-table)
|
||||
(modify-syntax-entry ?= "." S-syntax-table)
|
||||
(modify-syntax-entry ?% "." S-syntax-table)
|
||||
(modify-syntax-entry ?< "." S-syntax-table)
|
||||
(modify-syntax-entry ?> "." S-syntax-table)
|
||||
(modify-syntax-entry ?& "." S-syntax-table)
|
||||
(modify-syntax-entry ?| "." S-syntax-table)
|
||||
(modify-syntax-entry ?\' "\"" S-syntax-table)
|
||||
(modify-syntax-entry ?\" "\"" S-syntax-table)
|
||||
(modify-syntax-entry ?# "<" S-syntax-table) ; open comment
|
||||
(modify-syntax-entry ?\n ">" S-syntax-table) ; close comment
|
||||
;;(modify-syntax-entry ?. "w" S-syntax-table) ; "." used in S obj names
|
||||
(modify-syntax-entry ?. "_" S-syntax-table) ; see above/below,
|
||||
; plus consider separation.
|
||||
(modify-syntax-entry ?$ "_" S-syntax-table); foo$comp = 1 symbol(completion)
|
||||
(modify-syntax-entry ?@ "_" S-syntax-table); foo@slot = 1 symbol(completion)
|
||||
(modify-syntax-entry ?_ "_" S-syntax-table)
|
||||
(modify-syntax-entry ?: "_" S-syntax-table)
|
||||
(modify-syntax-entry ?* "." S-syntax-table)
|
||||
(modify-syntax-entry ?< "." S-syntax-table)
|
||||
(modify-syntax-entry ?> "." S-syntax-table)
|
||||
(modify-syntax-entry ?/ "." S-syntax-table)
|
||||
S-syntax-table)
|
||||
"Syntax table for S code."
|
||||
)
|
||||
|
||||
(defvar S-editing-alist
|
||||
'((paragraph-start . (concat "\\s-*$\\|" page-delimiter))
|
||||
(paragraph-separate . (concat "\\s-*$\\|" page-delimiter))
|
||||
(paragraph-ignore-fill-prefix . t)
|
||||
(require-final-newline . mode-require-final-newline)
|
||||
;;(comment-indent-function . 'S-comment-indent)
|
||||
;;(ess-comment-indent . 'S-comment-indent)
|
||||
;;(ess-indent-line . 'S-indent-line)
|
||||
;;(ess-calculate-indent . 'ess-calculate-indent)
|
||||
(indent-line-function . 'ess-indent-line)
|
||||
(parse-sexp-ignore-comments . t)
|
||||
(ess-style . ess-default-style)
|
||||
;;(ess-keep-dump-files . 'ask)
|
||||
(ess-mode-syntax-table . S-syntax-table)
|
||||
;; For Changelog add, require ' ' before <- : "attr<-" is a function name :
|
||||
(add-log-current-defun-header-regexp . "^\\(.+\\)\\s-+<-[ \t\n]*function")
|
||||
(ess-font-lock-keywords . 'ess-S-font-lock-keywords)
|
||||
(ess-font-lock-defaults . (ess--extract-default-fl-keywords ess-S-font-lock-keywords))
|
||||
(font-lock-defaults . '(ess-font-lock-defaults
|
||||
nil nil ((?\. . "w") (?\_ . "w"))))
|
||||
)
|
||||
"General options for S and S+ source files.")
|
||||
|
||||
(defvar inferior-S-language-start
|
||||
'(concat "options("
|
||||
"STERM='" ess-STERM "'"
|
||||
", str.dendrogram.last=\"'\""
|
||||
(if ess-editor (concat ", editor='" ess-editor "'"))
|
||||
(if ess-pager (concat ", pager='" ess-pager "', help.pager='" ess-pager "'"))
|
||||
", show.error.locations=TRUE"
|
||||
")")
|
||||
"S language expression for startup -- default for all S dialects.")
|
||||
|
||||
(defconst S-common-cust-alist
|
||||
'((ess-language . "S")
|
||||
(inferior-ess-exit-command . "q()\n")
|
||||
(inferior-ess-language-start . (eval inferior-S-language-start))
|
||||
(comint-use-prompt-regexp . t) ;;use fields if nil
|
||||
(comint-process-echoes . t)
|
||||
;; these prompt are the same for all S-languages As long as custom prompt
|
||||
;; ends in inferior-ess-primary-prompt everything should work as expected.
|
||||
(inferior-ess-primary-prompt . "> ")
|
||||
;; (inferior-ess-secondary-prompt . "[+:] ") ;; catch Selection: and alike
|
||||
(inferior-ess-secondary-prompt . "+ ") ;; catch Selection: and alike
|
||||
(comment-start . "#")
|
||||
(ess-imenu-generic-expression . ess-imenu-S-generic-expression)
|
||||
(comment-add . 1)
|
||||
(comment-start-skip . "#+ *")
|
||||
(comment-use-syntax . t) ; see log for bug report 2013-06-07
|
||||
(comment-column . 40)
|
||||
(ess-no-skip-regexp . (concat "^ *@\\|" (default-value 'ess-no-skip-regexp)))
|
||||
;; inferior-ess-prompt is used by comint for navigation, only if
|
||||
;; comint-use-prompt-regexp is t; (transcript-mode also relies on this regexp)
|
||||
(inferior-ess-prompt . inferior-S-prompt) ;customizable
|
||||
(ess-get-help-topics-function . 'ess-get-S-help-topics-function)
|
||||
(ess-getwd-command . "getwd()\n")
|
||||
(ess-setwd-command . "setwd('%s')\n")
|
||||
(ess-funargs-command . ".ess_funargs(\"%s\")\n")
|
||||
(fill-nobreak-predicate . 'ess-inside-string-p)
|
||||
(normal-auto-fill-function . 'ess-do-auto-fill)
|
||||
(ess-execute-screen-options-command . "options(width=%d, length=99999)\n")
|
||||
)
|
||||
"S-language common settings for all <dialect>-customize-alist s")
|
||||
|
||||
(defconst S+common-cust-alist
|
||||
(append
|
||||
'((ess-suffix . "S")
|
||||
(ess-mode-syntax-table . S-syntax-table)
|
||||
(ess-help-sec-regex . ess-help-S+-sec-regex)
|
||||
(ess-help-sec-keys-alist . ess-help-S+sec-keys-alist)
|
||||
(ess-change-sp-regexp . ess-S+-change-sp-regexp)
|
||||
(ess-cmd-delay . (if (featurep 'xemacs); needs much less delay
|
||||
(* 0.1 ess-S+-cmd-delay)
|
||||
ess-S+-cmd-delay))
|
||||
(ess-function-pattern . ess-S-function-pattern)
|
||||
(ess-function-template . " <- \n#\nfunction()\n{\n\n}\n")
|
||||
(ess-dump-filename-template . (ess-replace-regexp-in-string
|
||||
"S$" ess-suffix ; in the one from custom:
|
||||
ess-dump-filename-template-proto))
|
||||
(ess-traceback-command . "traceback()\n")
|
||||
(ess-mode-editing-alist . S-editing-alist)
|
||||
|
||||
(ess-dumped-missing-re
|
||||
. "\\(\\(<-\\|=\\)\nDumped\n\\'\\)\\|\\(\\(<-\\|=\\)\\(\\s \\|\n\\)*\\'\\)")
|
||||
(ess-syntax-error-re
|
||||
. "\\(Syntax error: .*\\) at line \\([0-9]*\\), file \\(.*\\)$")
|
||||
(inferior-ess-objects-command . inferior-Splus-objects-command)
|
||||
(ess-describe-object-at-point-commands . 'ess-S-describe-object-at-point-commands)
|
||||
(inferior-ess-font-lock-keywords . 'inferior-S-font-lock-keywords)
|
||||
(ess-editor . S-editor)
|
||||
(ess-pager . S-pager)
|
||||
)
|
||||
S-common-cust-alist)
|
||||
"Common settings for all S+<*>-customize-alist s"
|
||||
)
|
||||
|
||||
;;; Changes from S to S-PLUS 3.x. (standard S3 should be in ess-s-l!).
|
||||
|
||||
(defconst ess-help-S+sec-keys-alist
|
||||
'((?a . "ARGUMENTS:")
|
||||
(?b . "BACKGROUND:")
|
||||
(?B . "BUGS:")
|
||||
(?d . "DESCRIPTION:")
|
||||
(?D . "DETAILS:")
|
||||
(?e . "EXAMPLES:")
|
||||
(?n . "NOTE:")
|
||||
(?O . "OPTIONAL ARGUMENTS:")
|
||||
(?R . "REQUIRED ARGUMENTS:")
|
||||
(?r . "REFERENCES:")
|
||||
(?s . "SEE ALSO:")
|
||||
(?S . "SIDE EFFECTS:")
|
||||
(?u . "USAGE:")
|
||||
(?v . "VALUE:"))
|
||||
"Alist of (key . string) pairs for use in section searching.")
|
||||
;;; `key' indicates the keystroke to use to search for the section heading
|
||||
;;; `string' in an S help file. `string' is used as part of a
|
||||
;;; regexp-search, and so specials should be quoted.
|
||||
|
||||
;; S ver.3 (NOT S-Plus)
|
||||
(defconst ess-help-S3-sec-keys-alist
|
||||
'((?a . "ARGUMENTS:")
|
||||
(?b . "BACKGROUND:")
|
||||
(?B . "BUGS:")
|
||||
(?d . "DESCRIPTION:")
|
||||
(?D . "DETAILS:")
|
||||
(?e . "EXAMPLES:")
|
||||
(?n . "NOTE:")
|
||||
(?r . "REFERENCES:")
|
||||
(?s . "SEE ALSO:")
|
||||
(?S . "SIDE EFFECTS:")
|
||||
(?u . "USAGE:")
|
||||
(?v . "VALUE:"))
|
||||
"Help section keys for S ver.3.")
|
||||
|
||||
;; S ver.4 (NOT S-Plus)
|
||||
(defconst ess-help-S4-sec-keys-alist
|
||||
'((?a . "ARGUMENTS:")
|
||||
(?b . "BACKGROUND:")
|
||||
(?B . "BUGS:")
|
||||
(?d . "DESCRIPTION:")
|
||||
(?D . "DETAILS:")
|
||||
(?e . "EXAMPLES:")
|
||||
(?n . "NOTE:")
|
||||
(?r . "REFERENCES:")
|
||||
(?s . "SEE ALSO:")
|
||||
(?S . "SIDE EFFECTS:")
|
||||
(?u . "USAGE:")
|
||||
(?v . "VALUE:"))
|
||||
"Help section keys for S4.")
|
||||
|
||||
;; R
|
||||
(defconst ess-help-R-sec-keys-alist
|
||||
'((?a . "\\s *Arguments:")
|
||||
(?d . "\\s *Description:")
|
||||
(?D . "\\s *Details:")
|
||||
(?t . "\\s *Details:")
|
||||
(?e . "\\s *Examples:")
|
||||
(?n . "\\s *Note:")
|
||||
(?r . "\\s *References:")
|
||||
(?s . "\\s *See Also:")
|
||||
(?u . "\\s *Usage:")
|
||||
(?v . "\\s *Value[s]?") ;
|
||||
)
|
||||
"Alist of (key . string) pairs for use in help section searching.")
|
||||
|
||||
|
||||
(defconst ess-help-S+-sec-regex "^[A-Z. ---]+:$"
|
||||
"Reg(ular) Ex(pression) of section headers in help file.")
|
||||
|
||||
(defconst ess-help-R-sec-regex "^[A-Z][A-Za-z].+:$"
|
||||
"Reg(ular) Ex(pression) of section headers in help file.")
|
||||
|
||||
;;; S-mode extras of Martin Maechler, Statistik, ETH Zurich.
|
||||
;;; See also ./ess-utils.el
|
||||
|
||||
(defvar ess-function-outline-file
|
||||
(concat ess-etc-directory "/function-outline.S")
|
||||
"The file name of the ess-function outline that is to be inserted at point,
|
||||
when \\[ess-insert-function-outline] is used.
|
||||
Placeholders (substituted `at runtime'): $A$ for `Author', $D$ for `Date'.")
|
||||
|
||||
;; Use the user's own ~/S/emacs-fun.outline if (s)he has one : ---
|
||||
(let ((outline-file (concat (getenv "HOME") "/S/function-outline.S")))
|
||||
(if (file-exists-p outline-file)
|
||||
(setq ess-function-outline-file outline-file)))
|
||||
|
||||
;; Seth's idea; see ess-toggle-S-assign-key below
|
||||
(defvar ess-S-assign-key [?\C-=] ;; = "\C-c=" ; old-default: "_"
|
||||
"This key is mapped to insert `ess-S-assign' (by default '<-'),
|
||||
when \\[ess-toggle-S-assign-key] is called.")
|
||||
|
||||
(defvar ess-S-assign-key-last nil
|
||||
"This caches the previous value (binding) of `ess-S-assign-key'. It allows
|
||||
\\[ess-toggle-S-assign-key] to toggle back to the previous definition.")
|
||||
|
||||
; Function Definitions
|
||||
|
||||
(defun S-comment-indent ()
|
||||
"Indentation for S comments."
|
||||
(if (or (looking-at "###")
|
||||
(and (looking-at "#!") (= 1 (line-number-at-pos))))
|
||||
(current-column)
|
||||
(if (looking-at "##")
|
||||
(let ((tem (ess-calculate-indent)))
|
||||
(if (listp tem) (car tem) tem))
|
||||
(skip-chars-backward " \t")
|
||||
(max (if (bolp) 0 (1+ (current-column)))
|
||||
comment-column))))
|
||||
|
||||
;; VS: these are ess-indent-line and ess-calculate-indent from 2004 already,so
|
||||
;; commented out to avoid confusion:
|
||||
|
||||
;; (defun S-indent-line ()
|
||||
;; "Indent current line as S code.
|
||||
;; Return the amount the indentation changed by."
|
||||
;; (let ((indent (S-calculate-indent nil))
|
||||
;; beg shift-amt
|
||||
;; (case-fold-search nil)
|
||||
;; (pos (- (point-max) (point))))
|
||||
;; (beginning-of-line)
|
||||
;; (setq beg (point))
|
||||
;; (cond ((eq indent nil)
|
||||
;; (setq indent (current-indentation)))
|
||||
;; (t
|
||||
;; (skip-chars-forward " \t")
|
||||
;; (cond ((and ess-indent-with-fancy-comments ;; ### or #!
|
||||
;; (or (looking-at "###")
|
||||
;; (and (looking-at "#!") (= 1 (line-number-at-pos)))))
|
||||
;; (setq indent 0))
|
||||
;; ;; Single # comment
|
||||
;; ((and ess-indent-with-fancy-comments
|
||||
;; (looking-at "#") (not (looking-at "##")))
|
||||
;; (setq indent comment-column))
|
||||
;; (t
|
||||
;; (if (eq indent t) (setq indent 0))
|
||||
;; (if (listp indent) (setq indent (car indent)))
|
||||
;; (cond ((and (looking-at "else\\b")
|
||||
;; (not (looking-at "else\\s_")))
|
||||
;; (setq indent (save-excursion
|
||||
;; (ess-backward-to-start-of-if)
|
||||
;; (+ ess-else-offset (current-indentation)))))
|
||||
;; ((= (following-char) ?})
|
||||
;; (setq indent
|
||||
;; (+ indent
|
||||
;; (- ess-close-brace-offset ess-indent-offset))))
|
||||
;; ((= (following-char) ?{)
|
||||
;; (setq indent (+ indent ess-brace-offset))))))))
|
||||
;; (skip-chars-forward " \t")
|
||||
;; (setq shift-amt (- indent (current-column)))
|
||||
;; (if (zerop shift-amt)
|
||||
;; (if (> (- (point-max) pos) (point))
|
||||
;; (goto-char (- (point-max) pos)))
|
||||
;; (delete-region beg (point))
|
||||
;; (indent-to indent)
|
||||
;; ;; If initial point was within line's indentation,
|
||||
;; ;; position after the indentation.
|
||||
;; ;; Else stay at same point in text.
|
||||
;; (if (> (- (point-max) pos) (point))
|
||||
;; (goto-char (- (point-max) pos))))
|
||||
;; shift-amt))
|
||||
|
||||
;; (defun S-calculate-indent (&optional parse-start)
|
||||
;; "Return appropriate indentation for current line as S code.
|
||||
;; In usual case returns an integer: the column to indent to.
|
||||
;; Returns nil if line starts inside a string, t if in a comment."
|
||||
;; (save-excursion
|
||||
;; (beginning-of-line)
|
||||
;; (let ((indent-point (point))
|
||||
;; (beginning-of-defun-function nil) ;; don't call ess-beginning-of-function
|
||||
;; (case-fold-search nil)
|
||||
;; state
|
||||
;; containing-sexp)
|
||||
;; (if parse-start
|
||||
;; (goto-char parse-start)
|
||||
;; (beginning-of-defun))
|
||||
;; (while (< (point) indent-point)
|
||||
;; (setq parse-start (point))
|
||||
;; (setq state (parse-partial-sexp (point) indent-point 0))
|
||||
;; (setq containing-sexp (car (cdr state))))
|
||||
;; (cond ((or (nth 3 state) (nth 4 state))
|
||||
;; ;; return nil or t if should not change this line
|
||||
;; (nth 4 state))
|
||||
;; ((null containing-sexp)
|
||||
;; ;; Line is at top level. May be data or function definition,
|
||||
;; (beginning-of-line)
|
||||
;; (if (and (/= (following-char) ?\{)
|
||||
;; (save-excursion
|
||||
;; (ess-backward-to-noncomment (point-min))
|
||||
;; (ess-continued-statement-p)))
|
||||
;; ess-continued-statement-offset
|
||||
;; 0)) ; Unless it starts a function body
|
||||
;; ((/= (char-after containing-sexp) ?{)
|
||||
;; ;; line is expression, not statement:
|
||||
;; ;; indent to just after the surrounding open.
|
||||
;; (goto-char containing-sexp)
|
||||
;; (let ((bol (save-excursion (beginning-of-line) (point))))
|
||||
|
||||
;; ;; modified by shiba@isac 7.3.1992
|
||||
;; (cond ((and (numberp ess-expression-offset)
|
||||
;; (re-search-backward "[ \t]*expression[ \t]*" bol t))
|
||||
;; ;; This regexp match every "expression".
|
||||
;; ;; modified by shiba
|
||||
;; ;;(forward-sexp -1)
|
||||
;; (beginning-of-line)
|
||||
;; (skip-chars-forward " \t")
|
||||
;; ;; End
|
||||
;; (+ (current-column) ess-expression-offset))
|
||||
;; ((and (numberp ess-arg-function-offset)
|
||||
;; (re-search-backward
|
||||
;; "=[ \t]*\\s\"?\\(\\w\\|\\s_\\)+\\s\"?[ \t]*"
|
||||
;; bol
|
||||
;; t))
|
||||
;; (forward-sexp -1)
|
||||
;; (+ (current-column) ess-arg-function-offset))
|
||||
;; ;; "expression" is searched before "=".
|
||||
;; ;; End
|
||||
|
||||
;; (t
|
||||
;; (progn (goto-char (1+ containing-sexp))
|
||||
;; (current-column))))))
|
||||
;; (t
|
||||
;; ;; Statement level. Is it a continuation or a new statement?
|
||||
;; ;; Find previous non-comment character.
|
||||
;; (goto-char indent-point)
|
||||
;; (ess-backward-to-noncomment containing-sexp)
|
||||
;; ;; Back up over label lines, since they don't
|
||||
;; ;; affect whether our line is a continuation.
|
||||
;; (while (eq (preceding-char) ?\,)
|
||||
;; (ess-backward-to-start-of-continued-exp containing-sexp)
|
||||
;; (beginning-of-line)
|
||||
;; (ess-backward-to-noncomment containing-sexp))
|
||||
;; ;; Now we get the answer.
|
||||
;; (if (ess-continued-statement-p)
|
||||
;; ;; This line is continuation of preceding line's statement;
|
||||
;; ;; indent ess-continued-statement-offset more than the
|
||||
;; ;; previous line of the statement.
|
||||
;; (progn
|
||||
;; (ess-backward-to-start-of-continued-exp containing-sexp)
|
||||
;; (+ ess-continued-statement-offset (current-column)
|
||||
;; (if (save-excursion (goto-char indent-point)
|
||||
;; (skip-chars-forward " \t")
|
||||
;; (eq (following-char) ?{))
|
||||
;; ess-continued-brace-offset 0)))
|
||||
;; ;; This line starts a new statement.
|
||||
;; ;; Position following last unclosed open.
|
||||
;; (goto-char containing-sexp)
|
||||
;; ;; Is line first statement after an open-brace?
|
||||
;; (or
|
||||
;; ;; If no, find that first statement and indent like it.
|
||||
;; (save-excursion
|
||||
;; (forward-char 1)
|
||||
;; (while (progn (skip-chars-forward " \t\n")
|
||||
;; (looking-at "#"))
|
||||
;; ;; Skip over comments following openbrace.
|
||||
;; (forward-line 1))
|
||||
;; ;; The first following code counts
|
||||
;; ;; if it is before the line we want to indent.
|
||||
;; (and (< (point) indent-point)
|
||||
;; (current-column)))
|
||||
;; ;; If no previous statement,
|
||||
;; ;; indent it relative to line brace is on.
|
||||
;; ;; For open brace in column zero, don't let statement
|
||||
;; ;; start there too. If ess-indent-offset is zero, use
|
||||
;; ;; ess-brace-offset + ess-continued-statement-offset
|
||||
;; ;; instead.
|
||||
;; ;; For open-braces not the first thing in a line,
|
||||
;; ;; add in ess-brace-imaginary-offset.
|
||||
;; (+ (if (and (bolp) (zerop ess-indent-offset))
|
||||
;; (+ ess-brace-offset ess-continued-statement-offset)
|
||||
;; ess-indent-offset)
|
||||
;; ;; Move back over whitespace before the openbrace.
|
||||
;; ;; If openbrace is not first nonwhite thing on the line,
|
||||
;; ;; add the ess-brace-imaginary-offset.
|
||||
;; (progn (skip-chars-backward " \t")
|
||||
;; (if (bolp) 0 ess-brace-imaginary-offset))
|
||||
;; ;; If the openbrace is preceded by a parenthesized exp,
|
||||
;; ;; move to the beginning of that;
|
||||
;; ;; possibly a different line
|
||||
;; (progn
|
||||
;; (if (eq (preceding-char) ?\))
|
||||
;; (forward-sexp -1))
|
||||
;; ;; Get initial indentation of the line we are on.
|
||||
;; (current-indentation))))))))))
|
||||
|
||||
(defun ess-insert-function-outline ()
|
||||
"Insert an S function definition `outline' at point.
|
||||
Uses the file given by the variable `ess-function-outline-file'."
|
||||
(interactive)
|
||||
(let ((oldpos (point)))
|
||||
(save-excursion
|
||||
(insert-file-contents ess-function-outline-file)
|
||||
(if (search-forward "$A$" nil t)
|
||||
(replace-match (user-full-name) 'not-upcase 'literal))
|
||||
(goto-char oldpos)
|
||||
(if (search-forward "$D$" nil t)
|
||||
(replace-match (ess-time-string 'clock) 'not-upcase 'literal)))
|
||||
(goto-char (1+ oldpos))))
|
||||
|
||||
|
||||
;; typically bound to M-Enter
|
||||
(defun ess-use-this-dir (&optional no-force-current)
|
||||
"Synchronise the current directory of the S or R process to the one of the current
|
||||
buffer. If that buffer has no associated *R* process, use \\[ess-force-buffer-current],
|
||||
unless prefix argument NO-FORCE-CURRENT is non-nil."
|
||||
(interactive "P")
|
||||
(unless no-force-current (ess-force-buffer-current "R process to use: "))
|
||||
(if ess-local-process-name
|
||||
(let ((cmd (format "setwd('%s')\n" default-directory))
|
||||
)
|
||||
(unless (string= ess-language "S")
|
||||
;; FIXME: generalize this for Stata, SAS, Xlispstat... -- then move to ess-mode.el
|
||||
(error
|
||||
"ESS setting working directory in *%s* not yet implemented for language %s"
|
||||
ess-local-process-name ess-language))
|
||||
(ess-command cmd)
|
||||
(message "Directory of *%s* process set to %s"
|
||||
ess-local-process-name default-directory))
|
||||
;; no local process
|
||||
(message "No *%s* process associated with this buffer." ess-dialect)))
|
||||
|
||||
|
||||
;;*;; S/R Pretty-Editing
|
||||
|
||||
(defun ess-fix-comments (&optional dont-query verbose)
|
||||
"Fix ess-mode buffer so that single-line comments start with at least '##',
|
||||
and ensure space before subsequent text."
|
||||
(interactive "P")
|
||||
(ess-replace-regexp-dump-to-src "#\\([A-Za-z0-9]\\)" "# \\1" nil verbose)
|
||||
(ess-replace-regexp-dump-to-src "^\\([ \t]*#\\)\\([^#]\\)"
|
||||
"\\1#\\2" dont-query verbose))
|
||||
|
||||
(defun ess-dump-to-src (&optional dont-query verbose)
|
||||
"Make the changes in an S - dump() file to improve human readability."
|
||||
(interactive "P")
|
||||
(ess-replace-regexp-dump-to-src "^\"\\([a-z.][a-z.0-9]*\\)\" *<-\n"
|
||||
"\n\\1 <- "
|
||||
dont-query verbose 'ensure-ess))
|
||||
|
||||
(defun ess-num-var-round (&optional dont-query verbose)
|
||||
"Is VERY useful for dump(.)'ed numeric variables; ROUND some of them by
|
||||
replacing endings of 000000*.. and 999999*. Martin Maechler"
|
||||
(interactive "P")
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
|
||||
(let ((num 0)
|
||||
(str "")
|
||||
(rgxp "000000+[1-9]?[1-9]?\\>")
|
||||
(to ""))
|
||||
(if dont-query
|
||||
(ess-rep-regexp rgxp to nil nil verbose)
|
||||
(query-replace-regexp rgxp to nil))
|
||||
|
||||
(while (< num 9)
|
||||
(setq str (concat (int-to-string num) "999999+[0-8]*"))
|
||||
(if (and (numberp verbose) (> verbose 1))
|
||||
(message (format "\nregexp: '%s'" str)))
|
||||
(goto-char (point-min))
|
||||
(ess-rep-regexp str (int-to-string (1+ num))
|
||||
'fixedcase 'literal verbose)
|
||||
(setq num (1+ num))))))
|
||||
|
||||
(defun ess-fix-dot (before-chars &optional dont-query verbose)
|
||||
"Remove trailing decimal '.' (\"dot\"), before BEFORE; typically from S-plus"
|
||||
;; typically, before-chars = "]:" or more
|
||||
(ess-replace-regexp-dump-to-src
|
||||
(concat "\\([0-9]\\)\\.\\( *[" before-chars "]\\)")
|
||||
;; 111 ^
|
||||
"\\1\\2" dont-query verbose))
|
||||
|
||||
(defun ess-fix-dot-1 (&optional do-query verbose)
|
||||
"Remove trailing decimal '.' (\"dot\"), before ':' or ']', i.e.,
|
||||
in cases where it's ugly and nonsense. DO-QUERY(prefix) asks before replacing."
|
||||
(interactive "P")
|
||||
(ess-fix-dot "]:" (not do-query) verbose))
|
||||
|
||||
(defun ess-fix-dot-more (&optional dont-query verbose)
|
||||
"Remove trailing decimal '.' (\"dot\", typically from S+) in more cases
|
||||
than `ess-fix-dot-1'."
|
||||
(interactive "P")
|
||||
(ess-fix-dot-1 nil verbose)
|
||||
(ess-fix-dot ",)" dont-query verbose))
|
||||
|
||||
(defun ess-fix-EQ-assign (&optional dont-query verbose not-all)
|
||||
"Replace \"=\" by \"<-\" in places where it 'might make sense', e.g.,
|
||||
for function assignments and lines not ending in \",\".
|
||||
Be *careful* for list()s of functions and when argument not-all is
|
||||
nil (as by default) !"
|
||||
;;TODO: "in the few places we can be very sure.."
|
||||
;;---- is hard in general: local functions: ok; but functions in
|
||||
;; list(a = function(x) abs(x), b= function(y) bound(y)) *NOT* ok!
|
||||
(interactive "P")
|
||||
(ess-replace-regexp-dump-to-src
|
||||
"^\\( *[a-z.][_a-z.0-9]*\\) *= *\\(function *(\\)"
|
||||
"\\1 <- \\2" dont-query verbose)
|
||||
|
||||
(unless not-all
|
||||
;; "too" aggressive {proposing to replace function argument specs}:
|
||||
(ess-replace-regexp-dump-to-src ;; all those *not* ending in ","
|
||||
;; including Mat[ i, ] = ...,
|
||||
;; but not `names(x) = "..."' for that is "confused" with plot(x=x,..)
|
||||
"^\\( *[a-z.][][, \"_a-z.0-9]*\\) *= *\\([a-z.0-9({]\\(.*[^,]\\)? *$\\)"
|
||||
"\\1 <- \\2" nil ;; always query - often has many "false positives"
|
||||
verbose)
|
||||
))
|
||||
|
||||
;;; All of the above three :
|
||||
(defun ess-MM-fix-src (&optional dont-query verbose)
|
||||
"Clean up ess-source code which has been produced by dump(..), and other
|
||||
code typically produced by other tools. Produces more readable code,
|
||||
and one that is well formatted in emacs ess-mode."
|
||||
(interactive "P")
|
||||
;; each of the following does a save-excursion:
|
||||
(ess-dump-to-src dont-query)
|
||||
(ess-fix-comments dont-query)
|
||||
(ess-num-var-round dont-query verbose)
|
||||
(ess-fix-dot-more dont-query verbose)
|
||||
(ess-fix-EQ-assign dont-query verbose 'not-all)
|
||||
)
|
||||
|
||||
(defun ess-fix-miscellaneous (&optional from verbose)
|
||||
"Fix Miscellaneous S/R `ill-formation's from current \\[point].
|
||||
Particularly use \"<-\"and put spaces around operators."
|
||||
(interactive "d\nP"); Defaults: point and prefix (C-u)
|
||||
;; activate by (setq ess-verbose t)
|
||||
(ess-if-verbose-write
|
||||
(format "ess-fix-misc begin (from = %s, verbose = %s)\n" from verbose))
|
||||
(save-excursion
|
||||
|
||||
(if (string= ess-dialect "R")
|
||||
(progn
|
||||
(require 'ess-r-d)
|
||||
(R-fix-T-F from (not verbose))))
|
||||
|
||||
;; activate by (setq ess-verbose t)
|
||||
(ess-if-verbose-write "ess-fix-misc: after fix-T-F\n");___D___
|
||||
|
||||
;; former C and matlab programmers leave trailing ";" :
|
||||
;; (goto-char from) (ess-rep-regexp "; *$" "" nil 'literal verbose)
|
||||
;; (ess-if-verbose-write "ess-fix-misc: after trailing ';'\n");___D___
|
||||
(goto-char from) (ess-rep-regexp ";\\( *\\)#" "\\1#" nil nil verbose)
|
||||
(ess-if-verbose-write "ess-fix-misc: after ';' before #\n");___D___
|
||||
|
||||
;;from R 1.9.x "_" is valid in names; here assume no initial / trailing '_'
|
||||
;; BUG: The following changes "beta_ " or " _abc"
|
||||
;; (goto-char from) (ess-rep-regexp " +_ *" " <- " nil 'literal verbose)
|
||||
;; (goto-char from) (ess-rep-regexp "_ +" " <- " nil 'literal verbose)
|
||||
|
||||
(ess-if-verbose-write "ess-fix-misc: before 'around \"<-\"' :\n");___D___
|
||||
;; ensure space around "<-" ---- but only replace if necessary:
|
||||
(goto-char from)
|
||||
(ess-rep-regexp "\\([^< \t\n]\\)\\(<<?-\\)" "\\1 \\2" nil nil verbose)
|
||||
(goto-char from)(ess-rep-regexp "<-\\([^ \t\n]\\)" "<- \\1" nil nil verbose)
|
||||
;; ensure space around "<" (not in "<-","<=","<<-") and ">" (not ">=") :
|
||||
(goto-char from);; --> " <", care with "->":
|
||||
(ess-rep-regexp "\\([^-< \t\n]\\)\\([<>]\\)" "\\1 \\2" nil nil verbose)
|
||||
;; ">" -> "> " , for "<", don't split "<-" nor "<<-":
|
||||
(goto-char from)
|
||||
(ess-rep-regexp "\\(>=?\\)\\([^= \t\n]\\)" "\\1 \\2" nil nil verbose)
|
||||
(goto-char from)
|
||||
(ess-rep-regexp "\\(<=?\\)\\([^-<= \t\n]\\)" "\\1 \\2" nil nil t)
|
||||
|
||||
(ess-if-verbose-write "ess-fix-misc: before \"=\" \"==\" .. :\n");___D___
|
||||
;; -- ensure space around "=", "==", "!=" :
|
||||
(goto-char from) ;; --> " ="
|
||||
(ess-rep-regexp "\\([^=!<> ]\\)\\([=!]?\\)=" "\\1 \\2=" nil nil verbose)
|
||||
(goto-char from) (ess-rep-regexp "=\\([^= ]\\)" "= \\1" nil nil verbose)
|
||||
|
||||
(goto-char from) ;; add a space between "{" and surrounding ..char:
|
||||
(ess-rep-regexp "{\\([.A-Za-z()]\\)" "{ \\1" 'fix nil verbose)
|
||||
(ess-rep-regexp "\\([()]\\){" "\\1 {" 'fix nil verbose)
|
||||
(goto-char from) ;; add a space between "}" and a preceding wordchar:
|
||||
(ess-rep-regexp "\\([A-Za-z0-9()]\\)}" "\\1 }" 'fix nil verbose)
|
||||
(ess-space-around "else" from verbose)
|
||||
|
||||
(ess-if-verbose-write "ess-fix-misc: after \"{ ... }\" :\n");___D___
|
||||
(goto-char from) ;; add a space inside "){"
|
||||
(ess-rep-regexp "){" ") {" 'fix nil verbose)
|
||||
|
||||
;; add a newline and indent before a "}"
|
||||
;; --- IFF there's NO "{" or "#" AND some NON-white text on the same line:
|
||||
;;D (if verbose (message "\t R-fix-misc..: Hard.. '}'"))
|
||||
(goto-char from)
|
||||
(ess-rep-regexp "^\\([^#{\n]*[^#{ \t\n]+[ \t]*\\)}[ \t]*$"
|
||||
"\\1\n}" 'fix nil verbose)
|
||||
(ess-if-verbose-write "ess-fix-misc __end__\n");___D___
|
||||
))
|
||||
|
||||
;; This is by Seth Falcon, modeled after ess-toggle-underscore (see below).
|
||||
(defun ess-toggle-S-assign-key (force)
|
||||
"Possibly bind the key in `ess-S-assign-key' to inserting `ess-S-assign'.
|
||||
If `ess-S-assign-key' is \"_\", simply use \\[ess-toggle-underscore].
|
||||
Otherwise, unless the prefix argument FORCE is set,
|
||||
toggle between the new and the previous assignment."
|
||||
(interactive "P")
|
||||
(require 'ess-mode)
|
||||
(require 'ess-inf)
|
||||
(let ((current-action (lookup-key ess-mode-map ess-S-assign-key))
|
||||
(insert-S-assign (lambda() (interactive)
|
||||
(delete-horizontal-space) (insert ess-S-assign))))
|
||||
(if (and (stringp ess-S-assign-key)
|
||||
(string= ess-S-assign-key "_"))
|
||||
(ess-toggle-underscore force)
|
||||
;; else "do things here"
|
||||
(let* ((current-is-S-assign (eq current-action insert-S-assign))
|
||||
(new-action (if force insert-S-assign
|
||||
;; else "not force" (default):
|
||||
(if (or current-is-S-assign
|
||||
(eq ess-S-assign-key-last insert-S-assign))
|
||||
ess-S-assign-key-last
|
||||
insert-S-assign))))
|
||||
(message "[ess-toggle-S-assign-key:] current: '%s', new: '%s'"
|
||||
current-action new-action)
|
||||
(define-key ess-mode-map ess-S-assign-key new-action)
|
||||
(define-key inferior-ess-mode-map ess-S-assign-key new-action)
|
||||
(if (not (and force current-is-S-assign))
|
||||
(setq ess-S-assign-key-last current-action))))))
|
||||
|
||||
(defvar polymode-mode)
|
||||
(defun ess-smart-S-assign ()
|
||||
"Act as smart `ess-S-assign' key: insert `ess-S-assign', unless in string/comment.
|
||||
If the underscore key is pressed a second time, the assignment
|
||||
operator is removed and replaced by the underscore. `ess-S-assign',
|
||||
typically \" <- \", can be customized. In ESS modes other than R/S,
|
||||
the underscore is always inserted."
|
||||
(interactive)
|
||||
;;(insert (if (ess-inside-string-or-comment-p (point)) "_" ess-S-assign))
|
||||
(save-restriction
|
||||
(ignore-errors
|
||||
(when (and (eq major-mode 'inferior-ess-mode)
|
||||
(> (point) (process-mark (get-buffer-process (current-buffer)))))
|
||||
(narrow-to-region (process-mark (ess-get-process)) (point-max)))
|
||||
(and ess-noweb-mode
|
||||
(ess-noweb-in-code-chunk)
|
||||
(ess-noweb-narrow-to-chunk))
|
||||
(and (fboundp 'pm/narrow-to-span)
|
||||
polymode-mode
|
||||
(pm/narrow-to-span)))
|
||||
(if (or
|
||||
(ess-inside-string-or-comment-p (point))
|
||||
(not (equal ess-language "S")))
|
||||
(insert ess-smart-S-assign-key)
|
||||
;; else:
|
||||
(ess-insert-S-assign))))
|
||||
(defalias 'ess-smart-underscore 'ess-smart-S-assign)
|
||||
|
||||
(defun ess-insert-S-assign ()
|
||||
"Insert the assignment operator `ess-S-assign', unless it is already there.
|
||||
In that case, it is removed and replaced by `ess-smart-S-assign-key'.
|
||||
`ess-S-assign', typically \" <- \", can be customized."
|
||||
(interactive)
|
||||
;; one keypress produces ess-S-assign; a second keypress will delete
|
||||
;; ess-S-assign and instead insert _
|
||||
;; Rather than trying to count a second _ keypress, just check whether
|
||||
;; the current point is preceded by ess-S-assign.
|
||||
(let ((assign-len (length ess-S-assign)))
|
||||
(if (and
|
||||
(>= (point) (+ assign-len (point-min))) ;check that we can move back
|
||||
(save-excursion
|
||||
(backward-char assign-len)
|
||||
(looking-at ess-S-assign)))
|
||||
;; If we are currently looking at ess-S-assign, replace it with _
|
||||
(progn
|
||||
(delete-char (- assign-len))
|
||||
(insert ess-smart-S-assign-key))
|
||||
(if (string= ess-smart-S-assign-key "_")
|
||||
(delete-horizontal-space))
|
||||
(insert ess-S-assign))))
|
||||
|
||||
;;; Setting / Unsetting the smart S-assign-key behavior -----------------
|
||||
|
||||
;; Two basic building blocks, used below:
|
||||
(defun ess--unset-smart-S-assign-key ()
|
||||
(define-key ess-mode-map "_" nil)
|
||||
(define-key inferior-ess-mode-map "_" nil)
|
||||
(define-key ess-mode-map ess-smart-S-assign-key nil); 'self-insert-command
|
||||
(define-key inferior-ess-mode-map ess-smart-S-assign-key nil))
|
||||
(defun ess--activate-smart-S-assign-key ()
|
||||
(define-key ess-mode-map ess-smart-S-assign-key 'ess-smart-S-assign)
|
||||
(define-key inferior-ess-mode-map ess-smart-S-assign-key 'ess-smart-S-assign))
|
||||
|
||||
|
||||
;; Written such that whimps can have (ess-disable-smart-S-assign) in .emacs :
|
||||
(defun ess-disable-smart-S-assign (activate)
|
||||
"Disable or activate (if prefix argument ACTIVATE is set) the smart assignment
|
||||
operator `ess-S-assign'. That, typically \" <- \", can be customized."
|
||||
(interactive "P")
|
||||
(if activate
|
||||
(ess--activate-smart-S-assign-key)
|
||||
(ess--unset-smart-S-assign-key)))
|
||||
(defalias 'ess-disable-smart-underscore 'ess-disable-smart-S-assign)
|
||||
|
||||
(defun ess-toggle-S-assign (force)
|
||||
"Set the `ess-smart-S-assign-key' (by default \"_\"
|
||||
[underscore]) key to \\[ess-smart-S-assign] or back to
|
||||
`ess-smart-S-assign-key'. Toggle the current definition, unless
|
||||
FORCE is non-nil, where \\[ess-smart-S-assign] is set
|
||||
unconditionally.
|
||||
|
||||
If you as per default have `ess-smart-S-assign-key' set to
|
||||
underscore, note that using \"C-q _\" will always just insert the
|
||||
underscore character."
|
||||
(interactive "P")
|
||||
(let ((current-key (lookup-key ess-mode-map ess-smart-S-assign-key))
|
||||
(default-key (lookup-key ess-mode-map "_")))
|
||||
(if (and (or default-key current-key)
|
||||
;; (stringp current-key) (string= current-key ess-S-assign)
|
||||
(not force))
|
||||
(ess--unset-smart-S-assign-key)
|
||||
;; else : "force" or current-key is "nil", i.e. default
|
||||
(ess--activate-smart-S-assign-key))))
|
||||
(defalias 'ess-toggle-underscore 'ess-toggle-S-assign)
|
||||
;; NOTA BENE: "_" is smart *by default* :
|
||||
;; ----- The user can always customize `ess-S-assign' ...
|
||||
(ess-toggle-S-assign 'force-to-S-assign)
|
||||
|
||||
(defun ess-add-MM-keys ()
|
||||
"Define MM's user keys, currently \\<ess-mode-map>\\[ess-insert-function-outline], and
|
||||
\\<inferior-ess-mode-map>\\[ess-execute-screen-options]."
|
||||
(interactive)
|
||||
(require 'ess-mode); typically unnecessary
|
||||
(require 'ess-inf); dito
|
||||
(define-key ess-mode-map "\C-cf" 'ess-insert-function-outline)
|
||||
(define-key inferior-ess-mode-map "\C-cw" 'ess-execute-screen-options)
|
||||
|
||||
;; Make M-- : [Alt] + [-] (in addition to / instead of "_" = (on US-keyboard) [Shift]+ [-]
|
||||
;; Note this overwrites 'M--' as "negative argument" (still on 'C--'):
|
||||
(define-key ess-mode-map [?\M--] 'ess-insert-S-assign)
|
||||
(define-key inferior-ess-mode-map [?\M--] 'ess-insert-S-assign)
|
||||
)
|
||||
|
||||
|
||||
(defun ess-dump-args-and-go (Sfunc) ; &optional buff)
|
||||
"Dump the function name, with arguments, to a buffer for editing.
|
||||
|
||||
Currently, this needs to:
|
||||
1. set the buffer to the right mode, with the right settings
|
||||
2. format the statement,
|
||||
3. c/function/Sfunc/
|
||||
and I need to relearn emacs lisp (but I had to, anyway."
|
||||
|
||||
(interactive "sFunction ? ")
|
||||
(let* ((buffname "ess-complete.R")
|
||||
(buf (ess-execute (format "args(%s)" Sfunc) t buffname)))
|
||||
(pop-to-buffer buf)
|
||||
(message "here yet?")
|
||||
(while (search-forward "function" nil t)
|
||||
(replace-match Sfunc nil t))
|
||||
(ess-setq-vars-local ess-customize-alist); (current-buffer))
|
||||
(setq major-mode 'ess-mode)
|
||||
(use-local-map ess-mode-map)
|
||||
(set-syntax-table ess-mode-syntax-table)
|
||||
))
|
||||
|
||||
|
||||
|
||||
;;; S imenu support
|
||||
|
||||
;; don't use syntax classes, bad for etags
|
||||
(defvar ess-imenu-S-generic-expression
|
||||
'(("Functions" "^\\(.+\\)[ \t\n]*<-[ \t\n]*function[ ]*(" 1)
|
||||
("Classes" "^.*setClass(\\(.*\\)," 1)
|
||||
("Coercions" "^.*setAs(\\([^,]+,[^,]*\\)," 1) ; show from and to
|
||||
("Generics" "^.*setGeneric(\\([^,]*\\)," 1)
|
||||
("Methods" "^.*set\\(Group\\|Replace\\)?Method(\\([^,]+,[^,]*\\)" 2)
|
||||
;;[ ]*\\(signature=\\)?(\\(.*,?\\)*\\)," 1)
|
||||
;;
|
||||
;;("Other" "^\\(.+\\)\\s-*<-[ \t\n]*[^\\(function\\|read\\|.*data\.frame\\)]" 1)
|
||||
("Package" "^.*\\(library\\|require\\)(\\(.*\\)" 2)
|
||||
("Data" "^\\(.+\\)[ \t\n]-*<-[ \t\n]*\\(read\\|.*data\.frame\\).*(" 1)))
|
||||
|
||||
(defun ess-imenu-S (&optional arg)
|
||||
"S Language Imenu support for ESS."
|
||||
(interactive)
|
||||
(setq imenu-generic-expression ess-imenu-generic-expression)
|
||||
(imenu-add-to-menubar "Imenu-S"))
|
||||
|
||||
(defalias 'ess-imenu-R 'ess-imenu-S)
|
||||
|
||||
|
||||
;;; Speedbar stuff.
|
||||
(defun ess-S-initialize-speedbar ()
|
||||
"Extend to all extensions; see initialization, and edit."
|
||||
(speedbar-add-supported-extension ".R")
|
||||
(speedbar-add-supported-extension ".S")
|
||||
(speedbar-add-supported-extension ".s")
|
||||
(speedbar-add-supported-extension ".q"))
|
||||
|
||||
;(if (featurep 'speedbar)
|
||||
; (progn
|
||||
; (message "enabling speedbar support")
|
||||
; (require 'speedbar)
|
||||
; (ess-S-initialize-speedbar)))
|
||||
|
||||
(eval-when-compile
|
||||
(condition-case nil
|
||||
(progn
|
||||
(require 'speedbar)
|
||||
(when (featurep 'speedbar)
|
||||
|
||||
(defun S-speedbar-buttons (buffer)
|
||||
"attempted hack."
|
||||
|
||||
;;(speedbar-make-tag-line)
|
||||
;;(speedbar-insert-button)
|
||||
(speedbar-with-writable))
|
||||
|
||||
(fset 'R-speedbar-buttons 'S-speedbar-buttons)
|
||||
|
||||
(defun S-speedbar-menu-items ( )
|
||||
"Need to write.")
|
||||
|
||||
(ess-S-initialize-speedbar)))
|
||||
(error nil)))
|
||||
|
||||
(provide 'ess-s-l)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; outline-minor-mode: nil
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-s-l.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-s-l.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-s-l.elc
Normal file
Binary file not shown.
99
.emacs.d/elpa/ess-20160208.453/lisp/ess-s3-d.el
Normal file
99
.emacs.d/elpa/ess-20160208.453/lisp/ess-s3-d.el
Normal file
@@ -0,0 +1,99 @@
|
||||
;;; ess-s3-d.el --- S 3 (AT&T version) customization
|
||||
|
||||
;; Copyright (C) 1997 A. J. Rossini
|
||||
;; Copyright (C) 1998--2005 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: A.J. Rossini <rossini@stat.sc.edu>
|
||||
;; Created: 12 Jun 1997
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; Keywords: languages
|
||||
|
||||
;; This file is part of ESS.
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This file defines all the S 3 customizations for ess-mode.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(autoload 'inferior-ess "ess-inf" "Run an ESS process.")
|
||||
|
||||
(require 'ess-s-l)
|
||||
|
||||
(defvar S3-customize-alist
|
||||
(append
|
||||
'((ess-local-customize-alist . 'S3-customize-alist)
|
||||
(ess-dialect . "S3")
|
||||
(ess-loop-timeout . ess-S-loop-timeout);fixme: dialect spec.
|
||||
(ess-change-sp-regexp . ess-S-change-sp-regexp)
|
||||
(ess-help-sec-keys-alist . ess-help-S3-sec-keys-alist)
|
||||
(ess-object-name-db-file . "ess-s3-namedb.el" )
|
||||
(inferior-ess-program . inferior-S3-program-name) ; "S")
|
||||
(inferior-ess-help-command . "help(\"%s\")\n")
|
||||
(inferior-ess-help-filetype . nil)
|
||||
(inferior-ess-search-list-command . "search()\n")
|
||||
(inferior-ess-objects-command . "objects(%d)\n")
|
||||
(inferior-ess-start-file . nil) ;"~/.ess-S3")
|
||||
(inferior-ess-start-args . "")
|
||||
(ess-STERM . "iESS")
|
||||
)
|
||||
S+common-cust-alist); use S+ ones here; partly overwritten above!!
|
||||
|
||||
"Variables to customize for S3")
|
||||
|
||||
(defun S3 (&optional proc-name)
|
||||
"Call 'S 3.x', the version from AT&T."
|
||||
(interactive)
|
||||
(setq ess-customize-alist S3-customize-alist)
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "\n(S3): ess-dialect=%s, buf=%s\n" ess-dialect (current-buffer)))
|
||||
(inferior-ess)
|
||||
(if inferior-ess-language-start
|
||||
(ess-eval-linewise inferior-ess-language-start)))
|
||||
|
||||
|
||||
(defun S3-mode (&optional proc-name)
|
||||
"Major mode for editing S3 source. See `ess-mode' for more help."
|
||||
(interactive)
|
||||
(setq ess-customize-alist S3-customize-alist)
|
||||
(ess-mode S3-customize-alist proc-name)
|
||||
(if ess-imenu-use-S (ess-imenu-S)))
|
||||
|
||||
|
||||
; Provide package
|
||||
|
||||
(provide 'ess-s3-d)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; outline-minor-mode: nil
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-s3-d.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-s3-d.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-s3-d.elc
Normal file
Binary file not shown.
297
.emacs.d/elpa/ess-20160208.453/lisp/ess-s4-d.el
Normal file
297
.emacs.d/elpa/ess-20160208.453/lisp/ess-s4-d.el
Normal file
@@ -0,0 +1,297 @@
|
||||
;;; ess-s4-d.el --- S4 customization
|
||||
|
||||
;; Copyright (C) 1997--2004 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: A.J. Rossini <rossini@stat.sc.edu>
|
||||
;; Created: 12 Jun 1997
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; Keywords: languages
|
||||
|
||||
;; This file is part of ESS.
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; DB contributed the changes from ess-s3-d.el to
|
||||
;; ess-s4-d.el (removed the old ugly approach).
|
||||
;; This file defines S4 customizations for ess-mode. Lots of thanks
|
||||
;; to RMH and JMC for code and suggestions
|
||||
|
||||
;;; Code:
|
||||
|
||||
(autoload 'inferior-ess "ess-inf" "Run an ESS process.")
|
||||
|
||||
(require 'ess-s-l)
|
||||
|
||||
;; Some of this is based on files from:
|
||||
;; Copyright (C) 1996, John M. Chambers.
|
||||
|
||||
(defvar S4-customize-alist
|
||||
(append
|
||||
'((ess-local-customize-alist . 'S4-customize-alist)
|
||||
(ess-dialect . "S4")
|
||||
(ess-loop-timeout . ess-S-loop-timeout);fixme: dialect spec.
|
||||
(ess-change-sp-regexp . ess-S-change-sp-regexp)
|
||||
(ess-help-sec-keys-alist . ess-help-S3-sec-keys-alist)
|
||||
(ess-object-name-db-file . "ess-s4-namedb.el")
|
||||
(inferior-ess-program . inferior-S4-program-name)
|
||||
(inferior-ess-objects-command . ".SmodeObs(%d, pattern=\"%s\")\n")
|
||||
;;(inferior-ess-objects-pattern . ".*") ; for new s4 stuff
|
||||
(inferior-ess-help-command . "help(\"%s\")\n")
|
||||
(inferior-ess-help-filetype . nil)
|
||||
(inferior-ess-search-list-command . ".SmodePaths()\n")
|
||||
(ess-load-command . ".SmodeLoad(\"%s\")\n")
|
||||
(inferior-ess-dump-command . ".SmodeDump(\"%s\", \"%s\")\n")
|
||||
|
||||
(inferior-ess-start-file . nil) ;"~/.ess-S3")
|
||||
(inferior-ess-start-args . "")
|
||||
(ess-STERM . "iESS")
|
||||
)
|
||||
S+common-cust-alist); use S+ ones here; partly overwritten above!!
|
||||
|
||||
"Variables to customize for S4.")
|
||||
|
||||
;; For loading up the S code required for the above.
|
||||
;;(add-hook 'ess-post-run-hook
|
||||
;; (lambda ()
|
||||
;; (ess-command
|
||||
;; (concat
|
||||
;; "if(exists(\"Sversion\")) library(emacs) else source(\""
|
||||
;; ess-mode-run-file
|
||||
;; "\")\n"))
|
||||
;; (if ess-mode-run-file2
|
||||
;; (ess-command
|
||||
;; (concat "source(\"" ess-mode-run-file2 "\")\n")))))
|
||||
|
||||
|
||||
(defun S4 ()
|
||||
"Call 'S version 4', from Bell Labs. New way to do it."
|
||||
(interactive)
|
||||
(setq ess-customize-alist S4-customize-alist)
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "\n(S4): ess-dialect=%s, buf=%s\n" ess-dialect (current-buffer)))
|
||||
(inferior-ess)
|
||||
(if inferior-ess-language-start
|
||||
(ess-eval-linewise inferior-ess-language-start)))
|
||||
|
||||
|
||||
(defun S4-mode (&optional proc-name)
|
||||
"Major mode for editing S4 source. See `ess-mode' for more help."
|
||||
(interactive)
|
||||
(setq ess-customize-alist S4-customize-alist)
|
||||
(ess-mode S4-customize-alist proc-name)
|
||||
(if ess-imenu-use-S (ess-imenu-S)))
|
||||
|
||||
|
||||
;; From RMH: ALL THIS SHOULD BE INCORPORATED BY 5.0!
|
||||
|
||||
;;; s4.el startup file
|
||||
;;; Richard M. Heiberger
|
||||
;;; rmh@temple.edu
|
||||
;;
|
||||
;;(load "S")
|
||||
;;(setq inferior-S-program "/disk05/s4/betaJun96/S")
|
||||
;;(setq S-plus nil) ;; needed for non S-plus
|
||||
;;(add-to-list 'load-path "/disk05/s4/betaJun96") ;; S-namedb.el is here
|
||||
;;(S)
|
||||
;;(load-file "/disk05/s4/betaJun96/library/emacs/S-modeadds.el") ;; must come after (S)
|
||||
;;
|
||||
;;
|
||||
;;;;; S4 __Help, no longer S3 .Help
|
||||
;;(load "S-help")
|
||||
;; ;; Must follow S-help
|
||||
;;; S-help.file line 270
|
||||
;;(defun S-get-help-files-list nil
|
||||
;; (mapcar 'list
|
||||
;; (apply 'append
|
||||
;; (mapcar (lambda (dirname)
|
||||
;; (if (file-directory-p dirname)
|
||||
;; (directory-files dirname)))
|
||||
;; (mapcar (lambda (str) (concat str "/__Help"))
|
||||
;; (S-search-list))))))
|
||||
;;
|
||||
;;
|
||||
;;;;; additional font-lock-keywords for S4
|
||||
;;
|
||||
;;;;*;; based on S-inf.el line 107
|
||||
;;;;(add-to-list 'S-inf-font-lock-keywords
|
||||
;;;; '("\\<\\(^Problem\\|^Warning\\|^Error\\|Debug ?\\|Browsing in frame of\\|Local Variables\\)\\>" . font-lock-reference-face) ; S-inf problems
|
||||
;;;;)
|
||||
;;;;(add-to-list 'S-inf-font-lock-keywords
|
||||
;;;; '("^R>" . font-lock-keyword-face) ; debug prompt
|
||||
;;;;)
|
||||
;;(inferior-S-mode)
|
||||
;;
|
||||
;;; S-inf.el line 150
|
||||
;;(setq inferior-S-search-list-command "searchPaths()\n")
|
||||
;;
|
||||
;;;; fontify S-transcript-mode
|
||||
;;;; overwrites S-trans.el lines 60-69
|
||||
;;;;(setq S-trans-font-lock-keywords S-inf-font-lock-keywords)
|
||||
;;
|
||||
;;(load "S-mode")
|
||||
;; ;; Must follow S-mode
|
||||
;;;;*;; based on S-mode.el line 219
|
||||
;;(add-to-list 'S-mode-font-lock-keywords
|
||||
;; '("\\<\\(setGeneric\\|removeGeneric\\|setMethod\\|unsetMethod\\|setReplaceGeneric\\|setReplaceMethod\\|standardGeneric\\|setIs\\|setClass\\|representation\\)\\>" . font-lock-function-name-face) ; S4 method functions
|
||||
;;)
|
||||
;;
|
||||
;;
|
||||
;;
|
||||
;;;;; fix to S-load-file to make C-c C-l work with S4
|
||||
;;
|
||||
;;;When a file sourced into S4 by C-c C-l has a syntax error
|
||||
;;;without the following changes, the system
|
||||
;;;freezes until it is released with ^G. The reason is that the error
|
||||
;;;messages, including the `Debug ?' request, go to the *S-errors*
|
||||
;;;buffer. The *S-errors* buffer is not switched to, and couldn't accept
|
||||
;;;a response if it were.
|
||||
;;;
|
||||
;;;The fix requires three modification to S-inf.el and two to S-mode.el.
|
||||
;;;The correction to S-check-source noted in smode.cmt is also necessary.
|
||||
;;;
|
||||
;;
|
||||
;;; S-inf.el line 92 NEW variable
|
||||
;;(defvar inferior-S-debug-prompt "Debug \\? (y|n): "
|
||||
;; "The expression S uses to offer to initiate debug tracing.")
|
||||
;;
|
||||
;;; S-inf.el line 458
|
||||
;;(defun inferior-S-wait-for-prompt ()
|
||||
;; "Wait until the S process is ready for input."
|
||||
;; (let* ((cbuffer (current-buffer))
|
||||
;; (sprocess (get-S-process S-current-process-name))
|
||||
;; (sbuffer (process-buffer sprocess))
|
||||
;; r
|
||||
;; (timeout 0))
|
||||
;; (set-buffer sbuffer)
|
||||
;; (while (progn
|
||||
;; (if (not (eq (process-status sprocess) 'run))
|
||||
;; (S-error "S process has died unexpectedly.")
|
||||
;; (if (> (setq timeout (1+ timeout)) S-loop-timeout)
|
||||
;; (S-error "Timeout waiting for prompt. Check inferior-S-prompt or S-loop-timeout."))
|
||||
;; (accept-process-output)
|
||||
;; (goto-char (point-max))
|
||||
;;(setq end (point))
|
||||
;; (beginning-of-line)
|
||||
;;(setq e (buffer-substring (point) end))
|
||||
;;(if (equal e inferior-S-debug-prompt)
|
||||
;; (S-error "Debug prompt"))
|
||||
;; (setq r (looking-at inferior-S-prompt))
|
||||
;; (not (or r (looking-at ".*\\?\\s *"))))))
|
||||
;; (goto-char (point-max))
|
||||
;; (set-buffer cbuffer)
|
||||
;; (symbol-value r)))
|
||||
;;
|
||||
;;
|
||||
;;
|
||||
;;; S-mode.el line 204
|
||||
;;(setq S-dump-error-re "Problem")
|
||||
;;
|
||||
;;;; S-mode.el line 655
|
||||
;;(defun S-parse-errors (showerr)
|
||||
;; "Jump to error in last loaded S source file.
|
||||
;;With prefix argument, only shows the errors S reported."
|
||||
;; (interactive "P")
|
||||
;; (S-make-buffer-current)
|
||||
;; (let ((errbuff (get-buffer S-error-buffer-name)))
|
||||
;; (if (not errbuff)
|
||||
;; (error "You need to do a load first!")
|
||||
;; (set-buffer errbuff)
|
||||
;; (goto-char (point-max))
|
||||
;; (if
|
||||
;; (re-search-backward ", file \"" nil t)
|
||||
;; (let* ((beg-pos (progn (re-search-forward "\"" nil t) (point)))
|
||||
;; (end-pos (progn (re-search-forward "\"" nil t) (- (point) 1)))
|
||||
;; (filename (buffer-substring beg-pos end-pos))
|
||||
;; (fbuffer (get-file-buffer filename))
|
||||
;; (linenum (string-to-number
|
||||
;; (progn (re-search-backward "," nil t)
|
||||
;; (current-word))))
|
||||
;; (end-pos (point))
|
||||
;; (beg-pos (progn (goto-char (point-min))
|
||||
;; (re-search-forward ":" nil t)
|
||||
;; (1+ (point))))
|
||||
;; (errmess (buffer-substring beg-pos end-pos))
|
||||
;; )
|
||||
;; (if showerr
|
||||
;; (S-display-temp-buffer errbuff)
|
||||
;; (if fbuffer nil
|
||||
;; (setq fbuffer (find-file-noselect filename))
|
||||
;; (save-excursion
|
||||
;; (set-buffer fbuffer)
|
||||
;; (S-mode)))
|
||||
;; (pop-to-buffer fbuffer)
|
||||
;; (goto-line linenum))
|
||||
;; (princ errmess t))
|
||||
;; (message "Not a syntax error.")
|
||||
;; (S-display-temp-buffer errbuff)))))
|
||||
;;
|
||||
;;
|
||||
;;
|
||||
;;;; S-inf.el line 584
|
||||
;;(defun S-prompt-wait (proc &optional start-of-output)
|
||||
;; "Wait for a prompt to appear at BOL of current buffer
|
||||
;;PROC is the S process. Does not change point"
|
||||
;; (if start-of-output nil (setq start-of-output (point-min)))
|
||||
;; (save-excursion
|
||||
;; (while (progn
|
||||
;; ;; get output if there is some ready
|
||||
;; (accept-process-output proc 0 500)
|
||||
;; (goto-char (marker-position (process-mark proc)))
|
||||
;; (beginning-of-line)
|
||||
;;
|
||||
;; (if (re-search-forward inferior-S-debug-prompt nil t)
|
||||
;; (if (equal (get-buffer S-error-buffer-name)
|
||||
;; (get-buffer S-error-buffer-name))
|
||||
;; (let* ((sprocess (get-S-process S-current-process-name))
|
||||
;; (sbuffer (process-buffer sprocess)))
|
||||
;; (set-buffer sbuffer)
|
||||
;; (process-send-string sprocess "n\n")
|
||||
;; (accept-process-output sprocess)
|
||||
;; (beginning-of-line); delete inferior-S-debug-prompt
|
||||
;; (kill-line)
|
||||
;; (insert "> ")))
|
||||
;;
|
||||
;; (if (< (point) start-of-output) (goto-char start-of-output))
|
||||
;; (not (looking-at inferior-S-primary-prompt)))))))
|
||||
;;
|
||||
|
||||
|
||||
|
||||
; Provide package
|
||||
|
||||
(provide 'ess-s4-d)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; outline-minor-mode: nil
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-s4-d.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-s4-d.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-s4-d.elc
Normal file
Binary file not shown.
1484
.emacs.d/elpa/ess-20160208.453/lisp/ess-sas-a.el
Normal file
1484
.emacs.d/elpa/ess-20160208.453/lisp/ess-sas-a.el
Normal file
File diff suppressed because it is too large
Load Diff
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-sas-a.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-sas-a.elc
Normal file
Binary file not shown.
334
.emacs.d/elpa/ess-20160208.453/lisp/ess-sas-d.el
Normal file
334
.emacs.d/elpa/ess-20160208.453/lisp/ess-sas-d.el
Normal file
@@ -0,0 +1,334 @@
|
||||
;;; ess-sas-d.el --- SAS customization
|
||||
|
||||
;; Copyright (C) 1997--2001 Richard M. Heiberger and A. J. Rossini
|
||||
;; Copyright (C) 2002--2004 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: Richard M. Heiberger <rmh@temple.edu>
|
||||
;; Created: 20 Aug 1997
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; Keywords: languages
|
||||
|
||||
;; This file is part of ESS.
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This file defines all the SAS customizations for ESS behaviors. See
|
||||
;; ess-sas-l and ess-sas-a for the underlying general modifications.
|
||||
|
||||
;;; Code:
|
||||
|
||||
;;; Autoloads:
|
||||
|
||||
(ess-message "[ess-sas-d:] require 'comint & 'shell ...")
|
||||
(require 'comint)
|
||||
(require 'shell)
|
||||
(require 'executable)
|
||||
|
||||
;;(ess-message "[ess-sas-d:] require 'ess-sas-a ...")
|
||||
;;(require 'ess-sas-a)
|
||||
(ess-message "[ess-sas-d:] require 'ess-sas-l ...")
|
||||
(require 'ess-sas-l)
|
||||
(ess-message "[ess-sas-d:] (autoload ..) (def** ..) ...")
|
||||
|
||||
(autoload 'inferior-ess "ess-inf" no-doc t)
|
||||
(autoload 'ess-mode "ess-mode" no-doc t)
|
||||
(autoload 'ess-proc-name "ess-inf" no-doc nil)
|
||||
|
||||
(defvar inferior-SAS-args "-stdio -linesize 80 -noovp -nosyntaxcheck"
|
||||
"*Arguments to use for starting SAS.")
|
||||
|
||||
(defvar inferior-SAS-args-temp nil
|
||||
"Hack variable, needed for args preprocessing.
|
||||
Better logic needed! (see 2 uses, in this file).")
|
||||
|
||||
(defun ess-SAS-pre-run-hook (temp-ess-dialect)
|
||||
"Set up log and list files for interactive SAS."
|
||||
|
||||
(let* ((ess-shell-buffer-name-flag (get-buffer "*shell*"))
|
||||
ess-shell-buffer-name
|
||||
;; isn't pretty yet.
|
||||
;; ess-local-process-name is defined after this function.
|
||||
;; it needs to be defined prior to this function.
|
||||
(tmp-procname (let ((ntry 0)
|
||||
(done nil))
|
||||
;; find a non-existent process
|
||||
(while (not done)
|
||||
(setq ntry (1+ ntry)
|
||||
done (not
|
||||
(get-process (ess-proc-name
|
||||
ntry
|
||||
temp-ess-dialect)))))
|
||||
(ess-proc-name ntry temp-ess-dialect)))
|
||||
;; Following was tmp-local-process-name. Stolen from inferior-ess
|
||||
(ess-sas-lst-bufname (concat "*" tmp-procname ".lst*"))
|
||||
(ess-sas-log-bufname (concat "*" tmp-procname ".log*"))
|
||||
(explicit-shell-file-name "/bin/sh")
|
||||
inferior-SAS-redirect-args
|
||||
ess-sas-lst
|
||||
ess-sas-log)
|
||||
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "(ess-SAS-pre-run-hook 1): ess-lang=%s, ess-dialect=%s, temp-dialect=%s, buf=%s \n"
|
||||
ess-language
|
||||
ess-dialect
|
||||
temp-ess-dialect
|
||||
(current-buffer)))
|
||||
;; If someone is running a *shell* buffer, rename it to avoid
|
||||
;; inadvertent nuking.
|
||||
(if ess-shell-buffer-name-flag
|
||||
(save-excursion
|
||||
(set-buffer "*shell*")
|
||||
(setq ess-shell-buffer-name
|
||||
(rename-buffer "*ess-shell-regular*" t))))
|
||||
|
||||
;; Construct the LST buffer for output
|
||||
(if (get-buffer ess-sas-lst-bufname)
|
||||
nil
|
||||
(shell)
|
||||
(accept-process-output (get-buffer-process (current-buffer)))
|
||||
(sleep-for 2) ; need to wait, else working too fast!
|
||||
(setq ess-sas-lst (ess-insert-accept "tty"))
|
||||
(SAS-listing-mode)
|
||||
(shell-mode)
|
||||
(ess-listing-minor-mode t)
|
||||
(rename-buffer ess-sas-lst-bufname t))
|
||||
|
||||
;; Construct the LOG buffer for output
|
||||
(if (get-buffer ess-sas-log-bufname)
|
||||
nil
|
||||
(shell)
|
||||
(accept-process-output (get-buffer-process (current-buffer)))
|
||||
(sleep-for 2) ; need to wait, else working too fast!
|
||||
(setq ess-sas-log (ess-insert-accept "tty"))
|
||||
;(SAS-log-mode)
|
||||
(shell-mode)
|
||||
(ess-transcript-minor-mode t)
|
||||
(rename-buffer ess-sas-log-bufname t))
|
||||
|
||||
(setq inferior-SAS-redirect-args (concat " "
|
||||
ess-sas-lst
|
||||
" "
|
||||
ess-sas-log
|
||||
" ")
|
||||
inferior-SAS-args-temp (concat inferior-SAS-redirect-args
|
||||
inferior-SAS-args))
|
||||
|
||||
;; Restore the *shell* buffer
|
||||
(if ess-shell-buffer-name-flag
|
||||
(save-excursion
|
||||
(set-buffer ess-shell-buffer-name)
|
||||
(rename-buffer "*shell*")))
|
||||
|
||||
(delete-other-windows)
|
||||
(split-window-vertically)
|
||||
(split-window-vertically)
|
||||
(switch-to-buffer (nth 2 (buffer-list)))
|
||||
(other-window 2)
|
||||
(switch-to-buffer ess-sas-log-bufname)
|
||||
(split-window-vertically)
|
||||
(other-window 1)
|
||||
(switch-to-buffer ess-sas-lst-bufname)
|
||||
(other-window 2)
|
||||
|
||||
;;workaround
|
||||
(setq inferior-SAS-program-name
|
||||
(concat (file-name-as-directory ess-etc-directory)
|
||||
"ess-sas-sh-command"))
|
||||
(setq inferior-ess-program inferior-SAS-program-name)))
|
||||
|
||||
(defun ess-insert-accept (command)
|
||||
"Submit command to process, get next line."
|
||||
(interactive)
|
||||
(goto-char (point-max))
|
||||
(insert command)
|
||||
(comint-send-input)
|
||||
(accept-process-output (get-buffer-process (current-buffer)))
|
||||
(forward-line -1)
|
||||
(let* ((beg (point))
|
||||
(ess-tty-name (progn (end-of-line) (buffer-substring beg (point)))))
|
||||
(goto-char (point-max))
|
||||
ess-tty-name))
|
||||
|
||||
|
||||
(defvar SAS-customize-alist
|
||||
'((ess-local-customize-alist . 'SAS-customize-alist)
|
||||
(ess-language . "SAS")
|
||||
(ess-dialect . "SAS")
|
||||
(ess-mode-editing-alist . SAS-editing-alist) ; from ess-sas-l.el
|
||||
(ess-mode-syntax-table . SAS-syntax-table)
|
||||
(inferior-ess-program . inferior-SAS-program-name)
|
||||
(ess-help-sec-regex . "^[A-Z. ---]+:$")
|
||||
(ess-help-sec-keys-alist . " ")
|
||||
(ess-object-name-db-file . "ess-sas-namedb.el")
|
||||
(inferior-ess-objects-command . "objects(%d)");;FIXME
|
||||
(inferior-ess-help-command . "help(\"%s\",pager=\"cat\",window=F)\n");;FIXME
|
||||
(inferior-ess-exit-command . "endsas;\n")
|
||||
(ess-loop-timeout . 500000 )
|
||||
(inferior-ess-primary-prompt . "^")
|
||||
(inferior-ess-secondary-prompt . "^")
|
||||
(comint-use-prompt-regexp . t)
|
||||
(inferior-ess-start-file . nil) ;"~/.ess-SAS")
|
||||
(inferior-ess-start-args . inferior-SAS-args-temp)
|
||||
(inferior-ess-font-lock-defaults . SAS-mode-font-lock-defaults)
|
||||
;; (ess-pre-run-hook . 'ess-SAS-pre-run-hook)
|
||||
;; (ess-local-process-name . nil)
|
||||
)
|
||||
"Variables to customize for SAS")
|
||||
|
||||
;;; The functions of interest (mode, inferior mode)
|
||||
|
||||
(defvar sas-mode-local-map nil "contains modified local keymap for SAS")
|
||||
|
||||
(defun SAS-mode (&optional proc-name)
|
||||
"Major mode for editing SAS source. See ess-mode for more help."
|
||||
(interactive)
|
||||
(setq ess-customize-alist SAS-customize-alist)
|
||||
(ess-mode SAS-customize-alist proc-name)
|
||||
|
||||
;; Local map settings, AFTER initialization (only if not yet defined)
|
||||
(if sas-mode-local-map
|
||||
nil
|
||||
(setq sas-mode-local-map (copy-keymap (current-local-map)))
|
||||
(ess-sas-edit-keys-set ess-sas-edit-keys-toggle)
|
||||
(if ess-sas-local-unix-keys (ess-sas-local-unix-keys))
|
||||
(if ess-sas-local-pc-keys (ess-sas-local-pc-keys))
|
||||
(if ess-sas-global-unix-keys (ess-sas-global-unix-keys))
|
||||
(if ess-sas-global-pc-keys (ess-sas-global-pc-keys)))
|
||||
(define-key sas-mode-local-map "\C-ci" 'ess-eval-line-and-step-invisibly)
|
||||
(define-key sas-mode-local-map ";" 'ess-electric-run-semicolon)
|
||||
|
||||
;; this is a mess
|
||||
;; interactive and batch commands share sas-mode-local-map,
|
||||
;; but the associated commands are very different
|
||||
;; what would be better is two maps like
|
||||
;; sas-batch-mode-local-map and sas-interactive-mode-local-map
|
||||
;; or smart function definitions that would do the appropriate
|
||||
;; thing for either batch or interactive sessions
|
||||
;; however, neither of these solutions are planned
|
||||
;; therefore, no key definitions can be shared between
|
||||
;; batch and interactive at this time, hence the lines that
|
||||
;; are commented below: uncomment at your own risk
|
||||
;; (define-key sas-mode-local-map "\C-c\C-p" 'ess-sas-file-path)
|
||||
;; (define-key sas-mode-local-map "\C-c\C-b" 'ess-sas-submit)
|
||||
;; (define-key sas-mode-local-map "\C-c\C-r" 'ess-sas-submit-region)
|
||||
;; (define-key sas-mode-local-map "\C-c\C-x" 'ess-sas-goto-log)
|
||||
;; (define-key sas-mode-local-map "\C-c\C-y" 'ess-sas-goto-lst)
|
||||
|
||||
(use-local-map sas-mode-local-map)
|
||||
|
||||
(set (make-local-variable 'font-lock-defaults)
|
||||
;; KEYWORDS KEYWORDS-ONLY CASE-FOLD .....
|
||||
'(SAS-mode-font-lock-defaults nil t))
|
||||
;; ^^ this *should* set
|
||||
;; font-lock-keywords-case-fold-search, but it fails for Emacs 22.[23]
|
||||
;; hence :
|
||||
(setq font-lock-keywords-case-fold-search t)
|
||||
(run-hooks 'SAS-mode-hook))
|
||||
|
||||
|
||||
|
||||
;; rmh Jul 10 2003
|
||||
(defun ess-electric-run-semicolon (arg)
|
||||
"Insert character. If the line contains \"run;\" or \"quit;\" and nothing else then indent line."
|
||||
(interactive "P")
|
||||
(if ess-sas-edit-keys-toggle (insert ";") (let (insertpos)
|
||||
(if (and (not arg)
|
||||
(eolp)
|
||||
(save-excursion
|
||||
(skip-chars-backward " \t")
|
||||
(backward-word 1)
|
||||
(and (looking-at "run\\|quit")
|
||||
(progn
|
||||
(skip-chars-backward " \t")
|
||||
(bolp)))))
|
||||
(progn
|
||||
(insert last-command-event)
|
||||
(ess-indent-line)
|
||||
(save-excursion
|
||||
(if insertpos (goto-char (1+ insertpos)))
|
||||
(delete-char -1))))
|
||||
(if insertpos
|
||||
(save-excursion
|
||||
(goto-char insertpos)
|
||||
(self-insert-command (prefix-numeric-value arg)))
|
||||
(self-insert-command (prefix-numeric-value arg))))))
|
||||
|
||||
(defun SAS ()
|
||||
"Call 'SAS', from SAS Institute."
|
||||
(interactive)
|
||||
(setq-default ess-customize-alist SAS-customize-alist)
|
||||
(let* ((temp-dialect "SAS")) ;(cdr (rassoc ess-dialect SAS-customize-alist))))
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "(SAS): ess-dial=%s, temp-dial=%s\n"
|
||||
ess-dialect
|
||||
temp-dialect))
|
||||
(ess-SAS-pre-run-hook temp-dialect)
|
||||
(setq ess-eval-visibly-p nil)
|
||||
(inferior-ess)
|
||||
(save-excursion
|
||||
(set-buffer "*SAS*")
|
||||
(use-local-map sas-mode-local-map))))
|
||||
|
||||
|
||||
(defun ess-multi-frame-SAS ()
|
||||
"Put running SAS buffers into separate frames.
|
||||
Load this function M-x load-file essx-sas.el RET.
|
||||
Then find-file myfile.sas. If myfile.sas is already in a buffer, kill-buffer
|
||||
it and then find-file it again.
|
||||
Place the cursor in a myfile.sas buffer. Run SAS with M-x SAS,
|
||||
Return the cursor to the myfile.sas buffer,
|
||||
then enter C-c C-w to put *SAS* *SAS.log* *SAS.lst* buffers into
|
||||
their own frames."
|
||||
(interactive)
|
||||
(delete-other-windows)
|
||||
(save-excursion
|
||||
(set-buffer "*SAS*")
|
||||
(make-frame)
|
||||
(set-buffer "*SAS.log*")
|
||||
(make-frame)
|
||||
(set-buffer "*SAS.lst*")
|
||||
(make-frame)))
|
||||
|
||||
|
||||
(add-hook 'ess-mode-hook
|
||||
(lambda ()
|
||||
(when (string= ess-language "SAS") ;; e.g. not for R-only users
|
||||
(local-set-key "\C-c\C-w" 'ess-multi-frame-SAS))))
|
||||
|
||||
; Provide package
|
||||
|
||||
(provide 'ess-sas-d)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; outline-minor-mode: nil
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-sas-d.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-sas-d.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-sas-d.elc
Normal file
Binary file not shown.
1915
.emacs.d/elpa/ess-20160208.453/lisp/ess-sas-l.el
Executable file
1915
.emacs.d/elpa/ess-20160208.453/lisp/ess-sas-l.el
Executable file
File diff suppressed because it is too large
Load Diff
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-sas-l.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-sas-l.elc
Normal file
Binary file not shown.
74
.emacs.d/elpa/ess-20160208.453/lisp/ess-send.el
Normal file
74
.emacs.d/elpa/ess-20160208.453/lisp/ess-send.el
Normal file
@@ -0,0 +1,74 @@
|
||||
;; First pass at context sensitive help.
|
||||
|
||||
(defun ess-eval-expanded (&optional head tail commands-buffer)
|
||||
"Send the expanded current region or word-at-point to the
|
||||
inferior-ess process after first concating the head and tail.
|
||||
If the region is active, the function uses the current region.
|
||||
If the region is not active, the function uses the word-at-point"
|
||||
(interactive)
|
||||
(if (not head) (setq head "summary("))
|
||||
(if (not tail) (setq tail ")"))
|
||||
(if (not commands-buffer) (setq commands-buffer (get-buffer-create "tmp-buffer")))
|
||||
(let (kill-ring
|
||||
current-word)
|
||||
(if mark-active
|
||||
(progn
|
||||
(copy-region-as-kill (region-beginning) (region-end))
|
||||
(setq current-word (current-kill 1)))
|
||||
(setq current-word (word-at-point)))
|
||||
(ess-command (concat head current-word tail) commands-buffer)))
|
||||
|
||||
;; this is probably not the best key or key-map
|
||||
(define-key ess-mode-map "\C-c\C-w" 'ess-eval-expanded)
|
||||
|
||||
|
||||
|
||||
|
||||
;; previous version, sends expanded text to Commands window
|
||||
|
||||
;;;(defun ess-eval-expanded (&optional head tail) ""
|
||||
;;; (interactive)
|
||||
;;; (if (not head) (setq head "summary("))
|
||||
;;; (if (not tail) (setq tail ")"))
|
||||
;;; (let (kill-ring
|
||||
;;; current-word)
|
||||
;;; (if mark-active
|
||||
;;; (progn
|
||||
;;; (copy-region-as-kill (region-beginning) (region-end))
|
||||
;;; (setq current-word (current-kill 1)))
|
||||
;;; (setq current-word (word-at-point)))
|
||||
;;; (ess-eval-linewise (concat head current-word tail))))
|
||||
;;;(define-key ess-mode-map "\C-c\C-w" 'ess-eval-expanded)
|
||||
|
||||
|
||||
|
||||
|
||||
;; First working version: set of three functions.
|
||||
;; The region and word-at-point are in independent functions and
|
||||
;; and are called by the main function.
|
||||
|
||||
;;(defun ess-eval-expanded (&optional head tail) ""
|
||||
;; (interactive)
|
||||
;; (if mark-active (ess-eval-expanded-region
|
||||
;; (region-beginning) (region-end) head tail)
|
||||
;; (ess-eval-expanded-word-at-point head tail)))
|
||||
|
||||
;;(defun ess-eval-expanded-region (start end &optional head tail)
|
||||
;; "Send the expanded current region to the inferior ESS process after
|
||||
;;first concating the head and tail."
|
||||
;; (let (kill-ring
|
||||
;; expanded-region)
|
||||
;; (copy-region-as-kill start end)
|
||||
;; (setq expanded-region (concat head (current-kill 1) tail))
|
||||
;; (ess-eval-linewise expanded-region))
|
||||
;;)
|
||||
|
||||
;; (setq debug-on-error t)
|
||||
|
||||
;;(defun ess-eval-expanded-word-at-point (&optional head tail)
|
||||
;; "Send the expanded word-at-point to the inferior ESS process after
|
||||
;;first concating the head and tail."
|
||||
;; (let (expanded-region)
|
||||
;; (setq expanded-region (concat head (word-at-point) tail))
|
||||
;; (ess-eval-linewise expanded-region))
|
||||
;;)
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-send.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-send.elc
Normal file
Binary file not shown.
54
.emacs.d/elpa/ess-20160208.453/lisp/ess-send2.el
Normal file
54
.emacs.d/elpa/ess-20160208.453/lisp/ess-send2.el
Normal file
@@ -0,0 +1,54 @@
|
||||
;;(defun ess-eval-string (string) "" body)
|
||||
;;(defun ess-eval-string-popup (string) "" body)
|
||||
;;(defun ess-eval-string-buffer (string) "" body)
|
||||
|
||||
(defun ess-region-or-word-at-point ()
|
||||
"If the region is active, return the contents of the region.
|
||||
If the region is not active, return the word-at-point."
|
||||
(interactive)
|
||||
(if mark-active
|
||||
(buffer-substring-no-properties (region-beginning) (region-end))
|
||||
(word-at-point)))
|
||||
|
||||
|
||||
(defun ess-eval-expanded (&optional head tail commands-buffer)
|
||||
"Send the expanded region or word-at-point to the inferior-ess
|
||||
process after first concating the head and tail. If the region is
|
||||
active, the function uses the current region. If the region is not
|
||||
active, the function uses the word-at-point"
|
||||
(interactive)
|
||||
(if (not head) (setq head "summary("))
|
||||
(if (not tail) (setq tail ")"))
|
||||
(if (not commands-buffer) (setq commands-buffer
|
||||
(get-buffer-create "tmp-buffer")))
|
||||
(ess-command (concat head
|
||||
(ess-region-or-word-at-point)
|
||||
tail)
|
||||
commands-buffer))
|
||||
(define-key ess-mode-map "\C-c\C-w" 'ess-eval-expanded)
|
||||
|
||||
;; (defun ess-expand-string (string &optional head tail)
|
||||
;; "Expand the STRING by concating the HEAD and TAIL.
|
||||
;; Default result is 'summary(string)'."
|
||||
;; (interactive)
|
||||
;; (if (not head) (setq head "summary("))
|
||||
;; (if (not tail) (setq tail ")"))
|
||||
;; (concat head string tail))
|
||||
|
||||
|
||||
;; Write a popup Edit-data-menubar that will allow attributes and components
|
||||
;; to be displayed.
|
||||
;;
|
||||
;; popup menu items:
|
||||
;; summary
|
||||
;; print
|
||||
;; show
|
||||
;; help
|
||||
;; dump to buffer
|
||||
;; Edit.data (with optional location: window/buffer/frame)
|
||||
;; drilldown
|
||||
;; place in quotes (needed to get help on "[[" for example)
|
||||
;; browser on
|
||||
;; browser off
|
||||
;; browser popup menu
|
||||
;; add your own item to this menu
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-send2.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-send2.elc
Normal file
Binary file not shown.
792
.emacs.d/elpa/ess-20160208.453/lisp/ess-site.el
Normal file
792
.emacs.d/elpa/ess-20160208.453/lisp/ess-site.el
Normal file
@@ -0,0 +1,792 @@
|
||||
;;; ess-site.el --- user customization of ESS
|
||||
|
||||
;; Copyright (C) 1993 David M. Smith
|
||||
;; Copyright (C) 1997--2012 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: David Smith <D.M.Smith@lancaster.ac.uk>
|
||||
;; Created: 12 Nov 1993
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
;; Keywords: local
|
||||
|
||||
;; This file is part of ESS
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This file defines all the site-specific customizations for ESS. It should be
|
||||
;; edited on a per-site basis. Read the comments (1.1 in Section 1 to see if
|
||||
;; ess-site.el must be edited. The final directory location of this file must be
|
||||
;; supplied in ess-lisp-directory. The editing of remaining sections is
|
||||
;; optional. It should then be byte-compiled, and users who wish to use ESS
|
||||
;; should add the line:
|
||||
;;
|
||||
;; (load "/PATH/TO/THIS/FILE/ess-site")
|
||||
;;
|
||||
;; (where /PATH/TO/THIS/FILE is the path to ess-site.elc: i.e. the value of
|
||||
;; `ess-lisp-directory', below) to their .emacs file.
|
||||
;;
|
||||
;; Alternatively, if the file is already in a directory specified by
|
||||
;; the load-path variable:
|
||||
;;
|
||||
;; (require 'ess-site)
|
||||
;;
|
||||
;; will work.
|
||||
;;
|
||||
;; with XEmacs, this is simply:
|
||||
;;
|
||||
;; (add-path "/path/to/ess/lisp-directory")
|
||||
;;
|
||||
;; with Emacs (and in general):
|
||||
;;
|
||||
;; (setq load-path (cons "/path/to/ess/lisp-directory" load-path))
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; provide here; otherwise we'll get infinite loops of (require ..):
|
||||
(provide 'ess-site)
|
||||
;;(require 'ess-sp6-d)
|
||||
|
||||
;;;; 1. Load path, autoloads, and major modes
|
||||
;;;; ========================================
|
||||
;;;
|
||||
;;; (1.1) For most users the variable ess-lisp-directory will
|
||||
;;; automatically be set correctly. If you are working with an old
|
||||
;;; emacs, one in which file-truename is not defined, then you might
|
||||
;;; need to change the value of ess-lisp-directory to the directory
|
||||
;;; which is to contain the file ess-site.elc. This is probably the
|
||||
;;; current directory, or the value of LISPDIR if it was set in the
|
||||
;;; Makefile.
|
||||
|
||||
(eval-and-compile
|
||||
|
||||
;; Not important in XEmacs, if unpacking from ../xemacs/site-lisp/
|
||||
;; directory.
|
||||
|
||||
;; WARNING: with Emacs 20.2 (and 20.3 in one case),
|
||||
;; ======= MUST USE ONE OF THE NON-DEFAULT SETTINGS BELOW
|
||||
|
||||
;; NOTE again: MOST people should NOT change anything here !!!
|
||||
;; ==== ==== ================
|
||||
|
||||
;; A nice default
|
||||
(defvar ess-lisp-directory
|
||||
(directory-file-name
|
||||
(file-name-directory
|
||||
(if (and (boundp 'load-file-name) load-file-name) ;; A nice default
|
||||
(file-truename load-file-name)
|
||||
(locate-library "ess-site") )))
|
||||
"Directory containing ess-site.el(c) and other ESS lisp files.")
|
||||
|
||||
|
||||
;; NON DEFAULTS:
|
||||
;;(defvar ess-lisp-directory
|
||||
;;(directory-file-name "/usr/local/lib/xemacs/site-lisp/ess-/lisp"))
|
||||
;; >> or replace "ess-" above by "ESS" which would be a symbolic link..
|
||||
;; >> This way, your .emacs (or default.el or site-start.el)
|
||||
;; >> won't have to change with each version of ESS
|
||||
|
||||
;; example of "local" or personal use
|
||||
;;(defvar ess-lisp-directory
|
||||
;;(directory-file-name "/stat2/faculty/rossini/ESS/lisp"))
|
||||
|
||||
;;)
|
||||
|
||||
;; emacs 19.28 and 19.29 don't have functions we need.
|
||||
(if (not (fboundp 'file-name-sans-extension))
|
||||
;; take the definition from emacs-20.6/lisp/files.el:
|
||||
(defun file-name-sans-extension (filename)
|
||||
"Return FILENAME sans final \"extension\".
|
||||
The extension, in a file name, is the part that follows the last `.'."
|
||||
(save-match-data
|
||||
(let ((file (file-name-sans-versions
|
||||
(file-name-nondirectory filename)))
|
||||
directory)
|
||||
(if (string-match "\\.[^.]*\\'" file)
|
||||
(if (setq directory (file-name-directory filename))
|
||||
(expand-file-name (substring file 0 (match-beginning 0))
|
||||
directory)
|
||||
(substring file 0 (match-beginning 0)))
|
||||
filename)))))
|
||||
|
||||
(add-to-list 'load-path (file-name-as-directory ess-lisp-directory))
|
||||
|
||||
;; Need these as early as here [also in ./ess-comp.el] :
|
||||
(if (not (boundp 'ess-show-load-messages))
|
||||
(defvar ess-show-load-messages nil
|
||||
"If t, show many more \"loading ..\" messages."))
|
||||
(if (not (fboundp 'ess-message))
|
||||
(defun ess-message (format-string &rest args)
|
||||
"Shortcut for \\[message] only if `ess-show-load-messages' is non-nil."
|
||||
(if ess-show-load-messages (message format-string args)))
|
||||
)); eval-*-compile
|
||||
|
||||
;; DEBUG: (setq ess-show-load-messages t); instead of nil above
|
||||
|
||||
(ess-message
|
||||
(format "[ess-site:] ess-lisp-directory = '%s'" ess-lisp-directory))
|
||||
|
||||
;; load code to figure out what version/strain of Emacs we are running
|
||||
;; must come *AFTER* load-path is set !
|
||||
|
||||
;;; The following require sets ess-local-custom-available to
|
||||
;;; true if custom is provided at this point.
|
||||
(require 'ess-compat)
|
||||
;;; If it is not provided, but we think it will be available when necessary,
|
||||
;;; then we can use the following line (uncommented) to make sure that
|
||||
;;; it will be used. If you have to ask, then you don't need this.
|
||||
;;(setq ess-local-custom-available t)
|
||||
|
||||
;; SJE Thu 13 May 2004
|
||||
;; Maybe ess-etc-directory should not be defcustom, since its value
|
||||
;; depends on ess-lisp-directory, and is needed by other modes that are
|
||||
;; loaded before the custom code.
|
||||
(defvar ess-etc-directory nil
|
||||
"Location of the ESS etc/ directory.
|
||||
The ESS etc directory stores various auxillary files that are useful
|
||||
for ESS, such as icons.")
|
||||
|
||||
(defvar ess-etc-directory-list
|
||||
'("../etc/ess/" "../etc/" "../../etc/ess/" "./etc/")
|
||||
"List of directories, relative to `ess-lisp-directory', to search for etc.")
|
||||
|
||||
(while (and (listp ess-etc-directory-list) (consp ess-etc-directory-list))
|
||||
(setq ess-etc-directory
|
||||
(expand-file-name (concat ess-lisp-directory "/"
|
||||
(car ess-etc-directory-list))))
|
||||
(if (file-directory-p ess-etc-directory)
|
||||
(setq ess-etc-directory-list nil)
|
||||
(setq ess-etc-directory nil)
|
||||
(setq ess-etc-directory-list (cdr ess-etc-directory-list))
|
||||
(when (null ess-etc-directory-list)
|
||||
(beep 0) (beep 0)
|
||||
(message (concat
|
||||
"ERROR:ess-site.el:ess-etc-directory\n"
|
||||
"Relative to ess-lisp-directory, one of the following must exist:\n"
|
||||
"../etc/ess, ../etc, ../../etc/ess or ./etc"))
|
||||
(sit-for 4))))
|
||||
|
||||
;;-- no longer used thanks to the (unless ...) clause below --
|
||||
;; (defvar ess-info-directory nil
|
||||
;; "*Location of the ESS info/ directory.
|
||||
;; The ESS info directory stores the ESS info files.")
|
||||
|
||||
|
||||
;;(1.2) If ess.info is not found, then ess-lisp-directory/../doc/info is added
|
||||
;; resurrecting Stephen's version with a bug-fix & xemacs compatibility
|
||||
(if (fboundp 'locate-file) (progn
|
||||
(unless (locate-file "ess.info"
|
||||
(if (featurep 'xemacs)
|
||||
Info-directory-list
|
||||
Info-default-directory-list))
|
||||
(add-to-list (if (featurep 'xemacs)
|
||||
'Info-directory-list 'Info-default-directory-list)
|
||||
(expand-file-name "../doc/info/" ess-lisp-directory)))))
|
||||
|
||||
|
||||
;; ALWAYS:
|
||||
(ess-message "[ess-site:] require 'ess *ITSELF* ...")
|
||||
(require 'ess); -> loads ess-custom.el and more
|
||||
(ess-message "[ess-site:] .. after requiring 'ess ...")
|
||||
|
||||
|
||||
;;; (1.3) Files ending in .q and .S are considered to be S source files
|
||||
;;; Files ending in .St are considered to be S transcript files
|
||||
;;;
|
||||
;;; NB: in standard Emacs, files ending in .s are assembler files. If you
|
||||
;;; want to use assembler. If a user wants to
|
||||
;;; restore the default modes for assembly file extensions, the
|
||||
;;; following can go into ~/.emacs or ~/.xemacs/init.el
|
||||
;;;
|
||||
;;; (add-hook 'ess-mode-hook 'ess-restore-asm-extns)
|
||||
;;; (add-hook 'inferior-ess-mode-hook 'ess-restore-asm-extns)
|
||||
|
||||
(autoload 'Rd-mode "ess-rd" "Major mode for editing R documentation." t)
|
||||
|
||||
; Here is a workaround for an Emacs bug related to indirect buffers and
|
||||
; spurious lockfiles that rears its ugly head with .Rd files
|
||||
; http://lists.gnu.org/archive/html/bug-gnu-emacs/2013-02/msg01368.html
|
||||
; http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14328
|
||||
(if (featurep 'xemacs) nil
|
||||
;; (add-hook 'Rd-mode-hook (lambda ()
|
||||
;; (set (make-local-variable create-lockfiles) nil)))
|
||||
|
||||
(make-local-variable 'create-lockfiles)
|
||||
|
||||
(add-hook 'Rd-mode-hook (lambda () (setq create-lockfiles nil)))
|
||||
)
|
||||
|
||||
;; This is thanks to Ed L Cashin <ecashin@uga.edu>, 03 Mar 2004 :
|
||||
(defun ess-restore-asm-extns ()
|
||||
"Remove the S-Plus mode association for .s and .S files added by ESS.
|
||||
Putting the following in ~/.emacs restores emacs' default association
|
||||
between .s or .S files and assembly mode.
|
||||
|
||||
(add-hook 'ess-mode-hook 'ess-restore-asm-extns)
|
||||
(add-hook 'inferior-ess-mode-hook 'ess-restore-asm-extns)"
|
||||
(interactive)
|
||||
(when (assoc "\\.[qsS]\\'" auto-mode-alist)
|
||||
(setq auto-mode-alist
|
||||
(remassoc "\\.[qsS]\\'" auto-mode-alist))
|
||||
;; put .q extention back
|
||||
;; (add-to-list is in xemacs and GNU emacs)
|
||||
;; R-mode when in a R/ subdirectory, otherwise S-mode:
|
||||
(add-to-list 'auto-mode-alist '("/R/.*\\.q\\'" . R-mode))
|
||||
(add-to-list 'auto-mode-alist '("\\.q\\'" . S-mode))
|
||||
))
|
||||
|
||||
;; Be careful when editing the following. MISTAKES WILL RESULT IN
|
||||
;; *.sty BEING TREATED AS ESS[S], rather than LaTeX-mode!
|
||||
|
||||
(if (assoc "\\.[rR]\\'" auto-mode-alist) nil
|
||||
(setq auto-mode-alist
|
||||
(append
|
||||
'(("\\.sp\\'" . S-mode) ;; re: Don MacQueen <macq@llnl.gov>
|
||||
("/R/.*\\.q\\'" . R-mode) ;; R/*.q is R code (e.g., in package)
|
||||
("\\.[qsS]\\'" . S-mode) ;; s,S [see ess-restore-asm-extns above!]
|
||||
("\\.ssc\\'" . S-mode) ;; Splus (>= 4.x) script files.
|
||||
("\\.SSC\\'" . S-mode) ;; ditto for windoze
|
||||
("\\.[rR]\\'" . R-mode)
|
||||
("\\.[rR]nw\\'" . Rnw-mode)
|
||||
("\\.[sS]nw\\'" . Snw-mode); currently identical to Rnw-mode
|
||||
("\\.[rR]profile\\'" . R-mode)
|
||||
("NAMESPACE\\'" . R-mode)
|
||||
("CITATION\\'" . R-mode)
|
||||
("\\.omg\\'" . omegahat-mode)
|
||||
("\\.hat\\'" . omegahat-mode) ;; Duncan's pref'd...
|
||||
("\\.lsp\\'" . XLS-mode)
|
||||
("\\.do\\'" . STA-mode)
|
||||
("\\.ado\\'" . STA-mode)
|
||||
("\\.[Ss][Aa][Ss]\\'" . SAS-mode)
|
||||
;; Many .log/.lst files, not just SAS
|
||||
;;("\\.log\\'" . SAS-log-mode)
|
||||
;;("\\.[Ll][Ss][Tt]\\'" . SAS-listing-mode)
|
||||
("\\.[Ss]t\\'" . S-transcript-mode)
|
||||
("\\.Sout" . S-transcript-mode)
|
||||
;;("\\.[Rr]t\\'" . R-transcript-mode)
|
||||
("\\.[Rr]out" . R-transcript-mode)
|
||||
("\\.Rd\\'" . Rd-mode)
|
||||
("\\.[Bb][Uu][Gg]\\'" . ess-bugs-mode)
|
||||
("\\.[Bb][Oo][Gg]\\'" . ess-bugs-mode)
|
||||
("\\.[Bb][Mm][Dd]\\'" . ess-bugs-mode)
|
||||
("\\.[Jj][Aa][Gg]\\'" . ess-jags-mode)
|
||||
("\\.[Jj][Oo][Gg]\\'" . ess-jags-mode)
|
||||
("\\.[Jj][Mm][Dd]\\'" . ess-jags-mode)
|
||||
)
|
||||
auto-mode-alist)))
|
||||
|
||||
;; Rscript and littler interpreters recognized. XEmacs entries can
|
||||
;; be regexps, which complicates matters as "r" on its own matches
|
||||
;; other interpeters like "perl".
|
||||
(add-to-list 'interpreter-mode-alist '("Rscript" . r-mode))
|
||||
(add-to-list 'interpreter-mode-alist
|
||||
(cons (if (featurep 'xemacs) "r$" "r") 'r-mode))
|
||||
|
||||
|
||||
;; (1.4) Customize the dialects for your setup.
|
||||
|
||||
;;; AS OF ESS 5.1.14, if you are using Emacs 20.x, x>3, or XEmacs
|
||||
;;; 21.x, x>0, you can now use the "Customize" facility for
|
||||
;;; customization.
|
||||
|
||||
;;;; Choices for *(), where * is from inferior-*-program....
|
||||
;;; Most sites will not need to use these customized program-names. They are
|
||||
;;; provided for cases where the program is not on the standard default path.
|
||||
;;; If the program doesn't get located correctly by the default use of
|
||||
;;; M-x S+3 (for example), then put the path name for your system into the
|
||||
;;; the variable inferior-S+3-program-name. If for any reason you want the
|
||||
;;; default use of M-x S to refer to a different program than S+3, then
|
||||
;;; redefine inferior-S-program-name.
|
||||
|
||||
;;(setq-default inferior-S3-program-name "/disk05/s/S")
|
||||
;;(setq-default inferior-S+3-program-name "Splus34")
|
||||
;;(setq-default inferior-S4-program-name "/disk05/s4/S")
|
||||
;;(setq-default inferior-S+4-program-name "Splus")
|
||||
;;(setq-default inferior-S+5-program-name "Splus5")
|
||||
;;(setq-default inferior-S+-program-name "Splus7") ; unix systems ; or
|
||||
;;(setq-default inferior-S+-program-name "Splus") ; unix systems
|
||||
;;
|
||||
;; If you wish to call other versions of R on a Unix system, ESS
|
||||
;; should auto-detect other versions of R, according to matches to the
|
||||
;; variable `ess-r-versions' as described in its docstring. Consider
|
||||
;; changing that variable rather than changing inferior-R-program-name
|
||||
;; if your version of R is not already auto-detected.
|
||||
;;(setq-default inferior-R-program-name "R") ; unix systems
|
||||
;;(setq-default inferior-R-program-name "Rterm") ; MS Windows, see below for path as well
|
||||
;;(setq-default inferior-R-program-name "C:\\Program Files\\R\\R-2.5.0\\bin\\Rterm.exe")
|
||||
;;(setq-default inferior-XLS-program-name "xlispstat")
|
||||
;;(setq-default inferior-ARC-program-name "arc")
|
||||
;;(setq-default inferior-VST-program-name "vista")
|
||||
;;(setq-default inferior-SAS-program-name "sas")
|
||||
;;(setq-default inferior-OMG-program-name "/home/rossini/src/anoncvs/Omegahat/org/omegahat/bin/omegahat")
|
||||
(setq-default inferior-OMG-program-name "omegahat")
|
||||
|
||||
;;; The line below is the ESS default and sends the commands window
|
||||
;;; to emacs, giving the user the opportunity to
|
||||
;;; (1) edit the output into a clean ess-transcript file before printing, or
|
||||
;;; (2) print a region of the file.
|
||||
;;(setq-default inferior-S+4-print-command "S_PRINT_COMMAND=emacsclientw.exe")
|
||||
|
||||
;;; The editor and pager output from S+4 and Sqpe+4 are sent by
|
||||
;;; StatSci default to notepad, effectively using the definition:
|
||||
;;(setq-default inferior-S+4-editor-pager-command
|
||||
;; "options(editor='notepad', pager='notepad')")
|
||||
;;;
|
||||
;;; ESS sends the output from both commands to an emacs buffer using
|
||||
;;; the definition:
|
||||
;;(setq-default inferior-S+4-editor-pager-command
|
||||
;; "options(editor='emacsclient.exe', pager='emacsclientw.exe')")
|
||||
|
||||
;;; These commands are for running the PC version of Sqpe of S+4 and
|
||||
;;; S+6 in an emacs buffer, using the same technology as ESS uses for
|
||||
;;; Unix S-Plus. Interactive graphics with javagraph are available
|
||||
;;; in this mode beginning with S-Plus 6.1.
|
||||
;;; See ess-sp4-d.el or ess-sp6w-d.el
|
||||
|
||||
;;; -----> configuration now via custom, see ./ess-custom.el and look for
|
||||
;;; inferior-Sqpe+... e.g. inferior-Sqpe+6-program-name
|
||||
|
||||
;;; These ddeclient values will be buffer-local on MS-Windows 9x/NT
|
||||
(setq-default inferior-ess-ddeclient "Initial")
|
||||
(setq-default inferior-ess-client-name "Initial")
|
||||
(setq-default inferior-ess-client-command "Initial")
|
||||
|
||||
;;; S-Plus 6 for Windows startup time depends on the amount of RAM and
|
||||
;;; the processor speed. ESS needs to build a delay into the M-x S+6
|
||||
;;; sequence to allow time for S-Plus 6 to open the Commands window.
|
||||
;;; We then send several lines to the Commands window before returning
|
||||
;;; control to the user. On a 300 MHz machine with 96MB of RAM the
|
||||
;;; delay is 60 seconds. On a ???? MHz machine with 523MB the delay is
|
||||
;;; 10 seconds. The user may need to adjust this number.
|
||||
(defvar ess-S+6-startup-delay 15 ;; <- 2005-01-03; MM
|
||||
"*Number of seconds to wait for the Commands window to appear before
|
||||
sending `inferior-ess-language-start' to S-Plus.")
|
||||
|
||||
|
||||
;;; see essd-els.el
|
||||
|
||||
;;(setq-default inferior-S-elsewhere-program-name "sh")
|
||||
;;(setq-default inferior-S-elsewhere-program-name "ssh")
|
||||
;;; You might consider using ssh, if you can! (and if you really do
|
||||
;;; this, use ssh-agent, etc, for securing your sessions).
|
||||
|
||||
|
||||
;;;; Choice for S().
|
||||
;;(setq-default inferior-S-program-name inferior-S+3-program-name)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;; (1.5) Require the needed dialects for your setup.
|
||||
|
||||
(ess-message "[ess-site:] Before requiring dialect 'ess-*-d ....")
|
||||
(ess-message "[ess-site:] require 'ess-r-d ...")
|
||||
(require 'ess-r-d) ;; R
|
||||
(require 'ess-julia)
|
||||
;; (ess-message "[ess-site:] require 'ess-s4-d ...")
|
||||
;; (require 'ess-s4-d) ; has become VERY RARE ..
|
||||
|
||||
;;(ess-message "[ess-site:] require 'ess-s3-d ...")
|
||||
;;(require 'ess-s3-d) ; THIS IS RARE. You probably do not have this.
|
||||
|
||||
;; "sp" refers to S-PLUS (MathSoft/StatSci/Insightful/TIBCO):
|
||||
(ess-message "[ess-site:] require 'ess-sp3-d ...")
|
||||
(require 'ess-sp3-d)
|
||||
|
||||
(if ess-microsoft-p
|
||||
(progn
|
||||
;; (ess-message "[ess-site:] require 'ess-sp4-d ...")
|
||||
;; (require 'ess-sp4-d)
|
||||
(ess-message "[ess-site:] require 'ess-sp6w-d ...")
|
||||
(require 'ess-sp6w-d))
|
||||
;; else: decent OS
|
||||
;; (ess-message "[ess-site:] require 'ess-sp5-d ...")
|
||||
;; (require 'ess-sp5-d)
|
||||
(ess-message "[ess-site:] require 'ess-sp6-d ...")
|
||||
(require 'ess-sp6-d))
|
||||
|
||||
(ess-message "[ess-site:] require 'ess-sta-d ...")
|
||||
(require 'ess-sta-d) ;; for Stata.
|
||||
;; (ess-message "[ess-site:] require 'ess-xls-d ...")
|
||||
;; (require 'ess-xls-d) ;; XLispStat
|
||||
;; (ess-message "[ess-site:] require 'ess-vst-d ...")
|
||||
;; (require 'ess-vst-d) ;; ViSta
|
||||
;; (ess-message "[ess-site:] require 'ess-arc-d ...")
|
||||
;; (require 'ess-arc-d) ;; Arc
|
||||
(ess-message "[ess-site:] require 'ess-sas-d ...")
|
||||
(require 'ess-sas-d)
|
||||
(ess-message "[ess-site:] require 'essd-els ...")
|
||||
(require 'essd-els) ;; S-elsewhere, on another machine by telnet
|
||||
;; (ess-message "[ess-site:] require 'ess-omg-d ...")
|
||||
;; (require 'ess-omg-d) ;; for omegahat
|
||||
(ess-message "[ess-site:] require 'ess-bugs-l ...")
|
||||
(require 'ess-bugs-l) ;; for batch BUGS
|
||||
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "[ess-site.el]: ess-customize-alist=%s \n"
|
||||
ess-customize-alist))
|
||||
|
||||
;;; (1.7) Literate Data Analysis
|
||||
(require 'ess-noweb)
|
||||
(require 'ess-swv); for Sweave
|
||||
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "[ess-site.el _2_]: ess-customize-alist=%s \n"
|
||||
ess-customize-alist))
|
||||
|
||||
;; (1.8) Speedbar and mouse
|
||||
|
||||
(ess-message "[ess-site:] require 'ess-menu ...")
|
||||
(require 'ess-menu)
|
||||
(require 'ess-mouse)
|
||||
|
||||
;; (1.9) Toolbar support
|
||||
|
||||
;; To remove toolbar support under ESS, add "(setq ess-use-toolbar nil)"
|
||||
;; to your ~/.emacs or ~/.xemacs/init.el before (require 'ess-site)
|
||||
(ess-message "[ess-site:] require 'ess-toolbar ...")
|
||||
(require 'ess-toolbar)
|
||||
|
||||
;;; 2. Site Specific setup
|
||||
;;;; ===============================================
|
||||
|
||||
;;; Set this to the name of the program you use to run S or S-PLUS. It
|
||||
;;; can be an absolute pathname, if you wish.
|
||||
;;(setq inferior-ess-program "Splus")
|
||||
;;(setq inferior-ess-program (concat (getenv "SHOME") "/Splus"))
|
||||
|
||||
|
||||
;;; 2.1 Backwards compatibility (roll your own!)
|
||||
;;; What you want S and R to call...
|
||||
|
||||
(autoload 'ess-transcript-mode "ess-trns"
|
||||
"Major mode for editing S transcript files." t)
|
||||
(autoload 'ess-transcript-clean-region "ess-trns" no-doc t)
|
||||
|
||||
(autoload 'ess-rdired "ess-rdired"
|
||||
"View *R* objects in a dired-like buffer." t)
|
||||
|
||||
|
||||
;;; On a PC, the default is S+.
|
||||
;; Elsewhere (unix and linux) the default is S+
|
||||
(cond (ess-microsoft-p
|
||||
;; MS-Windows-------------------------------------------------
|
||||
|
||||
;; (fset 'S
|
||||
;; (if (equal (file-name-nondirectory shell-file-name) "cmdproxy.exe")
|
||||
;; 'S+-msdos
|
||||
;; 'S+))
|
||||
(defun S-by-icon (&rest x)
|
||||
(interactive)
|
||||
(message "Please start S+ from the icon.
|
||||
Then you can connect emacs to it with `M-x S-existing'.")
|
||||
)
|
||||
(fset 'S 'S-by-icon)
|
||||
(fset 'S-existing
|
||||
(if (equal (file-name-nondirectory shell-file-name) "cmdproxy.exe")
|
||||
'S+-msdos-existing
|
||||
'S+-existing))
|
||||
(fset 'Sqpe 'Sqpe+)
|
||||
(fset 's-mode 'S+-mode)
|
||||
(fset 's-transcript-mode 'S+-transcript-mode))
|
||||
|
||||
(t ;;((eq system-type 'gnu/linux)
|
||||
;; Linux etc (including Mac OSX !?) --------------------------
|
||||
(fset 'S 'S+)
|
||||
(fset 's-mode 'S+-mode)
|
||||
(fset 's-transcript-mode 'S+-transcript-mode)))
|
||||
|
||||
|
||||
;;;;* Alias S-mode to s-mode
|
||||
;;; Emacs will set the mode for a file based on the file's header.
|
||||
;;; The mode name is indicated by putting it between -*- on the top line.
|
||||
;;; (Other commands can go here too, see an Emacs manual.)
|
||||
;;; For a file you also load, you will want a leading # (comment to S)
|
||||
;;; Emacs will downcase the name of the mode, e.g., S, so we must provide
|
||||
;;; s-mode in lower case too. That is, "#-*- S-*-" invokes s-mode and
|
||||
;;; not S-mode.
|
||||
(fset 'S-transcript-mode 's-transcript-mode)
|
||||
(fset 'S-mode 's-mode)
|
||||
|
||||
;;; Create functions for calling different (older or newer than default)
|
||||
;;; versions of R and S(qpe).
|
||||
(defvar ess-versions-created nil
|
||||
"List of strings of all S- and R-versions found on the system.")
|
||||
|
||||
;; is currently used (updated) by ess-find-newest-R
|
||||
(defvar ess-r-versions-created nil
|
||||
"List of strings of all R-versions found on the system.")
|
||||
|
||||
(defun ess-r-s-versions-creation ()
|
||||
"(Re)Create ESS R-<..> commands FILENAME sans final \"extension\".
|
||||
The extension, in a file name, is the part that follows the last `.'."
|
||||
|
||||
(interactive)
|
||||
(ess-message "[ess-site:] before creating ess-versions-* ...")
|
||||
;; Create ess-versions-created,
|
||||
;; ess-r-versions-created,
|
||||
;; and on Windows, ess-rterm-version-paths -----------------------------------------
|
||||
(let ((R-newest-list '("R-newest"))
|
||||
(ess-s-versions-created (if ess-microsoft-p
|
||||
(nconc
|
||||
(ess-sqpe-versions-create ess-SHOME-versions) ;; 32-bit
|
||||
(ess-sqpe-versions-create ess-SHOME-versions-64 "-64-bit")) ;; 64-bit
|
||||
(ess-s-versions-create)))) ;; use ess-s-versions
|
||||
(if ess-microsoft-p
|
||||
(setq ess-rterm-version-paths ;; (ess-find-rterm))
|
||||
(ess-flatten-list
|
||||
(ess-uniq-list
|
||||
(if (not ess-directory-containing-R)
|
||||
(if (getenv "ProgramW6432")
|
||||
(let ((P-1 (getenv "ProgramFiles(x86)"))
|
||||
(P-2 (getenv "ProgramW6432")))
|
||||
(nconc
|
||||
;; always 32 on 64 bit OS, nil on 32 bit OS
|
||||
(ess-find-rterm (concat P-1 "/R/") "bin/Rterm.exe")
|
||||
(ess-find-rterm (concat P-1 "/R/") "bin/i386/Rterm.exe")
|
||||
;; keep this both for symmetry and because it can happen:
|
||||
(ess-find-rterm (concat P-1 "/R/") "bin/x64/Rterm.exe")
|
||||
|
||||
;; always 64 on 64 bit OS, nil on 32 bit OS
|
||||
(ess-find-rterm (concat P-2 "/R/") "bin/Rterm.exe")
|
||||
(ess-find-rterm (concat P-2 "/R/") "bin/i386/Rterm.exe")
|
||||
(ess-find-rterm (concat P-2 "/R/") "bin/x64/Rterm.exe")
|
||||
))
|
||||
(let ((PF (getenv "ProgramFiles")))
|
||||
(nconc
|
||||
;; always 32 on 32 bit OS, depends on 32 or 64 process on 64 bit OS
|
||||
(ess-find-rterm (concat PF "/R/") "bin/Rterm.exe")
|
||||
(ess-find-rterm (concat PF "/R/") "bin/i386/Rterm.exe")
|
||||
(ess-find-rterm (concat PF "/R/") "bin/x64/Rterm.exe")
|
||||
))
|
||||
)
|
||||
(let ((PF ess-directory-containing-R))
|
||||
(nconc
|
||||
(ess-find-rterm (concat PF "/R/") "bin/Rterm.exe")
|
||||
(ess-find-rterm (concat PF "/R/") "bin/i386/Rterm.exe")
|
||||
(ess-find-rterm (concat PF "/R/") "bin/x64/Rterm.exe")
|
||||
))
|
||||
)))))
|
||||
(ess-message "[ess-site:] (let ... before (ess-r-versions-create) ...")
|
||||
|
||||
(setq ess-r-versions-created ;; for Unix *and* Windows, using either
|
||||
(ess-r-versions-create));; ess-r-versions or ess-rterm-version-paths (above!)
|
||||
|
||||
;; Add the new defuns, if any, to the menu.
|
||||
;; Check that each variable exists, before adding.
|
||||
;; e.g. ess-sqpe-versions-created will not be created on Unix.
|
||||
(setq ess-versions-created
|
||||
(ess-flatten-list
|
||||
(mapcar (lambda(x) (if (boundp x) (symbol-value x) nil))
|
||||
'(R-newest-list
|
||||
ess-r-versions-created
|
||||
ess-s-versions-created))))))
|
||||
|
||||
(defun ess-r-s-versions-creation+menu ()
|
||||
"Call `\\[ess-r-s-versions-creation] creaing `ess-versions-created' and
|
||||
update the \"Start Process\" menu."
|
||||
(interactive)
|
||||
(ess-message "[ess-site:] before (ess-r-s-versions-creation) ...")
|
||||
(ess-r-s-versions-creation)
|
||||
|
||||
(when ess-versions-created
|
||||
;; new-menu will be a list of 3-vectors, of the form:
|
||||
;; ["R-1.8.1" R-1.8.1 t]
|
||||
(let ((new-menu (mapcar (lambda(x) (vector x (intern x) t))
|
||||
ess-versions-created)))
|
||||
(easy-menu-add-item ess-mode-menu '("Start Process")
|
||||
(cons "Other" new-menu))))
|
||||
|
||||
(ess-message "[ess-site:] after ess-versions-created ...")
|
||||
;; return
|
||||
ess-versions-created)
|
||||
|
||||
;; call it
|
||||
(ess-r-s-versions-creation+menu)
|
||||
|
||||
|
||||
;; Check to see that inferior-R-program-name points to a working version
|
||||
;; of R; if not, try to find the newest version:
|
||||
(ess-check-R-program-name) ;; -> (ess-find-newest-R) if needed, in ./ess-r-d.el
|
||||
(ess-message "[ess-site:] after ess-check-R-prog... ...")
|
||||
|
||||
;;; 3. Customization (and examples) for your site
|
||||
;;;; ===============================================
|
||||
|
||||
|
||||
;;; (3.01) SOME PEOPLE (who will remain nameless) worry that novices
|
||||
;;; won't like fancy buffer names for their first (and only :-)
|
||||
;;; process. To number all processes:
|
||||
;;(setq ess-plain-first-buffername nil)
|
||||
|
||||
;;; (3.02) Some people have requested using the program name as part
|
||||
;;; of the buffer. Turned on for R.
|
||||
;;(setq ess-use-inferior-program-name-in-buffer-name t)
|
||||
|
||||
|
||||
;;; (3.1) Font-lock
|
||||
;; The following two expressions automatically enable font-lock-mode
|
||||
;; for ess-mode and inferior-ess-mode buffers.
|
||||
|
||||
;; no longer requiring (window-system) here:
|
||||
(when ess-font-lock-mode
|
||||
(add-hook 'ess-mode-hook 'turn-on-font-lock t)
|
||||
(add-hook 'ess-transcript-mode-hook 'turn-on-font-lock t)
|
||||
(add-hook 'Rd-mode-hook 'turn-on-font-lock t)
|
||||
(add-hook 'inferior-ess-mode-hook 'turn-on-font-lock t))
|
||||
|
||||
|
||||
;;; (3.2) Framepop. Windows produced by ess-execute-objects etc. are
|
||||
;;; often unnecessarily large. The framepop package makes such
|
||||
;;; windows appear in a separate, shrink-wrapped frame. This will
|
||||
;;; also affect other "temporary" windows such as those produced by
|
||||
;;; C-h k, etc. To enable:
|
||||
;;;
|
||||
;;; Works only with Emacs at this time.
|
||||
;; (cond (window-system
|
||||
;; (require 'framepop)))
|
||||
|
||||
;;; (3.3) ess-keep-dump-files.
|
||||
;;; Documentation:
|
||||
;;; *Variable controlling whether to delete dump files after a successful load.
|
||||
;;; If nil: always delete. If `ask', confirm to delete. If `check', confirm
|
||||
;;; to delete, except for files created with ess-dump-object-into-edit-buffer.
|
||||
;;; Anything else (for example `always'): always keep and never delete.
|
||||
;;; This variable only affects the behavior
|
||||
;;; of ess-load-file. Dump files are never deleted if an error occurs
|
||||
;;; during the load.
|
||||
;;;
|
||||
;;; RH sez: I find the default `always' keep to be imperative. The previous
|
||||
;;; default was to throw away
|
||||
;;; files at the wrong time (I think it was something like, if you M-x
|
||||
;;; ess-load a file twice, while you are working on it, the file is
|
||||
;;; deleted). I believe source is real and the ESS object is temporary.
|
||||
;;; The previous default behavior is dangerous for people who believe this way.
|
||||
;;; It made sense only for people who believe the object is real
|
||||
;;; and the source file temporary.
|
||||
(setq ess-keep-dump-files "always")
|
||||
|
||||
;;; (3.4) ess-ask-for-ess-directory
|
||||
;;; If t, will ask for the directory to use. If nil, assumes the
|
||||
;;; default (usually, the users home directory...).
|
||||
;;now rather in ./ess-custom.el : (setq ess-ask-for-ess-directory t)
|
||||
|
||||
;;; (3.5) ess-directory default (correlated with above)
|
||||
;;; The default location for running the subprocess is configurable.
|
||||
;;; By default, that is the default-directory (a lisp variable which
|
||||
;;; initially contains the directory from which the inferior ESS
|
||||
;;; statistical package/process is started).
|
||||
;;; For example, the following function (added to the pre-run-hook, by
|
||||
;;; the line following it) will set the default directory to be your
|
||||
;;; home directory:
|
||||
;;;
|
||||
;;(defun ajr:ess-set-directory ()
|
||||
;; "Set ess-directory to home."
|
||||
;; (setq-default ess-directory (file-name-as-directory (getenv "HOME"))))
|
||||
;;(add-hook 'ess-pre-run-hook 'ajr:ess-set-directory)
|
||||
;;;
|
||||
;;; If you replace the setq-default line with:
|
||||
;;;
|
||||
;; (setq-default ess-directory (file-name-as-directory
|
||||
;; (concat (getenv "HOME") "/ess/")))
|
||||
;;;
|
||||
;;; then it will always start up in the directory "ess" in your home
|
||||
;;; directory.
|
||||
;;;
|
||||
;;; The default is to have ess to start up in the current buffer's
|
||||
;;; directory (the one in which you started the inferior ESS
|
||||
;;; statistical package/process). This is obtained
|
||||
;;; by setting ess-directory to nil, i.e.
|
||||
;; (setq-default ess-directory nil) ; this is the default.
|
||||
|
||||
(when ess-microsoft-p
|
||||
(add-hook 'ess-post-run-hook
|
||||
(lambda()
|
||||
(when (string= ess-dialect "R")
|
||||
(ess-eval-linewise "options(chmhelp=FALSE, help_type=\"text\")"
|
||||
nil nil nil 'wait)))))
|
||||
|
||||
|
||||
;;; 3.6 Example of formatting changes
|
||||
|
||||
;;; Formatting and indentation patterns are defined in ess-custom.el, please
|
||||
;;; see ess-custom.el for exact definitions of these variable settings.
|
||||
;;; To change them (eg, follow changes suggested by Terry Therneau),
|
||||
;;; you need one or both of the following lines:
|
||||
;;;
|
||||
;;(setq ess-indent-with-fancy-comments nil)
|
||||
;;(setq ess-default-style 'CLB)
|
||||
|
||||
;;; 4.0 SAS configuration
|
||||
|
||||
;;; Beginning with ESS 5.1.13, we have editing options in SAS-mode.
|
||||
;;; The default behavior is as it was in prior releases.
|
||||
;;;
|
||||
;;; There are two sets of alternatives.
|
||||
;;; 1. Editing SAS-mode files.
|
||||
;;; 1a. Default: TAB is bound to sas-indent-line.
|
||||
;;; Current line is correctly indented as SAS code. Equivalent to
|
||||
;;;(setq ess-sas-edit-keys-toggle nil) ;; default TAB in sas-mode
|
||||
;;; 1b. Optional: TAB is bound to tab-to-tab-stop and inserts up to 4
|
||||
;;; columns at a time. C-TAB moves backwards and deletes characters
|
||||
;;; up to 4 columns at a time.
|
||||
;;; The following line is for the optional behavior.
|
||||
;;;(setq ess-sas-edit-keys-toggle t) ;; optional TAB and C-TAB in sas-mode
|
||||
;;; Use the function call (ess-sas-edit-keys-toggle)
|
||||
;;; to change the setting after the first SAS-mode buffer has been created.
|
||||
;;; 1c. You can also define C-TAB in all modes by Option 2b (below).
|
||||
;;;
|
||||
;;; 2. Managing submitted SAS jobs with function keys.
|
||||
;;; 2a. Default: To define the function keys in ESS[SAS] mode only,
|
||||
;;; you will need, at most, one of the following two lines.
|
||||
;;;(setq ess-sas-local-unix-keys t) ;; F2-F12 bound in ESS[SAS] mode
|
||||
;;;(setq ess-sas-local-pc-keys t) ;; F2-F12 bound in ESS[SAS] mode
|
||||
;;;
|
||||
;;; 2b. Options: To define the function keys in all modes,
|
||||
;;; you will need, at most, one of the following two lines.
|
||||
;;;(setq ess-sas-global-unix-keys t) ;; F2-F12 bound in all modes
|
||||
;;;(setq ess-sas-global-pc-keys t) ;; F2-F12 bound in all modes
|
||||
;;;
|
||||
;;; 3. If it is more convenient to have "*Async Shell Command*"
|
||||
;;; in same-window-buffer-names, then:
|
||||
;;;(ess-same-window-async)
|
||||
;;;
|
||||
;;;(defvar sas-program "sas" "*Name of program which runs sas.")
|
||||
;;;
|
||||
;;;(defvar sas-indent-width 4 "*Amount to indent sas statements")
|
||||
|
||||
(ess-message "[ido:]")
|
||||
(if (featurep 'emacs)
|
||||
(require 'ido nil t))
|
||||
|
||||
; Local variables section
|
||||
(ess-message "[ess-site:] *very* end ...")
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-site.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-site.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-site.elc
Normal file
Binary file not shown.
105
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp3-d.el
Normal file
105
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp3-d.el
Normal file
@@ -0,0 +1,105 @@
|
||||
;;; ess-sp3-d.el --- S-PLUS 3.x customization
|
||||
|
||||
;; Copyright (C) 1997--2004 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: A.J. Rossini <rossini@u.washington.edu>
|
||||
;; Created: 12 Jun 1997
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; Keywords: languages
|
||||
|
||||
;; This file is part of ESS.
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This file defines all the S-PLUS 3.x customizations for ess-mode.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(autoload 'inferior-ess "ess-inf" "Run an ESS process.")
|
||||
(autoload 'ess-mode "ess-mode" "Edit an ESS process.")
|
||||
|
||||
(require 'ess-s-l)
|
||||
|
||||
(defvar S+3-dialect-name "S+3"
|
||||
"Name of 'dialect' for S-PLUS 3.x.");easily changeable in a user's .emacs
|
||||
|
||||
(defvar S+3-customize-alist
|
||||
(append
|
||||
'((ess-local-customize-alist . 'S+3-customize-alist)
|
||||
(ess-dialect . S+3-dialect-name)
|
||||
(ess-loop-timeout . ess-S-loop-timeout);fixme: dialect spec.
|
||||
(ess-object-name-db-file . "ess-s+3-namedb.el" )
|
||||
(inferior-ess-program . inferior-S+3-program-name)
|
||||
(inferior-ess-help-command . "help(\"%s\", pager=\"cat\", window=FALSE)\n")
|
||||
(inferior-ess-help-filetype . nil)
|
||||
(inferior-ess-search-list-command . "search()\n")
|
||||
(inferior-ess-start-file . nil) ;"~/.ess-S+3")
|
||||
(inferior-ess-start-args . "")
|
||||
(ess-STERM . "iESS")
|
||||
)
|
||||
S+common-cust-alist)
|
||||
|
||||
"Variables to customize for S+3.")
|
||||
|
||||
|
||||
(defun S+3 (&optional proc-name)
|
||||
"Call 'S-PLUS 3.x', the 'Real Thing' from StatSci."
|
||||
(interactive)
|
||||
(setq ess-customize-alist S+3-customize-alist)
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "\n(S+3): ess-dialect=%s, buf=%s\n" ess-dialect (current-buffer)))
|
||||
(inferior-ess)
|
||||
(if inferior-ess-language-start
|
||||
(ess-eval-linewise inferior-ess-language-start)))
|
||||
|
||||
(defun S+3-mode (&optional proc-name)
|
||||
"Major mode for editing S+3 source. See `ess-mode' for more help."
|
||||
(interactive)
|
||||
(setq ess-customize-alist S+3-customize-alist)
|
||||
(ess-mode S+3-customize-alist proc-name)
|
||||
(if ess-imenu-use-S (ess-imenu-S)))
|
||||
|
||||
(defun S+3-transcript-mode ()
|
||||
"S-PLUS 3.x transcript mode."
|
||||
(interactive)
|
||||
(ess-transcript-mode S+3-customize-alist))
|
||||
|
||||
|
||||
|
||||
; Provide package
|
||||
|
||||
(provide 'ess-sp3-d)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; outline-minor-mode: nil
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-sp3-d.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp3-d.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp3-d.elc
Normal file
Binary file not shown.
421
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp4-d.el
Normal file
421
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp4-d.el
Normal file
@@ -0,0 +1,421 @@
|
||||
;;; ess-sp4-d.el --- S-PLUS 4.x customization
|
||||
|
||||
;; Copyright (C) 1998--2002 Richard M. Heiberger <rmh@temple.edu>
|
||||
;; Copyright (C) 2003--2004 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: Richard M. Heiberger <rmh@temple.edu>
|
||||
;; Created: December 1998
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; Keywords: languages
|
||||
|
||||
;; This file is part of ESS.
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This file defines all the S-PLUS 4.x customizations for ess-mode
|
||||
;; with ddeclient.
|
||||
|
||||
;;; Code:
|
||||
|
||||
;;; Requires and Autoloads:
|
||||
|
||||
(require 'ess-s-l)
|
||||
;;NO: this is autoloaded from other places (require 'ess-dde)
|
||||
|
||||
(autoload 'inferior-ess "ess-inf" "Run an ESS process.")
|
||||
(autoload 'ess-mode "ess-mode" "Edit an ESS process.")
|
||||
|
||||
(defvar S+4-dialect-name "S+4"
|
||||
"Name of 'dialect' for S-PLUS 4.x.");easily changeable in a user's .emacs
|
||||
|
||||
(defvar inferior-S+4-multipleinstances "/MULTIPLEINSTANCES"
|
||||
"Default \"/MULTIPLEINSTANCES\" opens up a new instance of S+4 in a
|
||||
GUI window and connects it to the '(ddeESS [S+4])' window. The
|
||||
alternative nil uses an existing S+4 GUI (if there is one) and
|
||||
connects it to the '(ddeESS [S+4])' window.")
|
||||
|
||||
(defvar S+4-customize-alist
|
||||
(append
|
||||
'((ess-local-customize-alist . 'S+4-customize-alist)
|
||||
(ess-dialect . S+4-dialect-name)
|
||||
(ess-loop-timeout . ess-S-loop-timeout);fixme: dialect spec.
|
||||
(ess-object-name-db-file . "ess-sp4-namedb.el" )
|
||||
(inferior-ess-program . inferior-S+4-program-name)
|
||||
(inferior-ess-help-command . "help(\"%s\")\n")
|
||||
(inferior-ess-help-filetype . "chm")
|
||||
|
||||
(inferior-ess-start-file . nil) ;"~/.ess-S+4")
|
||||
(inferior-ess-start-args . (concat
|
||||
inferior-S+4-multipleinstances " "
|
||||
inferior-S+4-print-command
|
||||
" S_PROJ="
|
||||
(directory-file-name default-directory)))
|
||||
;; (inferior-ess-ddeclient . "ddeclient")
|
||||
;; (inferior-ess-client-name . "S-PLUS")
|
||||
;; (inferior-ess-client-command . "SCommand")
|
||||
(ess-STERM . "ddeESS")
|
||||
)
|
||||
S+common-cust-alist)
|
||||
|
||||
"Variables to customize for S+4")
|
||||
|
||||
(defvar Sqpe+4-customize-alist
|
||||
(append
|
||||
'((ess-local-customize-alist . 'Sqpe+4-customize-alist)
|
||||
(ess-dialect . S+4-dialect-name)
|
||||
(ess-loop-timeout . 500000 );fixme: dialect specific custom.v
|
||||
(ess-object-name-db-file . "ess-sp4-namedb.el" )
|
||||
(inferior-ess-program . inferior-Sqpe+4-program-name)
|
||||
(inferior-ess-help-command . "help(\"%s\")\n")
|
||||
(inferior-ess-help-filetype . "chm")
|
||||
(inferior-ess-search-list-command . "searchPaths()\n")
|
||||
(inferior-ess-start-file . nil) ;"~/.ess-S+4")
|
||||
(inferior-ess-language-start . (concat
|
||||
"options("
|
||||
"STERM='" ess-STERM "'"
|
||||
(if ess-editor
|
||||
(concat ", editor='" ess-editor "'"))
|
||||
(if ess-pager
|
||||
(concat ", pager='" ess-pager "'"))
|
||||
")"))
|
||||
(ess-STERM . "iESS")
|
||||
)
|
||||
S+common-cust-alist)
|
||||
|
||||
"Variables to customize for Sqpe+4.")
|
||||
|
||||
|
||||
;;; There are extra complications in S+4 (compared to S+3) because
|
||||
;;;
|
||||
;;; (1) The StatSci supplied Splus.exe doesn't work in an emacs
|
||||
;;; buffer. It works as as a GUI window and we must send commands
|
||||
;;; to it through ddeclient. Nonetheless, we need to give it a
|
||||
;;; process name and be sure that that there is a valid running
|
||||
;;; process in the '(ddeESS [S+4])' buffer. Therefore we create an
|
||||
;;; ESS process in the buffer as a placeholder and start a shell
|
||||
;;; in the ESS buffer. From the shell we start Splus. Once Splus
|
||||
;;; finishes initializing and kills the original shell, we start
|
||||
;;; another shell. We have a buffer-local variable
|
||||
;;; inferior-ess-ddeclient, initialized to nil. When there is a
|
||||
;;; non-nil value of inferior-ess-ddeclient we send lines to
|
||||
;;; inferior-ess-ddeclient rather than to the Splus process.
|
||||
;;; (2) There is no Splus process running in the '(ddeESS [S+4])'
|
||||
;;; buffer. Therefore inferior-ess will never see a prompt,
|
||||
;;; unless we first change it to the null prompt "^". Then once
|
||||
;;; the process has started, we change it back.
|
||||
;;; (3) When M-x S+4 starts Splus by a shell command, then Splus is an
|
||||
;;; independent process and will be survive if the '(ddeESS [S+4])'
|
||||
;;; buffer is killed (or emacs is quit). The '(ddeESS [S+4])' is
|
||||
;;; made read-only and a warning is placed in it saying that "You
|
||||
;;; can't type anything here." Actually, if the standalone Splus
|
||||
;;; is killed and the '(ddeESS [S+4])' is made writable (C-x C-q),
|
||||
;;; then '(ddeESS [S+4])' becomes a shell buffer.
|
||||
;;;
|
||||
(defun S+4 (&optional proc-name)
|
||||
"Call 'S-PLUS 4.x', the 'GUI Thing' from StatSci. Put S-Plus in an
|
||||
independent MS-Window (Splus persists even if the '(ddeESS [S+4])'
|
||||
window is killed in emacs). Do this by creating a comint process that
|
||||
calls sh. Send a shell command in that sh buffer to call Splus. When
|
||||
it completes set up a shell as a placeholder in the '(ddeESS [S+4])'
|
||||
buffer. The S-Plus options are correctly set. In particular, the
|
||||
S-Plus Commands window is opened if the Options/General
|
||||
Settings/Startup menu says it should be. There is a 30 second delay
|
||||
during startup in which the screen will not be refreshed. This delay
|
||||
is here to allow slow disks to start the Splus program."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(setq ess-customize-alist S+4-customize-alist)
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "\n(S+4): ess-dialect=%s, buf=%s\n" ess-dialect
|
||||
(current-buffer)))
|
||||
(setq ess-customize-alist ; change inferior-ess-program
|
||||
(append ess-customize-alist '((inferior-ess-program . "sh"))))
|
||||
(setq ess-customize-alist ; change inferior-ess-primary-prompt
|
||||
(append ess-customize-alist '((inferior-ess-primary-prompt . "^"))))
|
||||
(setq ess-customize-alist ; change inferior-ess-start-args
|
||||
(append ess-customize-alist '((inferior-ess-start-args . "-i"))))
|
||||
(let ((s-proj (getenv "S_PROJ"))
|
||||
(manpath (getenv "MANPATH")))
|
||||
(cd (w32-short-file-name (directory-file-name default-directory)))
|
||||
(setenv "S_PROJ" default-directory)
|
||||
;; I don't know why this PATH/MANPATH game is needed,
|
||||
;; except that it doesn't work without it.
|
||||
(setenv "MANPATH" (getenv "PATH"))
|
||||
(inferior-ess)
|
||||
(sleep-for 2) ; need to wait, else working too fast! The Splus
|
||||
; command in '(ddeESS [S+4])' should follow the "$"
|
||||
; prompt. If not, then increase the sleep-for time!
|
||||
(setenv "MANPATH" manpath)
|
||||
(setenv "S_PROJ" s-proj))
|
||||
(setq ess-customize-alist S+4-customize-alist)
|
||||
(ess-setq-vars-local ess-customize-alist)
|
||||
;;; the next three lines belong in customize-alist, but can't be there
|
||||
;;; because of the broken ess-setq-vars-default usage in ess-inf.el
|
||||
(setq inferior-ess-ddeclient "ddeclient")
|
||||
(setq inferior-ess-client-name "S-PLUS")
|
||||
(setq inferior-ess-client-command "SCommand")
|
||||
;;; end of what belongs in customize-alist
|
||||
(setq comint-process-echoes nil)
|
||||
(setq comint-input-sender 'comint-simple-send)
|
||||
(goto-char (point-max))
|
||||
(insert (concat inferior-S+4-program-name " "
|
||||
inferior-ess-start-args)) ; Note: there is no final "&".
|
||||
;; Without the "&", the results of !system.command come to '(ddeESS [S+4])'
|
||||
;; With the "&", the results of !system.command in S get lost.
|
||||
(inferior-ess-send-input)
|
||||
(sleep-for 30) ; Need to wait, else working too fast!
|
||||
; If the ess-current-process-name doesn't appear in the
|
||||
; Splus Commands window increase the sleep-for time!
|
||||
(setq ess-local-process-name ess-current-process-name)
|
||||
(ess-eval-linewise (concat "#" ess-current-process-name))
|
||||
(goto-char (point-min))
|
||||
(insert
|
||||
"This is a placeholder buffer. You can't type anything here.
|
||||
Use `C-x b RET' to return to your file.\n
|
||||
Anything sent to this process from an S-mode buffer goes
|
||||
directly to the associated Splus Commands window.\n
|
||||
The S-Plus Commands window must be visible.
|
||||
You may need to open the S-Plus Commands window manually (by clicking on
|
||||
Splus/Window/Commands Window).\n
|
||||
Any results of the !system.command typed at the S prompt in the
|
||||
Splus Commands window appear in this buffer.\n\n")
|
||||
(goto-char (point-max)) ; comint-mode-map makes '(ddeESS [S+4])'
|
||||
;; (use-local-map comint-mode-map) ;a shell buffer after Splus is finished.
|
||||
(set-buffer-process-coding-system 'raw-text-dos 'raw-text-unix)
|
||||
(setq buffer-read-only t) ; force buffer to be read-only
|
||||
(setq mode-name "ddeESS")
|
||||
;; (ess-eval-linewise inferior-S+4-editor-pager-command)
|
||||
(if inferior-ess-language-start
|
||||
(ess-eval-linewise inferior-ess-language-start))
|
||||
))
|
||||
|
||||
|
||||
|
||||
|
||||
(defun S+4-existing (&optional proc-name)
|
||||
"Call 'S-PLUS 4.x', the 'GUI Thing' from StatSci. Do so by finding
|
||||
an existing S-Plus in an independent MS-Window (if there is one) and
|
||||
set up a '(ddeESS [S+4])' buffer in emacs. If there is no existing
|
||||
S-Plus, then a new one will be opened in the default directory,
|
||||
usually something like c:/Program Files/spls45se/users/yourname.
|
||||
If you have a HOME environment variable, it will open it there."
|
||||
(interactive)
|
||||
(let* ((inferior-S+4-multipleinstances " & # ")) ; Note: there is a final "&".
|
||||
;; Without the "&", there is a core dump.
|
||||
;; With the "&", the results of !system.command in S get lost.
|
||||
;; We are picking up an existing S-Plus process for sending to.
|
||||
;; It doesn't know about us, so nothing comes back.
|
||||
(S+4 proc-name))
|
||||
(with-current-buffer (car (buffer-list)) ; get the ESS buffer just created
|
||||
(setq buffer-read-only nil) ; permit writing in ESS buffer
|
||||
(goto-char (point-max))
|
||||
(beginning-of-line)
|
||||
(forward-line -1)
|
||||
(insert
|
||||
"This is S+4-existing.
|
||||
Results of the !system.command typed at the S prompt in the
|
||||
Splus Commands window blink a DOS window and you won't see them.\n\n")
|
||||
(setq buffer-read-only t) ; restore ESS buffer to be read-only
|
||||
))
|
||||
|
||||
|
||||
;;; There are extra complications in Sqpe+4 (compared to S+3) because
|
||||
;;; (1) The StatSci supplied Sqpe.exe won't work without SHOME as an
|
||||
;;; environment variable and Sqpe does not take command line
|
||||
;;; arguments and
|
||||
;;; (2) Sqpe.exe comes up with options(interactive=F), which means it
|
||||
;;; doesn't provide prompts by default, and we must change it to T so
|
||||
;;; it will provide prompts.
|
||||
;;;
|
||||
(defun Sqpe+4 (&optional proc-name)
|
||||
"Call 'Sqpe' from 'S-PLUS 4.x', the 'Real Thing' from StatSci."
|
||||
(interactive)
|
||||
(setq ess-customize-alist Sqpe+4-customize-alist)
|
||||
(let* ((shome-nil-p (equal (getenv "SHOME") nil)))
|
||||
(if shome-nil-p (setenv "SHOME" inferior-Sqpe+4-SHOME-name))
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "\n(Sqpe+4): ess-dialect=%s, buf=%s\n" ess-dialect
|
||||
(current-buffer)))
|
||||
(setq ess-customize-alist ; change inferior-ess-primary-prompt
|
||||
(append ess-customize-alist '((inferior-ess-primary-prompt . "^"))))
|
||||
(inferior-ess)
|
||||
(setq ess-customize-alist Sqpe+4-customize-alist) ; restore i-e-p-p in alist
|
||||
(ess-setq-vars-local ess-customize-alist) ; restore i-e-p-p in buffer
|
||||
(setq inferior-ess-prompt ; define with correct i-e-p-p
|
||||
;; Do not anchor to bol with `^' ; (copied from ess-inf.el)
|
||||
(concat "\\("
|
||||
inferior-ess-primary-prompt
|
||||
"\\|"
|
||||
inferior-ess-secondary-prompt
|
||||
"\\)"))
|
||||
(setq comint-prompt-regexp (concat "^" inferior-ess-prompt))
|
||||
; define with correct i-e-p-p
|
||||
(setq comint-input-sender 'inferior-ess-input-sender)
|
||||
(add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m nil t)
|
||||
(goto-char (point-max))
|
||||
(insert "options(interactive=T)")
|
||||
(inferior-ess-send-input)
|
||||
(setq mode-name "iESS(Sqpe)")
|
||||
;; (ess-eval-linewise inferior-S+4-editor-pager-command)
|
||||
(if inferior-ess-language-start
|
||||
(ess-eval-linewise inferior-ess-language-start))
|
||||
(if shome-nil-p (setenv "SHOME" nil))))
|
||||
|
||||
|
||||
|
||||
(defun S+4-mode (&optional proc-name)
|
||||
"Major mode for editing S+4 source. See `ess-mode' for more help."
|
||||
(interactive)
|
||||
(setq ess-customize-alist S+4-customize-alist)
|
||||
(ess-mode S+4-customize-alist proc-name)
|
||||
(if ess-imenu-use-S (ess-imenu-S)))
|
||||
|
||||
(defun S+4-transcript-mode ()
|
||||
"S-PLUS 4.x transcript mode."
|
||||
(interactive)
|
||||
(ess-transcript-mode S+4-customize-alist))
|
||||
|
||||
|
||||
(defun S+4-msdos (&optional proc-name)
|
||||
"Call 'S-PLUS 4.x', the 'GUI Thing' from StatSci. Put S-Plus in an
|
||||
independent MS-Window (Splus persists even if the '(ddeESS [S+4])'
|
||||
window is killed in emacs). Do this by creating a comint process that
|
||||
calls sh. Send a shell command in that sh buffer to call Splus. When
|
||||
it completes set up a shell as a placeholder in the '(ddeESS [S+4])'
|
||||
buffer. The S-Plus options are correctly set. In particular, the
|
||||
S-Plus Commands window is opened if the Options/General
|
||||
Settings/Startup menu says it should be. There is a 30 second delay
|
||||
during startup in which the screen will not be refreshed. This delay
|
||||
is here to allow slow disks to start the Splus program."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(setq ess-customize-alist S+4-customize-alist)
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "\n(S+4): ess-dialect=%s, buf=%s\n" ess-dialect
|
||||
(current-buffer)))
|
||||
(setq ess-customize-alist ; change inferior-ess-program
|
||||
(append ess-customize-alist '((inferior-ess-program
|
||||
. (getenv "COMSPEC")))))
|
||||
(setq ess-customize-alist ; change inferior-ess-primary-prompt
|
||||
(append ess-customize-alist '((inferior-ess-primary-prompt . "^"))))
|
||||
(setq ess-customize-alist ; change inferior-ess-start-args
|
||||
(append ess-customize-alist '((inferior-ess-start-args . ""))))
|
||||
(let ((s-proj (getenv "S_PROJ")))
|
||||
(cd (w32-short-file-name (directory-file-name default-directory)))
|
||||
(setenv "S_PROJ" default-directory)
|
||||
(inferior-ess)
|
||||
(sleep-for 2) ; need to wait, else working too fast! The Splus
|
||||
; command in '(ddeESS [S+4])' should follow the "$"
|
||||
; prompt. If not, then increase the sleep-for time!
|
||||
(setenv "S_PROJ" s-proj))
|
||||
(setq ess-customize-alist S+4-customize-alist)
|
||||
(ess-setq-vars-local ess-customize-alist)
|
||||
;;; the next three lines belong in customize-alist, but can't be there
|
||||
;;; because of the broken ess-setq-vars-default usage in ess-inf.el
|
||||
(setq inferior-ess-ddeclient "ddeclient")
|
||||
(setq inferior-ess-client-name "S-PLUS")
|
||||
(setq inferior-ess-client-command "SCommand")
|
||||
;;; end of what belongs in customize-alist
|
||||
(setq comint-input-sender 'comint-simple-send)
|
||||
(setq comint-process-echoes nil)
|
||||
(set-buffer-process-coding-system 'raw-text-dos 'raw-text-dos)
|
||||
(goto-char (point-max))
|
||||
(insert (concat inferior-S+4-program-name " "
|
||||
inferior-ess-start-args)) ; Note: there is no final "&".
|
||||
; Without the "&", the results of !system.command come to '(ddeESS [S+4])'
|
||||
; With the "&", the results of !system.command in S get lost.
|
||||
(inferior-ess-send-input)
|
||||
(sleep-for 30) ; Need to wait, else working too fast!
|
||||
; If the ess-current-process-name doesn't appear in the
|
||||
; Splus Commands window increase the sleep-for time!
|
||||
;;; from msdos-minor-mode
|
||||
(setq comint-process-echoes t)
|
||||
(add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m nil t)
|
||||
;;; end from msdos-minor-mode
|
||||
(setq ess-local-process-name ess-current-process-name)
|
||||
(ess-eval-linewise (concat "#" ess-current-process-name))
|
||||
(goto-char (point-min))
|
||||
(insert
|
||||
"This is a placeholder buffer. You can't type anything here.
|
||||
Use 'C-x b RET' to return to your file.\n
|
||||
Anything sent to this process from an S-mode buffer goes
|
||||
directly to the associated Splus Commands window.\n
|
||||
The S-Plus Commands window must be visible.
|
||||
You may need to open the S-Plus Commands window manually
|
||||
(by clicking on Splus/Window/Commands Window).\n There is a 30
|
||||
second delay when this program starts during which the emacs
|
||||
screen will be partially blank.\n Remember to `q()' from S-Plus
|
||||
and then C-x C-q exit from the `'(ddeESS [S+4])'' buffer, or take
|
||||
the risk of not being able to shut down your computer and
|
||||
suffering through scandisk.\n Any results of the !system.command
|
||||
typed at the S prompt in the Splus Commands window (are supposed
|
||||
to) appear in this buffer.\n\n")
|
||||
(goto-char (point-max)) ; comint-mode-map makes '(ddeESS [S+4])'
|
||||
(use-local-map comint-mode-map) ; a shell buffer after Splus is finished.
|
||||
(setq buffer-read-only t) ; force buffer to be read-only
|
||||
(setq mode-name "ddeESS")
|
||||
;; (ess-eval-linewise inferior-S+4-editor-pager-command)
|
||||
(if inferior-ess-language-start
|
||||
(ess-eval-linewise inferior-ess-language-start))
|
||||
))
|
||||
|
||||
(defun S+4-msdos-existing (&optional proc-name)
|
||||
"Call 'S-PLUS 4.x', the 'GUI Thing' from StatSci. Do so by finding
|
||||
an existing S-Plus in an independent MS-Window (if there is one) and
|
||||
set up a '(ddeESS [S+4])' buffer in emacs. If there is no existing
|
||||
S-Plus, then a new one will be opened in the default directory,
|
||||
usually something like c:/Program Files/spls45se/users/yourname.
|
||||
If you have a HOME environment variable, it will open it there."
|
||||
(interactive)
|
||||
(let* ((inferior-S+4-multipleinstances ""))
|
||||
(S+4-msdos proc-name))
|
||||
(save-excursion
|
||||
(set-buffer (car (buffer-list))) ; get the ESS buffer just created
|
||||
(setq buffer-read-only nil) ; permit writing in ESS buffer
|
||||
(goto-char (point-max))
|
||||
(beginning-of-line)
|
||||
(forward-line -1)
|
||||
(insert
|
||||
"This is S+4-msdos-existing.
|
||||
Results of the !system.command typed at the S prompt in the
|
||||
Splus Commands window blink a DOS window and you won't see them.\n\n")
|
||||
(setq buffer-read-only t) ; restore ESS buffer to be read-only
|
||||
))
|
||||
|
||||
; Provide package
|
||||
|
||||
(provide 'ess-sp4-d)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; outline-minor-mode: nil
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-sp4-d.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp4-d.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp4-d.elc
Normal file
Binary file not shown.
126
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp5-d.el
Normal file
126
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp5-d.el
Normal file
@@ -0,0 +1,126 @@
|
||||
;;; ess-sp5-d.el --- S-plus 5 customization
|
||||
|
||||
;; Copyright (C) 1998 A.J. Rossini
|
||||
;; Copyright (C) 1999--2004 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: A.J. Rossini <rossini@biostat.washington.edu>
|
||||
;; Created: 9 Nov 1998
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; Keywords: languages
|
||||
|
||||
;; This file is part of ESS.
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; AJR copied S4 to be S+5.
|
||||
;; DB contributed the changes from ess-sp3-d.el to
|
||||
;; ess-s4-d.el. (removed the old ugly approach).
|
||||
;; This file defines Sp5 customizations for ess-mode. Lots of thanks
|
||||
;; to RMH and JMC for code and suggestions
|
||||
;; Thanks to MM for making this sensible.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(autoload 'inferior-ess "ess-inf" "Run an ESS process.")
|
||||
(autoload 'ess-mode "ess-mode" "Edit an ESS process.")
|
||||
|
||||
(require 'ess-s-l)
|
||||
|
||||
;; You now need to make sure you've defined if you are running 5.0 or 5.1.
|
||||
;; Lots of things are broken between them, GRR...
|
||||
|
||||
(defvar S+5-dialect-name "S+5"
|
||||
"Name of 'dialect' for S-PLUS 5.");easily changeable in a user's .emacs
|
||||
|
||||
(defvar S+5-customize-alist
|
||||
(append
|
||||
'((ess-local-customize-alist . 'S+5-customize-alist)
|
||||
(ess-dialect . S+5-dialect-name)
|
||||
(ess-loop-timeout . ess-S-loop-timeout);fixme: dialect spec.
|
||||
(ess-object-name-db-file . "ess-sp5-namedb.el")
|
||||
(inferior-ess-program . inferior-S+5-program-name)
|
||||
;;(inferior-ess-objects-pattern . ".*") ; for new s4 stuff
|
||||
(inferior-ess-help-command . "help(\"%s\", pager=\"slynx -dump\", window=FALSE)\n")
|
||||
(inferior-ess-help-filetype . nil)
|
||||
(inferior-ess-search-list-command . "searchPaths()\n")
|
||||
(inferior-ess-start-args . inferior-S+-start-args)
|
||||
(ess-STERM . "iESS")
|
||||
)
|
||||
S+common-cust-alist)
|
||||
|
||||
"Variables to customize for S+5.")
|
||||
|
||||
|
||||
;; For loading up the S code required for the above.
|
||||
;;(add-hook 'ess-post-run-hook
|
||||
;; (lambda ()
|
||||
;; (ess-command
|
||||
;; (concat
|
||||
;; "if(exists(\"Sversion\")) library(emacs) else source(\""
|
||||
;; ess-mode-run-file
|
||||
;; "\")\n"))
|
||||
;; (if ess-mode-run-file2
|
||||
;; (ess-command
|
||||
;; (concat "source(\"" ess-mode-run-file2 "\")\n")))))
|
||||
|
||||
|
||||
(defun S+5 (&optional proc-name)
|
||||
"Call 'Splus5', based on S version 4, from Bell Labs.
|
||||
New way to do it."
|
||||
(interactive)
|
||||
(setq ess-customize-alist S+5-customize-alist)
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "\n(S+5): ess-dialect=%s, buf=%s\n" ess-dialect (current-buffer)))
|
||||
(inferior-ess)
|
||||
(if inferior-ess-language-start
|
||||
(ess-eval-linewise inferior-ess-language-start)))
|
||||
|
||||
(defun S+5-mode (&optional proc-name)
|
||||
"Major mode for editing S+5 source. See `ess-mode' for more help."
|
||||
(interactive)
|
||||
(setq ess-customize-alist S+5-customize-alist)
|
||||
(ess-mode S+5-customize-alist proc-name)
|
||||
(if ess-imenu-use-S (ess-imenu-S)))
|
||||
|
||||
(defun S+5-transcript-mode ()
|
||||
"S-PLUS 5 transcript mode."
|
||||
(interactive)
|
||||
(ess-transcript-mode S+5-customize-alist))
|
||||
|
||||
; Provide package
|
||||
|
||||
(provide 'ess-sp5-d)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; outline-minor-mode: nil
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-sp5-d.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp5-d.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp5-d.elc
Normal file
Binary file not shown.
314
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp6-d.el
Normal file
314
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp6-d.el
Normal file
@@ -0,0 +1,314 @@
|
||||
;;; ess-sp6-d.el --- S-Plus 6 & 7 & 8 customization
|
||||
|
||||
;; Copyright (C) 2001--2005 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: A.J. Rossini <rossini@u.washington.edu>
|
||||
;; Created: 2001/02/06
|
||||
;; Maintainer: ESS Core Team <ESS-core@r-project.org>
|
||||
|
||||
;; Keywords: languages
|
||||
|
||||
;; This file is part of ESS.
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; AJR copied S+5 to be S+6.
|
||||
;; AJR copied S4 to be S+5.
|
||||
;; DB contributed the changes from ess-sp3-d.el to
|
||||
;; ess-s4-d.el. (removed the old ugly approach).
|
||||
;; This file defines Sp5 customizations for ess-mode. Lots of thanks
|
||||
;; to RMH and JMC for code and suggestions
|
||||
;; Thanks to MM for making this sensible.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(autoload 'inferior-ess "ess-inf" "Run an ESS process.")
|
||||
(autoload 'ess-mode "ess-mode" "Edit an ESS process.")
|
||||
|
||||
(require 'ess-s-l)
|
||||
|
||||
;; You now need to make sure you've defined if you are running 5.0 or 5.1.
|
||||
;; Lots of things are broken between them, GRR...
|
||||
|
||||
(defun S+-directory-p (directory)
|
||||
"Splus 5++ directories have a .Data directory and a __Meta directory within."
|
||||
(and directory
|
||||
(file-directory-p (concat directory ".Data"))
|
||||
(file-directory-p (concat directory ".Data/__Meta"))))
|
||||
|
||||
(defvar S+-directory-function
|
||||
(lambda ()
|
||||
(if (S+-directory-p default-directory)
|
||||
default-directory
|
||||
(or ess-directory default-directory))))
|
||||
|
||||
(defvaralias 'S+6-setup-directory-function 'S+-setup-directory-function)
|
||||
(defvar S+-setup-directory-function
|
||||
(lambda (startdir)
|
||||
(when (and startdir (S+-directory-p startdir))
|
||||
(setenv "S_WORK"
|
||||
(if (getenv "S_WORK")
|
||||
(concat startdir ":" (getenv "S_WORK"))
|
||||
;;(message "adding %s to S_WORK" startdir)
|
||||
startdir)))))
|
||||
|
||||
|
||||
|
||||
(defvaralias 'S+6-customize-alist 'S+-customize-alist)
|
||||
(defvar S+-customize-alist
|
||||
(append
|
||||
'((ess-local-customize-alist . 'S+-customize-alist)
|
||||
(ess-dialect . S+-dialect-name)
|
||||
(ess-loop-timeout . ess-S-loop-timeout);fixme: dialect spec.
|
||||
(ess-function-pattern . ess-R-function-pattern)
|
||||
|
||||
(ess-object-name-db-file . "ess-sp6-namedb.el")
|
||||
(inferior-ess-program . inferior-S+-program-name)
|
||||
(inferior-ess-help-command . "help(\"%s\", pager=\"slynx -dump\", window=FALSE)\n")
|
||||
(inferior-ess-help-filetype . nil)
|
||||
(inferior-ess-search-list-command . "searchPaths()\n")
|
||||
|
||||
(ess-directory-function . S+-directory-function)
|
||||
(ess-setup-directory-function . S+-setup-directory-function)
|
||||
(inferior-ess-start-args . inferior-S+-start-args)
|
||||
(ess-STERM . "iESS")
|
||||
)
|
||||
S+common-cust-alist)
|
||||
|
||||
"Variables to customize for S+.")
|
||||
|
||||
(defvar ess-S+-post-run-hook nil
|
||||
"Functions run in process buffer after the initialization of S+
|
||||
process.")
|
||||
|
||||
(defalias 'S+6 'S+)
|
||||
(defun S+ (&optional proc-name)
|
||||
"Call 'Splus6', based on S version 4, from Bell Labs.
|
||||
New way to do it."
|
||||
(interactive)
|
||||
(setq ess-customize-alist S+-customize-alist)
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "\n(S+): ess-dialect=%s, buf=%s\n" ess-dialect (current-buffer)))
|
||||
(inferior-ess)
|
||||
(ess-command ess-S+--injected-code)
|
||||
(if inferior-ess-language-start
|
||||
(ess-eval-linewise inferior-ess-language-start))
|
||||
(with-ess-process-buffer nil
|
||||
(run-mode-hooks 'ess-S+-post-run-hook)))
|
||||
|
||||
(defvar ess-S+--injected-code
|
||||
".ess_funargs <- function(funname){
|
||||
## funname <- deparse(substitute(object))
|
||||
fun <- try(eval(parse(text=funname)), silent = TRUE)
|
||||
if(is.function(fun)) {
|
||||
special <- grepl('[:$@[]', funname)
|
||||
args <- args(fun)
|
||||
fmls <- formals(args)
|
||||
fmls.names <- names(fmls)
|
||||
fmls <- gsub('\\\"', '\\\\\\\"', as.character(fmls), fixed = TRUE)
|
||||
args.alist <- sprintf(\"'(%s)\", paste(\"(\\\"\", fmls.names, \"\\\" . \\\"\", fmls, \"\\\")\", sep = '', collapse = ' '))
|
||||
## envname <- environmentName(environment(fun))
|
||||
envname <- if (special) '' else 'S+'
|
||||
cat(sprintf('(list \\\"%s\\\" %s )\\n', envname, args.alist))
|
||||
}
|
||||
}
|
||||
")
|
||||
|
||||
|
||||
(defalias 'S+6-mode 'S+-mode)
|
||||
(defun S+-mode (&optional proc-name)
|
||||
"Major mode for editing S+ source. See `ess-mode' for more help."
|
||||
(interactive)
|
||||
(setq ess-customize-alist S+-customize-alist)
|
||||
(ess-mode S+-customize-alist proc-name)
|
||||
(if (fboundp 'ess-add-toolbar) (ess-add-toolbar))
|
||||
(if ess-imenu-use-S (ess-imenu-S)))
|
||||
|
||||
(defalias 'S+6-transcript-mode 'S+-transcript-mode)
|
||||
(defun S+-transcript-mode ()
|
||||
"S-PLUS 6 transcript mode."
|
||||
(interactive)
|
||||
(ess-transcript-mode S+-customize-alist))
|
||||
|
||||
(defvar ess-s-versions-list nil
|
||||
"List of other versions of S to add to ESS.
|
||||
Each element of this list is itself a list:
|
||||
\(FUNCTION PATH ARGS\)
|
||||
e.g.
|
||||
\(\"mysplus\" \"/usr/splus7/bin/splus7\" \"-j\"\)
|
||||
FUNCTION is the name of the function to be created by Emacs.
|
||||
PATH is the full path to the variant of S that you want to run.
|
||||
ARGS (optional) are start-up arguments that you want to pass to S.
|
||||
")
|
||||
|
||||
(defvar ess-s-versions '("Splus")
|
||||
"List of partial strings for versions of S to access within ESS.
|
||||
Each string specifies the start of a filename. If a filename
|
||||
beginning with one of these strings is found on `exec-path', a M-x
|
||||
command for that version of S is made available. For example, if the
|
||||
file \"Splus7\" is found and this variable includes the string
|
||||
\"Splus\", a function called `M-x Splus7' will be available to run that
|
||||
version of S.
|
||||
If duplicate versions of the same program are found (which happens if
|
||||
the same path is listed on `exec-path' more than once), they are
|
||||
ignored by calling `ess-uniq-list'.
|
||||
Set this variable to nil to disable searching for other versions
|
||||
of S using this method.
|
||||
If you set this variable, you need to restart Emacs (and set this variable
|
||||
before ess-site is loaded) for it to take effect.
|
||||
|
||||
See also `ess-s-versions-list' for another way to add other S
|
||||
processes to ESS. ")
|
||||
|
||||
(defun ess-s-versions-create ()
|
||||
"Generate defuns for starting other versions of S.
|
||||
See `ess-s-versions' for strings that determine which functions are created.
|
||||
It assumes these versions of S can be run as a substitute for Splus6.
|
||||
|
||||
This function returns the list of S defuns, if any, that were
|
||||
created. The defuns will normally be placed on the menubar upon
|
||||
ESS initialisation."
|
||||
|
||||
;; This works by creating a temp buffer where the template function is
|
||||
;; edited so that X.Y is replaced by the version name
|
||||
(let ((template "")
|
||||
(template-args)
|
||||
(beg)
|
||||
(versions)
|
||||
(version)
|
||||
(eval-buf (get-buffer-create "*ess-temp-s-evals*"))
|
||||
(ess-s-versions-created)
|
||||
|
||||
(ess-s-versions-list ess-s-versions-list)
|
||||
;; make local copy so it won't be destroyed globally
|
||||
)
|
||||
;;
|
||||
;; This is the template function used for creating M-x Splus
|
||||
(setq template "(defun S-X.Y ()
|
||||
\"Call S-X.Y, i.e., the S version 'S-X.Y' using ESS.
|
||||
This function was generated by `ess-s-versions-create'.\"
|
||||
(interactive \"\")
|
||||
(let ((inferior-S+-program-name \"S-X.Y\"))
|
||||
(S+)))
|
||||
|
||||
")
|
||||
(with-current-buffer eval-buf
|
||||
;; clear the buffer.
|
||||
(delete-region (point-min) (point-max))
|
||||
|
||||
(when ess-s-versions
|
||||
;; Find which versions of S we want. Remove the pathname, leaving just
|
||||
;; the name of the executable.
|
||||
(setq versions
|
||||
(ess-uniq-list
|
||||
(mapcar 'file-name-nondirectory
|
||||
(apply 'nconc
|
||||
(mapcar 'ess-find-exec-completions
|
||||
ess-s-versions)))))
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "(S): ess-s-versions-create making M-x defuns for \n %s\n"
|
||||
(mapconcat 'identity versions "\n ")))
|
||||
(setq ess-s-versions-created versions) ;keep copy for returning at end.
|
||||
;; Iterate over each string in VERSIONS, creating a new defun each time.
|
||||
(while versions
|
||||
(setq version (car versions)
|
||||
versions (cdr versions))
|
||||
(setq beg (point))
|
||||
(insert template)
|
||||
(goto-char beg)
|
||||
(while (search-forward "S-X.Y" nil t)
|
||||
(replace-match version t t))
|
||||
(goto-char (point-max))
|
||||
))
|
||||
|
||||
;; Check if we have any static defuns to evaluate.
|
||||
(when ess-s-versions-list
|
||||
|
||||
;; Need a slightly different template for static defuns.
|
||||
(setq template "(defun S-X.Y ()
|
||||
\"Call S-X.Y, i.e., the S version 'S-X.Y' using ESS.
|
||||
This function will run S-FULL-PATH
|
||||
This function was generated by `ess-s-versions-create'.\"
|
||||
(interactive \"\")
|
||||
(let ((inferior-S+-program-name \"S-FULL-PATH\"))
|
||||
(S+)))
|
||||
|
||||
")
|
||||
;; need another version of template, with args.
|
||||
(setq template-args "(defun S-X.Y ()
|
||||
\"Call S-X.Y, i.e., the S version 'S-X.Y' using ESS.
|
||||
This function will run S-FULL-PATH
|
||||
This function was generated by `ess-s-versions-create'.\"
|
||||
(interactive \"\")
|
||||
(let ((inferior-S+-program-name \"S-FULL-PATH\")
|
||||
(inferior-S+-start-args \"S-MYARGS\"))
|
||||
(S+)))
|
||||
|
||||
")
|
||||
(while ess-s-versions-list
|
||||
(let* ((this-S-version (car ess-s-versions-list))
|
||||
(S-defun (nth 0 this-S-version))
|
||||
(S-path (nth 1 this-S-version))
|
||||
(S-args (nth 2 this-S-version)))
|
||||
(setq ess-s-versions-list (cdr ess-s-versions-list))
|
||||
;; Could do error checking here, that S-defun is not defined
|
||||
;; before, and that S-path is valid.
|
||||
(setq beg (point))
|
||||
(insert
|
||||
(if S-args
|
||||
template-args
|
||||
template))
|
||||
(goto-char beg)
|
||||
(while (search-forward "S-X.Y" nil t)
|
||||
(replace-match S-defun t t))
|
||||
(goto-char beg)
|
||||
(while (search-forward "S-FULL-PATH" nil t)
|
||||
(replace-match S-path t t))
|
||||
(when S-args
|
||||
(goto-char beg)
|
||||
(while (search-forward "S-MYARGS" nil t)
|
||||
(replace-match S-args t t)))
|
||||
(goto-char (point-max))
|
||||
(add-to-list 'ess-s-versions-created S-defun 'append))))
|
||||
|
||||
;; buffer has now been created with defuns, so eval them!
|
||||
(eval-buffer)
|
||||
(kill-buffer eval-buf); < comment this for debugging
|
||||
ess-s-versions-created)))
|
||||
|
||||
; Provide package
|
||||
|
||||
(provide 'ess-sp6-d)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; outline-minor-mode: nil
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-sp6-d.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp6-d.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp6-d.elc
Normal file
Binary file not shown.
602
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp6w-d.el
Normal file
602
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp6w-d.el
Normal file
@@ -0,0 +1,602 @@
|
||||
;;; ess-sp6w-d.el --- S-PLUS 6.x for Windows customization
|
||||
|
||||
;;; copied and edited from ess-s4-d.el - Richard M. Heiberger, April 2001
|
||||
|
||||
;; Copyright (C) 2001 Richard M. Heiberger <rmh@temple.edu>
|
||||
;; Copyright (C) 2002--2005 A.J. Rossini, Richard M. Heiberger, Martin
|
||||
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
|
||||
|
||||
;; Author: Richard M. Heiberger <rmh@temple.edu>
|
||||
;; Created: April 2001
|
||||
;; Maintainer: ESS-core <ESS-core@r-project.org>
|
||||
|
||||
;; Keywords: languages
|
||||
|
||||
;; This file is part of ESS.
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; A copy of the GNU General Public License is available at
|
||||
;; http://www.r-project.org/Licenses/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This file defines all the S-PLUS 6.x for Windows customizations
|
||||
;; for ess-mode with ddeclient.
|
||||
|
||||
;;; Code:
|
||||
|
||||
;;; Requires and Autoloads:
|
||||
|
||||
(require 'ess-s-l)
|
||||
;;NO: this is autoloaded from other places (require 'ess-dde)
|
||||
|
||||
(autoload 'inferior-ess "ess-inf" "Run an ESS process.")
|
||||
(autoload 'ess-mode "ess-mode" "Edit an ESS process.")
|
||||
|
||||
|
||||
(defvaralias 'inferior-S+6-multipleinstances 'inferior-S+-multipleinstances)
|
||||
(defvar inferior-S+-multipleinstances "/MULTIPLEINSTANCES"
|
||||
"Default \"/MULTIPLEINSTANCES\" opens up a new instance of S+[678] in a
|
||||
GUI window and connects it to the '(ddeESS [S+])' window. The
|
||||
alternative nil uses an existing S+ GUI (if there is one) and
|
||||
connects it to the '(ddeESS [S+])' window.")
|
||||
|
||||
(defvaralias 'S+6-customize-alist 'S+-customize-alist)
|
||||
(defvar S+-customize-alist
|
||||
(append
|
||||
'((ess-local-customize-alist . 'S+-customize-alist)
|
||||
(ess-dialect . S+-dialect-name)
|
||||
(ess-loop-timeout . ess-S-loop-timeout);fixme: dialect spec.
|
||||
(ess-object-name-db-file . "ess-sp6-namedb.el" )
|
||||
(inferior-ess-program . inferior-S+-program-name)
|
||||
(inferior-ess-help-command . "help(\"%s\")\n")
|
||||
(inferior-ess-help-filetype . "chm")
|
||||
(inferior-ess-search-list-command . "searchPaths()\n")
|
||||
(inferior-ess-start-file . nil) ;"~/.ess-S+")
|
||||
(inferior-ess-start-args . (concat
|
||||
inferior-S+-multipleinstances
|
||||
" "
|
||||
inferior-S+-start-args
|
||||
" "
|
||||
inferior-S+-print-command
|
||||
" S_PROJ="
|
||||
(w32-short-file-name (directory-file-name default-directory))))
|
||||
;; (inferior-ess-ddeclient . "ddeclient")
|
||||
;; (inferior-ess-client-name . "S-PLUS")
|
||||
;; (inferior-ess-client-command . "SCommand")
|
||||
(ess-STERM . "ddeESS")
|
||||
)
|
||||
S+common-cust-alist)
|
||||
"Variables to customize for S+")
|
||||
|
||||
(defvaralias 'Sqpe+6-customize-alist 'Sqpe+-customize-alist)
|
||||
(defvar Sqpe+-customize-alist
|
||||
(append
|
||||
'((ess-local-customize-alist . 'Sqpe+-customize-alist)
|
||||
(ess-dialect . S+-dialect-name)
|
||||
(ess-loop-timeout . 500000 );fixme: dialect specific custom.var
|
||||
(ess-object-name-db-file . "ess-sp6-namedb.el" )
|
||||
(inferior-ess-program . inferior-Sqpe+-program-name)
|
||||
(inferior-ess-help-command . "help(\"%s\")\n")
|
||||
(inferior-ess-help-filetype . "chm")
|
||||
(inferior-ess-search-list-command . "searchPaths()\n")
|
||||
(inferior-ess-start-file . nil) ;"~/.ess-S+")
|
||||
(inferior-ess-start-args . (concat
|
||||
;; workaround for bug in S-Plus 6 for Windows:
|
||||
"ALWAYS_PROMPT=X"
|
||||
" "
|
||||
inferior-Sqpe+-start-args ;; e.g. license manager
|
||||
))
|
||||
(ess-STERM . "iESS")
|
||||
)
|
||||
S+common-cust-alist)
|
||||
"Variables to customize for Sqpe+.")
|
||||
|
||||
|
||||
|
||||
;;; There are extra complications in S+6 and S+7 and S+8 (compared to S+3)
|
||||
;;; because
|
||||
;;;
|
||||
;;; (1) The StatSci supplied Splus.exe doesn't work in an emacs
|
||||
;;; buffer. It works as as a GUI window and we must send commands
|
||||
;;; to it through ddeclient. Nonetheless, we need to give it a
|
||||
;;; process name and be sure that that there is a valid running
|
||||
;;; process in the '(ddeESS [S+])' buffer. Therefore we create an
|
||||
;;; ESS process in the buffer as a placeholder and start a shell
|
||||
;;; in the ESS buffer. From the shell we start Splus. Once Splus
|
||||
;;; finishes initializing and kills the original shell, we start
|
||||
;;; another shell. We have a buffer-local variable
|
||||
;;; inferior-ess-ddeclient, initialized to nil. When there is a
|
||||
;;; non-nil value of inferior-ess-ddeclient we send lines to
|
||||
;;; inferior-ess-ddeclient rather than to the Splus process.
|
||||
;;; (2) There is no Splus process running in the '(ddeESS [S+])'
|
||||
;;; buffer. Therefore inferior-ess will never see a prompt,
|
||||
;;; unless we first change it to the null prompt "^". Then once
|
||||
;;; the process has started, we change it back.
|
||||
;;; (3) When M-x S+ starts Splus by a shell command, then Splus is an
|
||||
;;; independent process and will be survive if the '(ddeESS [S+])'
|
||||
;;; buffer is killed (or emacs is quit). The '(ddeESS [S+])' is
|
||||
;;; made read-only and a warning is placed in it saying that "You
|
||||
;;; can't type anything here." Actually, if thestandalone Splus
|
||||
;;; is killed and the '(ddeESS [S+])' is made writable (C-x C-q),
|
||||
;;; then '(ddeESS [S+])' becomes a shell buffer.
|
||||
;;;
|
||||
(defalias 'S+6 'S+)
|
||||
(defun S+ (&optional proc-name)
|
||||
"Verify that `inferior-S+-program-name' points to S-Plus 6 or
|
||||
S-Plus 7 or S-Plus 8. Start normally for S-Plus 6.1 and later.
|
||||
Inform the user to start S-Plus 6.0 from the icon and then
|
||||
connect to it with `S+-existing'. Give an error message if
|
||||
`inferior-S+-program-name' doesn't point to S-Plus 6 or S-Plus 7
|
||||
or S-Plus 8."
|
||||
(interactive)
|
||||
(with-current-buffer (find-file-noselect
|
||||
(concat (executable-find inferior-S+-program-name)
|
||||
"/../../versions") t)
|
||||
(setq buffer-read-only 1)
|
||||
(forward-line)
|
||||
(if (not (search-backward-regexp "splus\t[678].[0-9]" (point-min) t))
|
||||
(error "The emacs variable `inferior-S+-program-name' does
|
||||
not point to S-Plus 6 or 7 or 8. Please add `splus[678]?/cmd' (expand the
|
||||
`[678]?' to match your setup) to your `exec-path' or specify the complete
|
||||
path to `Splus.exe' in the variable `inferior-S+-program-name' in your
|
||||
`.emacs' file.")
|
||||
(forward-line)
|
||||
(if (search-backward "splus\t6.0" (point-min) t)
|
||||
(error "S-Plus 6.0 for Microsoft Windows has a bug that
|
||||
prevents it from being started by emacs. Instead, you must start it
|
||||
by double-clicking an icon. Then you can connect to it with
|
||||
`S+-existing'. You should consider upgrading to a newer
|
||||
release of S-Plus."))))
|
||||
(S+-initiate proc-name)) ;; normal start ;
|
||||
|
||||
(defalias 'S+6-initiate 'S+-initiate)
|
||||
(defun S+-initiate (&optional proc-name)
|
||||
"Call 'S-PLUS [678].x for Windows', the 'GUI Thing' from StatSci. Put
|
||||
S-Plus in an independent MS-Window (Splus persists even if the
|
||||
'(ddeESS [S+])' window is killed in emacs). Do this by creating a
|
||||
comint process that calls sh. Send a shell command in that sh buffer
|
||||
to call Splus. When it completes set up a shell as a placeholder in
|
||||
the '(ddeESS [S+])' buffer. The S-Plus options are correctly set.
|
||||
In particular, the S-Plus Commands window is opened if the
|
||||
Options/General Settings/Startup menu says it should be. There is a
|
||||
startup delay of `ess-S+-startup-delay' seconds during which the
|
||||
screen will not be refreshed. This delay is here to allow slow disks
|
||||
to start the Splus program."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(setq ess-customize-alist S+-customize-alist)
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "\n(S+): ess-dialect=%s, buf=%s\n" ess-dialect
|
||||
(current-buffer)))
|
||||
(setq ess-customize-alist ; change inferior-ess-program
|
||||
(append ess-customize-alist '((inferior-ess-program . "sh"))))
|
||||
(setq ess-customize-alist ; change inferior-ess-primary-prompt
|
||||
(append ess-customize-alist '((inferior-ess-primary-prompt . "^"))))
|
||||
(setq ess-customize-alist ; change inferior-ess-start-args
|
||||
(append ess-customize-alist '((inferior-ess-start-args . "-i"))))
|
||||
(let ((s-proj (getenv "S_PROJ"))
|
||||
(use-dialog-box (not (or ess-microsoft-p (eq system-type 'cygwin))))
|
||||
)
|
||||
(cd (w32-short-file-name (directory-file-name default-directory)))
|
||||
(setenv "S_PROJ" (w32-short-file-name default-directory))
|
||||
(inferior-ess)
|
||||
(sleep-for 2) ; need to wait, else working too fast! The Splus
|
||||
; command in '(ddeESS [S+])' should follow the "$"
|
||||
; prompt. If not, then increase the sleep-for time!
|
||||
(setenv "S_PROJ" s-proj))
|
||||
(setq ess-customize-alist S+-customize-alist)
|
||||
(ess-setq-vars-local ess-customize-alist)
|
||||
;;; the next three lines belong in customize-alist, but can't be there
|
||||
;;; because of the broken ess-setq-vars-default usage in ess-inf.el
|
||||
(setq inferior-ess-ddeclient "ddeclient")
|
||||
(setq inferior-ess-client-name "S-PLUS")
|
||||
(setq inferior-ess-client-command "SCommand")
|
||||
;;; end of what belongs in customize-alist
|
||||
(setq comint-process-echoes nil)
|
||||
(setq comint-input-sender 'comint-simple-send)
|
||||
(goto-char (point-max))
|
||||
(insert (concat inferior-S+-program-name " "
|
||||
inferior-ess-start-args)) ; Note: there is no final "&".
|
||||
;; Without the "&", the results of !system.command come to '(ddeESS [S+])'
|
||||
;; With the "&", the results of !system.command in S get lost.
|
||||
(inferior-ess-send-input)
|
||||
(sleep-for ess-S+-startup-delay) ; Need to wait, else working too fast!
|
||||
; If the ess-current-process-name doesn't appear in the
|
||||
; Splus Commands window increase the sleep-for time!
|
||||
(setq ess-local-process-name ess-current-process-name)
|
||||
(ess-eval-linewise (concat "#" ess-current-process-name))
|
||||
(goto-char (point-min))
|
||||
(insert
|
||||
"This is a placeholder buffer. You can't type anything here.
|
||||
Use `C-x b RET' to return to your file.\n
|
||||
Anything sent to this process from an S-mode buffer goes
|
||||
directly to the associated Splus Commands window.\n
|
||||
The S-Plus Commands window must be visible.
|
||||
You may need to open the S-Plus Commands window manually (by clicking on
|
||||
Splus/Window/Commands Window).\n
|
||||
Any results of the !system.command typed at the S prompt in the
|
||||
Splus Commands window appear in this buffer.\n\n")
|
||||
(goto-char (point-max)) ; comint-mode-map makes '(ddeESS [S+])'
|
||||
;; (use-local-map comint-mode-map) ;a shell buffer after Splus is finished.
|
||||
(set-buffer-process-coding-system 'raw-text-dos 'raw-text-unix)
|
||||
(setq buffer-read-only t) ; force buffer to be read-only
|
||||
(setq mode-name "ddeESS")
|
||||
;; (ess-eval-linewise inferior-S+-editor-pager-command)
|
||||
(if inferior-ess-language-start
|
||||
(ess-eval-linewise inferior-ess-language-start))
|
||||
))
|
||||
|
||||
|
||||
(defalias 'S+6-existing 'S+-existing)
|
||||
(defun S+-existing (&optional proc-name)
|
||||
"Call 'S-PLUS [678].x for Windows', the 'GUI Thing' from StatSci. Do so by
|
||||
finding an existing S-Plus in an independent MS-Window (if there is one) and
|
||||
set up a '(ddeESS [S+])' buffer in emacs. If there is no existing
|
||||
S-Plus, then a new one will be opened in the default directory. The default
|
||||
is usually something like 'c:/Program Files/Insightful/splus70/users/yourname'
|
||||
for S-Plus before 8.0.4. Beginning with 8.0.4, S-Plus uses the default directory
|
||||
'c:/Documents and Settings/yourname/My Documents/S-PLUS Projects/Project1'.
|
||||
Beginning with TIBCO Spotfire S+ Version 8.1.1 for Microsft Windows, the default
|
||||
directory is 'c:/DOCUME~1/yourname/MYDOCU~1/SPOTFI~1/Project1'.
|
||||
If you have a HOME environment variable, it will open it there."
|
||||
(interactive)
|
||||
(let* ((inferior-S+-multipleinstances " & # ") ; Note: there is a final "&".
|
||||
(ess-S+-startup-delay 0)) ;; No delay for existing S-Plus
|
||||
;; Without the "&", there is a core dump.
|
||||
;; With the "&", the results of !system.command in S get lost.
|
||||
;; We are picking up an existing S-Plus process for sending to.
|
||||
;; It doesn't know about us, so nothing comes back.
|
||||
(S+-initiate proc-name))
|
||||
(with-current-buffer (car (buffer-list)) ; get the ESS buffer just created
|
||||
(setq buffer-read-only nil) ; permit writing in ESS buffer
|
||||
(goto-char (point-max))
|
||||
(beginning-of-line)
|
||||
(forward-line -1)
|
||||
(insert
|
||||
"This is S+-existing.
|
||||
Results of the !system.command typed at the S prompt in the
|
||||
Splus Commands window blink a DOS window and you won't see them.\n\n")
|
||||
(setq buffer-read-only t) ; restore ESS buffer to be read-only
|
||||
))
|
||||
|
||||
|
||||
;;; There are extra complications in Sqpe+6 (compared to S+3) because
|
||||
;;; (1) The StatSci supplied Sqpe.exe won't work without SHOME as an
|
||||
;;; environment variable and Sqpe does not take command line
|
||||
;;; arguments and
|
||||
;;; (2) Sqpe.exe comes up with options(interactive=FALSE), which means it
|
||||
;;; doesn't provide prompts by default, and we must change it to T so
|
||||
;;; it will provide prompts.
|
||||
;;;
|
||||
(defalias 'Sqpe+6 'Sqpe+)
|
||||
(defun Sqpe+ (&optional proc-name)
|
||||
"Call 'Sqpe' from 'S-PLUS [678].x for Windows', the 'Real Thing' from StatSci."
|
||||
(interactive)
|
||||
(setq ess-customize-alist Sqpe+-customize-alist)
|
||||
(let* ((shome-nil-p (equal (getenv "SHOME") nil))
|
||||
(use-dialog-box (not (or ess-microsoft-p (eq system-type 'cygwin))))
|
||||
)
|
||||
(if shome-nil-p (setenv "SHOME" inferior-Sqpe+-SHOME-name))
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "\n(Sqpe+6): ess-dialect=%s, buf=%s\n" ess-dialect
|
||||
(current-buffer)))
|
||||
(setq ess-customize-alist ; change inferior-ess-primary-prompt
|
||||
(append ess-customize-alist '((inferior-ess-primary-prompt . "^"))))
|
||||
(inferior-ess)
|
||||
(setq ess-customize-alist Sqpe+-customize-alist) ; restore i-e-p-p in alist
|
||||
(ess-setq-vars-local ess-customize-alist) ; restore i-e-p-p in buffer
|
||||
(setq inferior-ess-prompt ; define with correct i-e-p-p
|
||||
;; Do not anchor to bol with `^' ; (copied from ess-inf.el)
|
||||
(concat "\\("
|
||||
inferior-ess-primary-prompt
|
||||
"\\|"
|
||||
inferior-ess-secondary-prompt
|
||||
"\\)"))
|
||||
(setq comint-prompt-regexp (concat "^" inferior-ess-prompt))
|
||||
; define with correct i-e-p-p
|
||||
(setq comint-input-sender 'inferior-ess-input-sender)
|
||||
(add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m nil t)
|
||||
(goto-char (point-max))
|
||||
(insert "options(interactive=TRUE)")
|
||||
(inferior-ess-send-input)
|
||||
(setq mode-name "iESS(Sqpe)")
|
||||
;; (ess-eval-linewise inferior-S+-editor-pager-command)
|
||||
(if inferior-ess-language-start
|
||||
(ess-eval-linewise inferior-ess-language-start))
|
||||
(if shome-nil-p (setenv "SHOME" nil))))
|
||||
|
||||
|
||||
(defalias 'S+6-mode 'S+-mode)
|
||||
(defun S+-mode (&optional proc-name)
|
||||
"Major mode for editing S+[678] source. See `ess-mode' for more help."
|
||||
(interactive)
|
||||
(setq ess-customize-alist S+-customize-alist)
|
||||
(ess-mode S+-customize-alist proc-name)
|
||||
(if ess-imenu-use-S (ess-imenu-S)))
|
||||
|
||||
(defalias 'S+6-transcript-mode 'S+-transcript-mode)
|
||||
(defun S+-transcript-mode ()
|
||||
"S-PLUS transcript mode."
|
||||
(interactive)
|
||||
(ess-transcript-mode S+-customize-alist))
|
||||
|
||||
(defalias 'S+-msdos 'S+-msdos)
|
||||
(defun S+-msdos (&optional proc-name)
|
||||
"Verify that `inferior-S+-program-name' points to S-Plus 6 or
|
||||
S-Plus 7 or S-Plus 8. Start normally for S-Plus 6.1 and later.
|
||||
Inform the user to start S-Plus 6.0 from the icon and then
|
||||
connect to it with `S+-msdos-existing'. Give an error message
|
||||
if `inferior-S+-program-name' doesn't point to S-Plus 6 or
|
||||
S-Plus 7 or S-Plus 8."
|
||||
(interactive)
|
||||
(with-current-buffer (find-file-noselect
|
||||
(concat (executable-find inferior-S+-program-name)
|
||||
"/../../versions") t)
|
||||
(setq buffer-read-only 1)
|
||||
(forward-line)
|
||||
(if (not (search-backward-regexp "splus\t[678].[0-9]" (point-min) t))
|
||||
(error "The emacs variable `inferior-S+-program-name' does
|
||||
not point to S-Plus 6 or 7 or 8. Please add `splus[678]?/cmd'
|
||||
(expand the `[678]?' to match your setup) to your `exec-path' or
|
||||
specify the complete path to `Splus.exe' in the variable
|
||||
`inferior-S+-program-name' in your `.emacs' file.") ;;; " This comment keeps emacs font-lock from getting out of phase.
|
||||
|
||||
(progn
|
||||
(forward-line)
|
||||
(if (search-backward "splus\t6.0" (point-min) t)
|
||||
(error "S-Plus 6.0 for Microsoft Windows has a bug that
|
||||
prevents it from being started by emacs. Instead, you must start it
|
||||
by double-clicking an icon. Then you can connect to it with
|
||||
`S+-msdos-existing'. You should consider upgrading to a newer
|
||||
release of S-Plus.")
|
||||
(S+-msdos-initiate proc-name))) ;; normal start ;
|
||||
)))
|
||||
|
||||
(defalias 'S+6-msdos-initiate 'S+-msdos-initiate)
|
||||
(defun S+-msdos-initiate (&optional proc-name)
|
||||
"Call 'S-PLUS [678].x for Windows', the 'GUI Thing' from StatSci. Put
|
||||
S-Plus in an independent MS-Window (Splus persists even if the
|
||||
'(ddeESS [S+])' window is killed in emacs). Do this by creating a
|
||||
comint process that calls sh. Send a shell command in that sh buffer
|
||||
to call Splus. When it completes set up a shell as a placeholder in
|
||||
the '(ddeESS [S+])' buffer. The S-Plus options are correctly set.
|
||||
In particular, the S-Plus Commands window is opened if the
|
||||
Options/General Settings/Startup menu says it should be. There is a
|
||||
startup delay of `ess-S+-startup-delay' seconds during which the
|
||||
screen will not be refreshed. This delay is here to allow slow disks
|
||||
to start the Splus program."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(setq ess-customize-alist S+-customize-alist)
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "\n(S+): ess-dialect=%s, buf=%s\n" ess-dialect
|
||||
(current-buffer)))
|
||||
(setq ess-customize-alist ; change inferior-ess-program
|
||||
(append ess-customize-alist '((inferior-ess-program
|
||||
. (getenv "COMSPEC")))))
|
||||
(setq ess-customize-alist ; change inferior-ess-primary-prompt
|
||||
(append ess-customize-alist '((inferior-ess-primary-prompt . "^"))))
|
||||
(setq ess-customize-alist ; change inferior-ess-start-args
|
||||
(append ess-customize-alist '((inferior-ess-start-args . ""))))
|
||||
(let ((s-proj (getenv "S_PROJ"))
|
||||
(use-dialog-box (not (or ess-microsoft-p (eq system-type 'cygwin))))
|
||||
)
|
||||
(cd (w32-short-file-name (directory-file-name default-directory)))
|
||||
(setenv "S_PROJ" (w32-short-file-name default-directory))
|
||||
(inferior-ess)
|
||||
(sleep-for 2) ; need to wait, else working too fast! The Splus
|
||||
; command in '(ddeESS [S+])' should follow the "$"
|
||||
; prompt. If not, then increase the sleep-for time!
|
||||
(setenv "S_PROJ" s-proj))
|
||||
(setq ess-customize-alist S+-customize-alist)
|
||||
(ess-setq-vars-local ess-customize-alist)
|
||||
;;; the next three lines belong in customize-alist, but can't be there
|
||||
;;; because of the broken ess-setq-vars-default usage in ess-inf.el
|
||||
(setq inferior-ess-ddeclient "ddeclient")
|
||||
(setq inferior-ess-client-name "S-PLUS")
|
||||
(setq inferior-ess-client-command "SCommand")
|
||||
;;; end of what belongs in customize-alist
|
||||
(setq comint-input-sender 'comint-simple-send)
|
||||
(setq comint-process-echoes nil)
|
||||
(set-buffer-process-coding-system 'raw-text-dos 'raw-text-dos)
|
||||
(goto-char (point-max))
|
||||
(insert (concat inferior-S+-program-name " "
|
||||
inferior-ess-start-args)) ; Note: there is no final "&".
|
||||
;; Without the "&", the results of !system.command come to '(ddeESS [S+])'
|
||||
;; With the "&", the results of !system.command in S get lost.
|
||||
(inferior-ess-send-input)
|
||||
(sleep-for ess-S+-startup-delay) ; Need to wait, else working too fast!
|
||||
; If the ess-current-process-name doesn't appear in the
|
||||
; Splus Commands window increase the sleep-for time!
|
||||
;;; from msdos-minor-mode
|
||||
(setq comint-process-echoes t)
|
||||
(add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m nil t)
|
||||
;;; end from msdos-minor-mode
|
||||
(setq ess-local-process-name ess-current-process-name)
|
||||
(ess-eval-linewise (concat "#" ess-current-process-name))
|
||||
(goto-char (point-min))
|
||||
(insert
|
||||
"This is a placeholder buffer. You can't type anything here.
|
||||
Use `C-x b RET' to return to your file.\n
|
||||
Anything sent to this process from an S-mode buffer goes
|
||||
directly to the associated Splus Commands window.\n
|
||||
The S-Plus Commands window must be visible.
|
||||
You may need to open the S-Plus Commands window manually
|
||||
(by clicking on Splus/Window/Commands Window).\n
|
||||
There is a `ess-S+-startup-delay' second delay when this program starts
|
||||
during which the emacs screen will be partially blank.\n
|
||||
Remember to 'q()' from S-Plus and
|
||||
then C-x C-q exit from the '(ddeESS [S+])' buffer,
|
||||
or take the risk of not being able to shut down your computer
|
||||
and suffering through scandisk.\n
|
||||
Any results of the !system.command typed at the S prompt in the
|
||||
Splus Commands window (are supposed to) appear in this buffer.\n\n")
|
||||
(goto-char (point-max)) ; comint-mode-map makes '(ddeESS [S+])'
|
||||
(use-local-map comint-mode-map) ; a shell buffer after Splus is finished.
|
||||
(setq buffer-read-only t) ; force buffer to be read-only
|
||||
(setq mode-name "ddeESS")
|
||||
;; (ess-eval-linewise inferior-S+-editor-pager-command)
|
||||
(if inferior-ess-language-start
|
||||
(ess-eval-linewise inferior-ess-language-start))
|
||||
))
|
||||
|
||||
(defalias 'S+6-msdos-existing 'S+-msdos-existing)
|
||||
(defun S+-msdos-existing (&optional proc-name)
|
||||
"Call 'S-PLUS [678].x for Windows', the 'GUI Thing' from StatSci. Do so by
|
||||
finding an existing S-Plus in an independent MS-Window (if there is one) and
|
||||
set up a '(ddeESS [S+])' buffer in emacs. If there is no existing
|
||||
S-Plus, then a new one will be opened in the default directory. The default
|
||||
is usually something like 'c:/Program Files/Insightful/splus70/users/yourname'
|
||||
for S-Plus before 8.0.4. Beginning with 8.0.4, S-Plus uses the default directory
|
||||
'c:/Documents and Settings/yourname/My Documents/S-PLUS Projects/Project1'.
|
||||
Beginning with TIBCO Spotfire S+ Version 8.1.1 for Microsft Windows, the default
|
||||
directory is 'c:/DOCUME~1/yourname/MYDOCU~1/SPOTFI~1/Project1'.
|
||||
If you have a HOME environment variable, it will open it there."
|
||||
(interactive)
|
||||
(let* ((inferior-S+-multipleinstances "")
|
||||
(ess-S+-startup-delay 0)) ;; No delay for existing S-Plus
|
||||
(S+-msdos-initiate proc-name))
|
||||
(with-current-buffer (car (buffer-list)) ; get the ESS buffer just created
|
||||
(setq buffer-read-only nil) ; permit writing in ESS buffer
|
||||
(goto-char (point-max))
|
||||
(beginning-of-line)
|
||||
(forward-line -1)
|
||||
(insert
|
||||
"This is S+-msdos-existing.
|
||||
Results of the !system.command typed at the S prompt in the
|
||||
Splus Commands window blink a DOS window and you won't see them.\n\n")
|
||||
(setq buffer-read-only t) ; restore ESS buffer to be read-only
|
||||
))
|
||||
|
||||
(defun ess-sqpe-versions-create (ess-SHOME-versions &optional x64)
|
||||
"Generate the `M-x splusxy' functions for starting other versions of
|
||||
Sqpe. `ESS-SHOME-VERSIONS' is normally taken from
|
||||
`ess-sqpe-versions', a variable that contains strings that determine which
|
||||
functions are created. This works by creating a temp buffer where the
|
||||
template function `Sqpe+template' is edited by replacing the string
|
||||
'Sqpe+template' by the version name. The list of functions actually
|
||||
created appears in the *ESS* buffer. If `X64' is not nil, then
|
||||
modify the function name to show \"-64bit\" in its name.
|
||||
|
||||
The result `ess-sqpe-versions-created' will store a list of the new
|
||||
Sqpe defuns, if any, that were created. The defuns will normally be
|
||||
placed on the menubar upon ESS initialisation."
|
||||
(let ((beg)
|
||||
(versions)
|
||||
(version)
|
||||
(eval-buf (get-buffer-create "*ess-temp-sqpe-evals*"))
|
||||
(ess-sqpe-versions-created)
|
||||
)
|
||||
;;
|
||||
(with-current-buffer eval-buf
|
||||
;; clear the buffer.
|
||||
(delete-region (point-min) (point-max))
|
||||
|
||||
;; Find which versions of Sqpe we want.
|
||||
(setq x64 (if x64 "-64bit"))
|
||||
(setq versions (ess-uniq-list ess-SHOME-versions))
|
||||
;; Iterate over each string in VERSIONS, creating a new defun each time.
|
||||
(while versions
|
||||
(setq version (car versions)
|
||||
versions (cdr versions))
|
||||
(if (file-executable-p version)
|
||||
(progn
|
||||
(setq beg (point))
|
||||
(setq version-function-name (concat (file-name-nondirectory version) x64))
|
||||
(prin1 (symbol-function 'Sqpe+template) eval-buf)
|
||||
(insert "\n\n")
|
||||
(goto-char beg)
|
||||
(while (search-forward "lambda" nil t 1)
|
||||
(replace-match
|
||||
(concat "defun " version-function-name)
|
||||
t t))
|
||||
(while (search-forward "ess-SHOME" nil t)
|
||||
(replace-match version t t))
|
||||
(goto-char (point-max))
|
||||
(setq ess-sqpe-versions-created
|
||||
(cons version-function-name
|
||||
ess-sqpe-versions-created))
|
||||
(ess-write-to-dribble-buffer
|
||||
(format
|
||||
"(Sqpe): ess-sqpe-versions-create making M-x defun %s for %s \n"
|
||||
version-function-name version))
|
||||
)))
|
||||
;; buffer has now been created with defuns, so eval them!
|
||||
(eval-buffer)
|
||||
(kill-buffer eval-buf))
|
||||
ess-sqpe-versions-created))
|
||||
|
||||
;; template function used by ess-sqpe-versions-create
|
||||
(defun Sqpe+template (&optional proc-name)
|
||||
"Call 'Sqpe' from 'S-PLUS for Windows ess-SHOME',
|
||||
the 'Real Thing' from StatSci.
|
||||
This function was generated by `ess-sqpe-versions-create'."
|
||||
(interactive)
|
||||
(setq ess-customize-alist Sqpe+-customize-alist)
|
||||
(let* ((use-dialog-box) ;; MS dialog box won't return a directory
|
||||
(shome-old (getenv "SHOME"))
|
||||
(inferior-Sqpe+-SHOME-name "ess-SHOME")
|
||||
(inferior-Sqpe+-program-name (concat "ess-SHOME" "/cmd/sqpe.exe")))
|
||||
(setenv "SHOME" "ess-SHOME")
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "\n(Sqpe+template): ess-dialect=%s, buf=%s\n" ess-dialect
|
||||
(current-buffer)))
|
||||
(setq ess-customize-alist ; change inferior-ess-primary-prompt
|
||||
(append ess-customize-alist
|
||||
'((inferior-ess-primary-prompt . "^"))))
|
||||
(inferior-ess)
|
||||
(setq ess-customize-alist Sqpe+-customize-alist) ; restore i-e-p-p in alist
|
||||
(ess-setq-vars-local ess-customize-alist) ; restore i-e-p-p in buffer
|
||||
(setq inferior-ess-prompt ; define with correct i-e-p-p
|
||||
;; Do not anchor to bol with `^' ; (copied from ess-inf.el)
|
||||
(concat "\\("
|
||||
inferior-ess-primary-prompt
|
||||
"\\|"
|
||||
inferior-ess-secondary-prompt
|
||||
"\\)"))
|
||||
(setq comint-prompt-regexp (concat "^" inferior-ess-prompt))
|
||||
; define with correct i-e-p-p
|
||||
(setq comint-input-sender 'inferior-ess-input-sender)
|
||||
(add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m nil t)
|
||||
(goto-char (point-max))
|
||||
(insert "options(interactive=TRUE)")
|
||||
(inferior-ess-send-input)
|
||||
(setq mode-name "iESS(Sqpe)")
|
||||
;; (ess-eval-linewise inferior-S+-editor-pager-command)
|
||||
(if inferior-ess-language-start
|
||||
(ess-eval-linewise inferior-ess-language-start))
|
||||
(setenv "SHOME" shome-old)))
|
||||
|
||||
|
||||
; Provide package
|
||||
|
||||
(provide 'ess-sp6w-d)
|
||||
|
||||
; Local variables section
|
||||
|
||||
;;; This file is automatically placed in Outline minor mode.
|
||||
;;; The file is structured as follows:
|
||||
;;; Chapters: ^L ;
|
||||
;;; Sections: ;;*;;
|
||||
;;; Subsections: ;;;*;;;
|
||||
;;; Components: defuns, defvars, defconsts
|
||||
;;; Random code beginning with a ;;;;* comment
|
||||
|
||||
;;; Local variables:
|
||||
;;; mode: emacs-lisp
|
||||
;;; outline-minor-mode: nil
|
||||
;;; mode: outline-minor
|
||||
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
|
||||
;;; End:
|
||||
|
||||
;;; ess-sp6w-d.el ends here
|
||||
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp6w-d.elc
Normal file
BIN
.emacs.d/elpa/ess-20160208.453/lisp/ess-sp6w-d.elc
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user