Klimi's new dotfiles with stow.
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

519 linhas
24 KiB

há 4 anos
  1. ;;; ess-r-completion.el --- R completion -*- lexical-binding: t; -*-
  2. ;;
  3. ;; Copyright (C) 2015 A.J. Rossini, Richard M. Heiberger, Martin Maechler, Kurt
  4. ;; Hornik, Rodney Sparapani, Stephen Eglen and Vitalie Spinu.
  5. ;;
  6. ;; Author: Vitalie Spinu
  7. ;; Maintainer: ESS-core <ESS-core@r-project.org>
  8. ;;
  9. ;; Keywords: languages, statistics
  10. ;;
  11. ;; This file is part of ESS.
  12. ;;
  13. ;; This file is free software; you can redistribute it and/or modify
  14. ;; it under the terms of the GNU General Public License as published by
  15. ;; the Free Software Foundation; either version 2, or (at your option)
  16. ;; any later version.
  17. ;;
  18. ;; This file is distributed in the hope that it will be useful,
  19. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. ;; GNU General Public License for more details.
  22. ;;
  23. ;; A copy of the GNU General Public License is available at
  24. ;; https://www.r-project.org/Licenses/
  25. ;;
  26. ;;; Commentary:
  27. ;;
  28. ;;; Code:
  29. ;;; ElDoc
  30. (require 'cl-lib)
  31. (require 'ess-inf)
  32. (require 'ess-help)
  33. (eval-when-compile
  34. (require 'subr-x))
  35. (defvar ac-auto-start)
  36. (defvar ac-prefix)
  37. (defvar ac-point)
  38. (defvar ac-use-comphist)
  39. (declare-function company-begin-backend "company")
  40. (declare-function company-doc-buffer "company")
  41. (defcustom ess-R-argument-suffix " = "
  42. "Suffix appended by `ac-source-R' and `ac-source-R-args' to candidates."
  43. :group 'ess-R
  44. :type 'string)
  45. (defun ess-r-eldoc-function ()
  46. "Return the doc string, or nil.
  47. If an ESS process is not associated with the buffer, do not try
  48. to look up any doc strings."
  49. (when (and eldoc-mode ess-can-eval-in-background)
  50. (let* ((proc (ess-get-next-available-process))
  51. (funname (and proc (or (and ess-eldoc-show-on-symbol ;; Aggressive completion
  52. (thing-at-point 'symbol))
  53. (car (ess--fn-name-start))))))
  54. (when funname
  55. (let* ((args (ess-function-arguments funname proc))
  56. (bargs (cadr args))
  57. (doc (mapconcat (lambda (el)
  58. (if (equal (car el) "...")
  59. "..."
  60. (concat (car el) "=" (cdr el))))
  61. bargs ", "))
  62. (margs (nth 2 args))
  63. (W (- (window-width (minibuffer-window)) (+ 4 (length funname))))
  64. doc1)
  65. (when doc
  66. (setq doc (ess-eldoc-docstring-format funname doc))
  67. (when (and margs (< (length doc1) W))
  68. (setq doc1 (concat doc (propertize " || " 'face font-lock-function-name-face)))
  69. (while (and margs (< (length doc1) W))
  70. (let ((head (pop margs)))
  71. (unless (assoc head bargs)
  72. (setq doc doc1
  73. doc1 (concat doc1 head "=, ")))))
  74. (when (equal (substring doc -2) ", ")
  75. (setq doc (substring doc 0 -2)))
  76. (when (and margs (< (length doc) W))
  77. (setq doc (concat doc " {--}"))))
  78. doc))))))
  79. (defun ess-eldoc-docstring-format (funname doc)
  80. (save-match-data
  81. (let* (;; (name (symbol-name sym))
  82. (truncate (or (not (eq t eldoc-echo-area-use-multiline-p))
  83. (eq ess-eldoc-abbreviation-style 'aggressive)))
  84. ;; Subtract 1 from window width since will cause a wraparound and
  85. ;; resize of the echo area.
  86. (W (1- (- (window-width (minibuffer-window))
  87. (+ 2 (length funname))))))
  88. (setq doc
  89. (if (or (<= (length doc) W)
  90. (null ess-eldoc-abbreviation-style)
  91. (eq 'none ess-eldoc-abbreviation-style))
  92. doc
  93. ;;MILD filter
  94. (setq doc (replace-regexp-in-string "TRUE" "T" doc))
  95. (setq doc (replace-regexp-in-string "FALSE" "F" doc))
  96. (if (or (<= (length doc) W)
  97. (eq 'mild ess-eldoc-abbreviation-style))
  98. doc
  99. ;;NORMAL filter (deal with long defaults)
  100. (setq doc (replace-regexp-in-string
  101. ;; function calls inside default docs foo(xxxx{..})
  102. "([^)]\\{8\\}\\([^)]\\{4,\\}\\))"
  103. "{.}" doc nil nil 1))
  104. (if (<= (length doc) W)
  105. doc
  106. (setq doc (replace-regexp-in-string
  107. " +[^ \t=,\"\]+=[^ \t]\\{10\\}\\([^ \t]\\{4,\\}\\)\\(,\\|\\'\\)"
  108. "{.}," doc nil nil 1))
  109. (if (<= (length doc) W)
  110. doc
  111. (setq doc (replace-regexp-in-string
  112. " +[^ \t=,\"]+=\\([^ \t]\\{10,\\}\\)\\(,\\|\\'\\)"
  113. "{.}," doc nil nil 1))
  114. (if (or (<= (length doc) W)
  115. (eq 'normal ess-eldoc-abbreviation-style))
  116. doc
  117. ;;STRONG filter (replace defaults)
  118. (setq doc (replace-regexp-in-string
  119. " *[^ \t=,\"\\]* = \\([^ \t]\\{4,\\}\\)\\(,\\|\\'\\)"
  120. "{.}," doc nil nil 1))
  121. (if (<= (length doc) W)
  122. doc
  123. (setq doc (replace-regexp-in-string
  124. "\\(=[^FT0-9].+?\\)\\(, [^ =,\"\\]+=\\|\\'\\)"
  125. "" doc nil nil 1))
  126. (setq doc (replace-regexp-in-string
  127. "\\(=[^FT0-9].+?\\)\\(, [^ =,\"\\]+,\\|\\'\\)"
  128. "" doc nil nil 1))
  129. (if (or (<= (length doc) W)
  130. (eq 'strong ess-eldoc-abbreviation-style))
  131. doc
  132. ;;AGGRESSIVE filter (truncate what is left)
  133. (concat (substring doc 0 (- W 4)) "{--}")))))))))
  134. (when (and truncate
  135. (> (length doc) W))
  136. (setq doc (concat (substring doc 0 (- W 4)) "{--}")))
  137. (format "%s: %s" (propertize funname 'face 'font-lock-function-name-face) doc))))
  138. ;;; OBJECTS
  139. (defun ess-r-object-completion ()
  140. "Return completions at point in a format required by `completion-at-point-functions'."
  141. (if (ess-make-buffer-current)
  142. (let* ((funstart (cdr (ess--fn-name-start)))
  143. (completions (ess-r-get-rcompletions funstart))
  144. (token (pop completions)))
  145. (when completions
  146. (list (- (point) (length token)) (point)
  147. completions)))
  148. (when (string-match "complete" (symbol-name last-command))
  149. (message "No ESS process associated with current buffer")
  150. nil)))
  151. (defun ess-complete-object-name ()
  152. "Perform completion on object preceding point.
  153. Uses `ess-r-complete-object-name' when `ess-use-R-completion' is non-nil,
  154. and `ess-internal-complete-object-name' otherwise."
  155. (interactive)
  156. (if (ess-make-buffer-current)
  157. (if ess-use-R-completion
  158. (ess-r-complete-object-name)
  159. (ess-internal-complete-object-name))
  160. ;; else give a message on second invocation
  161. (when (string-match "complete" (symbol-name last-command))
  162. (message "No ESS process associated with current buffer")
  163. nil)))
  164. (define-obsolete-function-alias 'ess-list-object-completions #'ess-complete-object-name "ESS 19.04")
  165. ;; This one is needed for R <= 2.6.x -- hence *not* obsoleting it
  166. (defun ess-internal-complete-object-name ()
  167. "Perform completion on `ess-language' object preceding point.
  168. The object is compared against those objects known by
  169. `ess-get-object-list' and any additional characters up to ambiguity are
  170. inserted. Completion only works on globally-known objects (including
  171. elements of attached data frames), and thus is most suitable for
  172. interactive `command-line' entry, and not so much for function editing
  173. since local objects (e.g. argument names) aren't known.
  174. Use \\[ess-resynch] to re-read the names of the attached directories.
  175. This is done automatically (and transparently) if a directory is
  176. modified (S only!), so the most up-to-date list of object names is always
  177. available. However attached dataframes are *not* updated, so this
  178. command may be necessary if you modify an attached dataframe."
  179. (ess-make-buffer-current)
  180. (if (memq (char-syntax (preceding-char)) '(?w ?_))
  181. (let* ((comint-completion-addsuffix nil)
  182. (bounds (ess-bounds-of-symbol))
  183. (beg (car bounds))
  184. (end (cdr bounds))
  185. (full-prefix (buffer-substring beg end))
  186. (pattern full-prefix)
  187. ;; See if we're indexing a list with `$'
  188. (listname (if (string-match "\\(.+\\)\\$\\(\\(\\sw\\|\\s_\\)*\\)$"
  189. full-prefix)
  190. (progn
  191. (setq pattern
  192. (if (not (match-beginning 2)) ""
  193. (substring full-prefix
  194. (match-beginning 2)
  195. (match-end 2))))
  196. (substring full-prefix (match-beginning 1)
  197. (match-end 1)))))
  198. ;; are we trying to get a slot via `@' ?
  199. (classname (if (string-match "\\(.+\\)@\\(\\(\\sw\\|\\s_\\)*\\)$"
  200. full-prefix)
  201. (progn
  202. (setq pattern
  203. (if (not (match-beginning 2)) ""
  204. (substring full-prefix
  205. (match-beginning 2)
  206. (match-end 2))))
  207. (ess-write-to-dribble-buffer
  208. (format "(ess-C-O-Name : slots..) : patt=%s"
  209. pattern))
  210. (substring full-prefix (match-beginning 1)
  211. (match-end 1)))))
  212. (components (if listname
  213. (ess-object-names listname)
  214. (if classname
  215. (ess-slot-names classname)
  216. ;; Default case: It hangs here when
  217. ;; options(error=recover) :
  218. (ess-get-object-list ess-current-process-name)))))
  219. ;; always return a non-nil value to prevent history expansions
  220. (or (completion-in-region beg end components) 'none))))
  221. (defun ess-r-get-rcompletions (&optional start end prefix allow-3-dots)
  222. "Call R internal completion utilities (rcomp) for possible completions.
  223. Optional START and END delimit the entity to complete, default to
  224. bol and point. If PREFIX is given, perform completion on
  225. PREFIX. First element of the returned list is the completion
  226. token. Needs version of R >= 2.7.0."
  227. (let* ((start (or start
  228. (if prefix
  229. 0
  230. (save-excursion (comint-bol nil) (point)))))
  231. (end (or end (if prefix (length prefix) (point))))
  232. (prefix (or prefix (buffer-substring start end)))
  233. ;; (opts1 (if no-args "op<-rc.options(args=FALSE)" ""))
  234. ;; (opts2 (if no-args "rc.options(op)" ""))
  235. (call1 (format ".ess_get_completions(\"%s\", %d, \"%s\")"
  236. (ess-quote-special-chars prefix)
  237. (- end start)
  238. ess-R-argument-suffix))
  239. (cmd (if allow-3-dots
  240. (concat call1 "\n")
  241. (concat "local({ r <- " call1 "; r[r != '...='] })\n"))))
  242. (ess-get-words-from-vector cmd)))
  243. (defun ess-r-complete-object-name ()
  244. "Completion in R via R's completion utilities (formerly 'rcompgen').
  245. To be used instead of ESS' completion engine for R versions >= 2.7.0."
  246. (let ((possible-completions (ess-r-get-rcompletions))
  247. token-string)
  248. (when possible-completions
  249. (setq token-string (pop possible-completions))
  250. (or (completion-in-region (- (point) (length token-string))
  251. (point)
  252. possible-completions)
  253. 'none))))
  254. (defvar ess--cached-sp-objects nil)
  255. (defun ess--get-cached-completions (prefix &optional _point)
  256. (if (string-match-p "[]:$@[]" prefix)
  257. ;; call proc for objects
  258. (cdr (ess-r-get-rcompletions nil nil prefix))
  259. ;; else, get cached list of objects
  260. (with-ess-process-buffer 'no-error ;; use proc buf alist
  261. (ess-when-new-input last-cached-completions
  262. (if (and ess--cached-sp-objects
  263. (not (process-get *proc* 'sp-for-ac-changed?)))
  264. ;; if global cache is already there, only re-read local .GlobalEnv
  265. (progn
  266. (unless ess-sl-modtime-alist
  267. ;; initialize if empty
  268. (setq ess-sl-modtime-alist '((".GlobalEnv" nil))))
  269. ;; fixme: Make adaptive. Not on all remotes are slow; For lots of
  270. ;; objects in .GlobalEnv,locals could also be slow.
  271. (unless (file-remote-p default-directory)
  272. (ess-extract-onames-from-alist ess-sl-modtime-alist 1 'force)))
  273. (if ess--cached-sp-objects
  274. (ess-get-modtime-list 'ess--cached-sp-objects 'exclude-first)
  275. (ess-get-modtime-list)
  276. (setq ess--cached-sp-objects (cdr ess-sl-modtime-alist)))
  277. ;; reread new package, but not rda, much faster and not needed anyways
  278. (process-put *proc* 'sp-for-ac-changed? nil)))
  279. (apply 'append
  280. (cl-cddar ess-sl-modtime-alist) ; .GlobalEnv
  281. (mapcar 'cddr ess--cached-sp-objects)))))
  282. ;;; ARGUMENTS
  283. (defvar ess-r--funargs-pre-cache
  284. '(("plot"
  285. (("graphics")
  286. (("x" . "") ("y" . "NULL") ("type" . "p") ("xlim" . "NULL") ("ylim" . "NULL") ("log" . "") ("main" . "NULL") ("sub" . "NULL") ("xlab" . "NULL") ("ylab" . "NULL")
  287. ("ann" . "par(\"ann\")") ("axes" . "TRUE") ("frame.plot" . "axes") ("panel.first" . "NULL") ("panel.last" . "NULL") ("asp" . "NA") ("..." . ""))
  288. ("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"
  289. "panel.first" "panel.last" "asp" "center" "edge.root" "nodePar" "edgePar" "leaflab" "dLeaf" "xaxt" "yaxt" "horiz"
  290. "zero.line" "verticals" "col.01line" "pch" "legend.text" "formula" "data" "subset" "to" "from" "newpage" "vp" "labels"
  291. "hang" "freq" "density" "angle" "col" "border" "lty" "add" "predicted.values" "intervals" "separator" "col.predicted"
  292. "col.intervals" "col.separator" "lty.predicted" "lty.intervals" "lty.separator" "plot.type" "main2" "par.fit" "grid"
  293. "panel" "cex" "dimen" "abbrev" "which" "caption" "sub.caption" "id.n" "labels.id" "cex.id" "qqline" "cook.levels"
  294. "add.smooth" "label.pos" "cex.caption" "rows" "levels" "conf" "absVal" "ci.lty" "xval" "do.points" "col.points" "cex.points"
  295. "col.hor" "col.vert" "lwd" "set.pars" "range.bars" "col.range" "xy.labels" "xy.lines" "nc" "yax.flip" "mar.multi" "oma.multi")))
  296. ("print"
  297. (("base")
  298. (("x" . "") ("digits" . "NULL") ("quote" . "TRUE") ("na.print" . "NULL") ("print.gap" . "NULL") ("right" . "FALSE") ("max" . "NULL") ("useSource" . "TRUE") ("..." . ""))
  299. ("x" "..." "digits" "signif.stars" "intercept" "tol" "se" "sort" "verbose" "indent" "style" ".bibstyle" "prefix" "vsep" "minlevel" "quote" "right" "row.names" "max" "na.print" "print.gap"
  300. "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"
  301. "loadings" "zero.print" "calendar"))))
  302. "Alist of cached arguments for time consuming functions.")
  303. ;;; HELP
  304. (defun ess-r-get-object-help-string (sym)
  305. "Help string for ac."
  306. (let ((proc (ess-get-next-available-process)))
  307. (if (null proc)
  308. "No free ESS process found"
  309. (let ((buf (get-buffer-create " *ess-command-output*")))
  310. (when (string-match ":+\\(.*\\)" sym)
  311. (setq sym (match-string 1 sym)))
  312. (with-current-buffer (process-buffer proc)
  313. (ess-with-current-buffer buf
  314. (ess--flush-help-into-current-buffer sym nil)))
  315. (with-current-buffer buf
  316. (ess-help-underline)
  317. (goto-char (point-min))
  318. (buffer-string))))))
  319. (defun ess-r-get-arg-help-string (sym &optional proc)
  320. "Help string for ac."
  321. (setq sym (replace-regexp-in-string " *= *\\'" "" sym))
  322. (let ((proc (or proc (ess-get-next-available-process))))
  323. (if (null proc)
  324. "No free ESS process found"
  325. (let ((fun (car ess--fn-name-start-cache)))
  326. (with-current-buffer (ess-command (format ".ess_arg_help('%s','%s')\n" sym fun)
  327. nil nil nil nil proc)
  328. (goto-char (point-min))
  329. (forward-line)
  330. (buffer-substring-no-properties (point) (point-max)))))))
  331. ;;; COMPANY
  332. ;;; https://company-mode.github.io/
  333. (defun company-R-objects (command &optional arg &rest ignored)
  334. (interactive (list 'interactive))
  335. (cl-case command
  336. (interactive (company-begin-backend 'company-R-objects))
  337. (prefix (unless (ess-inside-string-or-comment-p)
  338. (let ((start (ess-symbol-start)))
  339. (when start
  340. (buffer-substring-no-properties start (point))))))
  341. (candidates (let ((proc (ess-get-next-available-process)))
  342. (when proc
  343. (with-current-buffer (process-buffer proc)
  344. (all-completions arg (ess--get-cached-completions arg))))))
  345. (doc-buffer (company-doc-buffer (ess-r-get-object-help-string arg)))))
  346. (defun company-R-args (command &optional arg &rest ignored)
  347. (interactive (list 'interactive))
  348. (cl-case command
  349. (interactive (company-begin-backend 'company-R-args))
  350. (prefix (unless (ess-inside-string-or-comment-p)
  351. (let ((start (ess-arg-start)))
  352. (when start
  353. (let ((prefix (buffer-substring-no-properties start (point))))
  354. (if ess-company-arg-prefix-length
  355. (cons prefix (>= (length prefix)
  356. ess-company-arg-prefix-length))
  357. prefix))))))
  358. (candidates (let* ((proc (ess-get-next-available-process))
  359. (args (delete "..." (nth 2 (ess-function-arguments
  360. (car ess--fn-name-start-cache) proc))))
  361. (args (mapcar (lambda (a) (concat a ess-R-argument-suffix))
  362. args)))
  363. (all-completions arg args)))
  364. (meta (let ((proc (ess-get-next-available-process)))
  365. (when (and proc
  366. (with-current-buffer (process-buffer proc)
  367. (not (file-remote-p default-directory))))
  368. ;; fixme: ideally meta should be fetched with args
  369. (let ((doc (ess-r-get-arg-help-string arg proc)))
  370. (replace-regexp-in-string "^ +\\| +$" ""
  371. (replace-regexp-in-string "[ \t\n]+" " " doc))))))
  372. (sorted t)
  373. (require-match 'never)
  374. (doc-buffer (company-doc-buffer (ess-r-get-arg-help-string arg)))))
  375. (defun company-R-library (command &optional arg &rest ignored)
  376. (interactive (list 'interactive))
  377. (cl-case command
  378. (interactive (company-begin-backend 'company-R-library))
  379. (prefix (and (member (car (ess--fn-name-start))
  380. '("library" "require"))
  381. (let ((start (ess-symbol-start)))
  382. (and start (buffer-substring start (point))))))
  383. (candidates (all-completions arg (ess-installed-packages)))
  384. (annotation "<pkg>")
  385. (duplicates nil)
  386. (sorted t)))
  387. ;; FIXME: There's a lot of overlap between `ess-r-package-completion'
  388. ;; and `company-R-library'. Can we merge them somehow?
  389. (defun ess-r-package-completion ()
  390. "Return installed packages if in a call to library or require.
  391. Return format suitable for `completion-at-point-functions'."
  392. (when (member (car (ess--fn-name-start))
  393. '("library" "require"))
  394. (list (ess-symbol-start)
  395. (point)
  396. (ess-installed-packages)
  397. :annotation-function
  398. (lambda (_) " <pkg>"))))
  399. ;;; AC SOURCES
  400. ;;; http://cx4a.org/software/auto-complete/index.html
  401. ;; auto-complete is de-facto unmaintained, users should switch to `company-mode'.
  402. (defvar ac-source-R
  403. '((prefix . ess-ac-start)
  404. ;; (requires . 0) ::)
  405. (candidates . ess-ac-candidates)
  406. ;; (action . ess-ac-action-args) ;; interfere with ac-fallback mechanism on RET (which is extremely annoying in inferior buffers)
  407. (document . ess-ac-help))
  408. "Combined ad-completion source for R function arguments and R objects.")
  409. (make-obsolete-variable 'ac-source-R "Use company-mode instead" "ESS 19.04")
  410. (defun ess-ac-start ()
  411. (when (ess-process-live-p)
  412. (or (ess-arg-start)
  413. (ess-symbol-start))))
  414. (make-obsolete-variable 'ess-ac-start "Use company-mode instead" "ESS 19.04")
  415. (defun ess-ac-candidates ()
  416. "OBJECTS + ARGS."
  417. (let ((args (with-no-warnings
  418. ;; suppress obsolete warnings
  419. (ess-ac-args))))
  420. ;; sort of intrusive but right
  421. (if (and ac-auto-start
  422. (< (length ac-prefix) ac-auto-start))
  423. args
  424. (if args
  425. (append args (with-no-warnings
  426. ;; suppress obsolete warnings
  427. (ess-ac-objects t)))
  428. (with-no-warnings
  429. ;; suppress obsolete warnings
  430. (ess-ac-objects))))))
  431. (make-obsolete-variable 'ess-ac-candidates "Use company-mode instead" "ESS 19.04")
  432. (defun ess-ac-help (sym)
  433. (if (string-match-p "= *\\'" sym)
  434. (ess-r-get-arg-help-string sym)
  435. (ess-r-get-object-help-string sym)))
  436. (make-obsolete-variable 'ess-ac-help "Use company-mode instead" "ESS 19.04")
  437. ;; OBJECTS
  438. (defvar ac-source-R-objects
  439. '((prefix . ess-symbol-start)
  440. ;; (requires . 2)
  441. (candidates . ess-ac-objects)
  442. (document . ess-r-get-object-help-string))
  443. "Auto-completion source for R objects.")
  444. (make-obsolete-variable 'ac-source-R-objects "Use company-mode instead" "ESS 19.04")
  445. (defun ess-ac-objects (&optional no-kill)
  446. "Get all cached objects."
  447. (declare (obsolete "Use company-mode instead" "ESS 19.04"))
  448. (let ((aprf ac-prefix))
  449. (when (and aprf (ess-process-live-p))
  450. (unless no-kill ;; workaround
  451. (kill-local-variable 'ac-use-comphist))
  452. (ess--get-cached-completions aprf ac-point))))
  453. ;; ARGS
  454. (defvar ac-source-R-args
  455. '((prefix . ess-arg-start)
  456. ;; (requires . 0)
  457. (candidates . ess-ac-args)
  458. ;; (action . ess-ac-action-args)
  459. (document . ess-r-get-arg-help-string))
  460. "Auto-completion source for R function arguments.")
  461. (make-obsolete-variable 'ac-source-R-args "Use company-mode instead" "ESS 19.04")
  462. (defun ess-ac-args ()
  463. "Get the args of the function when inside parentheses."
  464. (declare (obsolete "Use company-mode-instead" "ESS 19.04"))
  465. (when (and ess--fn-name-start-cache ;; set in a call to ess-arg-start
  466. (ess-process-live-p))
  467. (let ((args (nth 2 (ess-function-arguments (car ess--fn-name-start-cache)))))
  468. (if args
  469. (setq-local ac-use-comphist nil)
  470. (kill-local-variable 'ac-use-comphist))
  471. (delete "..." args)
  472. (mapcar (lambda (a) (concat a ess-R-argument-suffix))
  473. args))))
  474. (provide 'ess-r-completion)
  475. ;;; ess-r-completion.el ends here