Klimi's new dotfiles with stow.
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

190 righe
6.9 KiB

  1. ;;; essd-els.el --- S-PLUS 3.x at another location customization -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 1998 Richard M. Heiberger
  3. ;; Copyright (C) 1999--2005 A.J. Rossini, Richard M. Heiberger, Martin
  4. ;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
  5. ;; Author: Richard M. Heiberger <rmh@temple.edu>
  6. ;; Created: December 1998
  7. ;; Maintainer: ESS-core <ESS-core@r-project.org>
  8. ;; Keywords: languages
  9. ;; This file is part of ESS.
  10. ;; This file is free software; you can redistribute it and/or modify
  11. ;; it under the terms of the GNU General Public License as published by
  12. ;; the Free Software Foundation; either version 2, or (at your option)
  13. ;; any later version.
  14. ;; This file is distributed in the hope that it will be useful,
  15. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ;; GNU General Public License for more details.
  18. ;; A copy of the GNU General Public License is available at
  19. ;; https://www.r-project.org/Licenses/
  20. ;;; Commentary:
  21. ;; This file defines all the S-PLUS 3.x customizations for ess-mode.
  22. ;;; Code:
  23. (require 'ess-julia)
  24. (require 'ess-s-lang)
  25. (require 'ess-sp6-d)
  26. (require 'ess-sas-d)
  27. (require 'ess-stata-mode)
  28. (require 'ess-trns)
  29. (require 'ess-utils)
  30. ;; Easily changeable in a user's .emacs
  31. (defvar S+elsewhere-dialect-name "S+6"
  32. "Name of 'dialect' for S-PLUS at another location.")
  33. (defvar S+elsewhere-start-args "-i"
  34. "Arguments for `S+elsewhere-dialect-name'.")
  35. (defcustom inferior-ess-remote-pager nil
  36. "Remote pager to use for reporting help files and similar things.
  37. The default value is nil."
  38. :group 'ess-proc
  39. :type '(choice (const nil) string))
  40. (defvar S+elsewhere-customize-alist
  41. (append
  42. '((ess-local-customize-alist . 'S+elsewhere-customize-alist)
  43. (ess-dialect . S+elsewhere-dialect-name)
  44. (ess-object-name-db-file . "ess-spelsewhere-namedb.el" )
  45. (inferior-ess-program . inferior-S-elsewhere-program)
  46. (inferior-ess-help-command . "help(\"%s\", pager=\"cat\", window=F)\n")
  47. (ess-STERM . "iESS")
  48. )
  49. S+common-cust-alist)
  50. "Variables to customize for S+elsewhere.")
  51. (defun S+elsewhere (&optional _proc-name)
  52. "Call 'S-PLUS 3.x', the 'Real Thing' from StatSci."
  53. ;; git commit 104c4d7c56bc239ea245562763caa317bc3a1a84
  54. (declare (obsolete ess-remote "2000"))
  55. (ess-write-to-dribble-buffer
  56. (format "\n(S+elsewhere): ess-dialect=%s, buf=%s\n" ess-dialect
  57. (current-buffer)))
  58. (let ((inf-buf (inferior-ess nil S+elsewhere-customize-alist)))
  59. (when inferior-ess-language-start
  60. (ess-eval-linewise inferior-ess-language-start))
  61. inf-buf))
  62. (defun S+elsewhere-mode (&optional _proc-name)
  63. "Major mode for editing S+3 source. See `ess-mode' for more help."
  64. (declare (obsolete ess-remote "2000"))
  65. (setq-local ess-local-customize-alist S+elsewhere-customize-alist)
  66. (ess-mode))
  67. (define-obsolete-function-alias 'S+elsewhere-transcript-mode #'S-transcript-mode "2000")
  68. ;; This REALLY shouldn't need an editing mode. Just a transcript and
  69. ;; an inferior process handler.
  70. (defun ess-select-alist-dialect (&optional dialect)
  71. "Query user for an ESS DIALECT and return the matching customize-alist."
  72. (interactive)
  73. (let* ((dialects '("R" "S+" "julia" "arc" "vst" "omg" "s3" "s4" "stata" "sp3" "sp4"
  74. "sqpe4" "sp5" "sqpe" "XLS" "SAS"))
  75. (dialect (or dialect
  76. (ess-completing-read "Dialect" dialects nil t))))
  77. (cond
  78. ((string= dialect "julia") ess-julia-customize-alist)
  79. ((string= dialect "stata") STA-customize-alist)
  80. ((string= dialect "R") ess-r-customize-alist)
  81. ((string= dialect "SAS") SAS-customize-alist)
  82. (t S+elsewhere-customize-alist))))
  83. (defun ess-add-ess-process ()
  84. "Execute this command from within a buffer running a process to add
  85. the process to `ess-process-name-alist' and to make it the
  86. `ess-current-process-name'. This command will normally be run in a
  87. telnet buffer connected to another computer or in a shell or comint
  88. buffer on the local computer."
  89. (interactive)
  90. (let ((proc (get-buffer-process (buffer-name))))
  91. (if (not proc)
  92. (error "No process is associated with this buffer")
  93. (set-process-filter proc 'inferior-ess-output-filter)
  94. (setq ess-current-process-name (process-name proc))
  95. (add-to-list 'ess-process-name-list
  96. (list ess-current-process-name)))))
  97. (defvar ess-remote nil
  98. "Indicator, t in remote buffers.")
  99. ;;;###autoload
  100. (defun ess-remote (&optional proc-name dialect)
  101. "Execute this command from within a buffer running a process.
  102. It runs `ess-add-ess-process' to add the PROC-NAME to
  103. `ess-process-name-alist' and to make it the
  104. `ess-current-process-name'. It then prompts the user for an ESS
  105. language and sets the editing characteristics appropriately.
  106. To use this command, first start a process on a remote computer by
  107. manual use of telnet, rlogin, ssh, or some other protocol. Start the
  108. relevant program (\"S\" or \"R\" or \"sas -stdio\") in that buffer. Once
  109. you are talking to S or R or SAS, then do \\[ess-remote] to make
  110. the current buffer an inferior-ess buffer with the right behavior for
  111. the language you are currently working with. With S and R, use C-c
  112. C-n to send lines over. With SAS, use C-c i
  113. `ess-eval-line-and-step-invisibly' to send lines over invisibly.
  114. DIALECT is the desired ess-dialect. If nil, ask for dialect"
  115. (interactive)
  116. (ess-add-ess-process)
  117. ;; Need to select a remote-customize-alist
  118. (let ((customize-alist (ess-select-alist-dialect dialect)))
  119. (ess-write-to-dribble-buffer
  120. (format "\n(ESS-remote): ess-dialect=%s, buf=%s\n" ess-dialect
  121. (current-buffer)))
  122. (ess-setq-vars-local customize-alist)
  123. (inferior-ess--set-major-mode ess-dialect)
  124. (setq-local ess-remote t)
  125. (setq ess-local-process-name (or proc-name ess-current-process-name))
  126. (goto-char (point-max))
  127. (when (equal ess-dialect "R")
  128. ;; ugly fix for evn variable. What can we do :(
  129. (ess-eval-linewise (format "options(pager='%s')\n"
  130. (or inferior-ess-remote-pager inferior-ess-pager))
  131. nil nil nil 'wait)
  132. (ess-r-load-ESSR))
  133. (when (equal ess-dialect "S+")
  134. (ess-command ess-S+--injected-code))
  135. (when (equal ess-language "SAS")
  136. (font-lock-mode 0)
  137. (SAS-log-mode)
  138. (shell-mode)
  139. (setq buffer-read-only nil)
  140. (font-lock-mode 1))
  141. (ess-process-put 'funargs-cache (make-hash-table :test 'equal))
  142. (ess-process-put 'funargs-pre-cache nil)
  143. ;; auto-complete
  144. (ess--setup-auto-complete ess-r-ac-sources t)
  145. ;; company
  146. (ess--setup-company ess-r-company-backends t)
  147. (when inferior-ess-language-start
  148. (ess-eval-linewise inferior-ess-language-start
  149. nil nil nil 'wait-prompt))))
  150. ; Provide package
  151. (provide 'essd-els)
  152. ;;; essd-els.el ends here