[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#35663: 27.0.50; Eldoc support for apply

From: Michael Heerdegen
Subject: bug#35663: 27.0.50; Eldoc support for apply
Date: Fri, 10 May 2019 02:11:34 +0200


when editing something like

(apply #'call-process
  (car command)
  (if stderr-file (list t stderr-file) t)
  (append (cdr command) (list archive name)))

eldoc support would be useful to see the argument names of
'call-process' instead of the signature of 'apply'.

Would doing something like this be acceptable?

From 5eb45fe4a22bb8d130e5318335439b11ef00623b Mon Sep 17 00:00:00 2001
From: Michael Heerdegen <address@hidden>
Date: Fri, 10 May 2019 02:00:18 +0200
Subject: [PATCH] WIP: Make eldoc handle 'apply' specially

 lisp/progmodes/elisp-mode.el | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index cb1b17b447..7631bc60b1 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -1356,6 +1356,16 @@ elisp-eldoc-documentation-function
          ((eq current-symbol (car current-fnsym))
           (or (apply #'elisp-get-fnsym-args-string current-fnsym)
               (elisp-get-var-docstring current-symbol)))
+          ((and (memq (car current-fnsym) '(apply apply-partially))
+                (< 1 (cadr current-fnsym))
+                (let ((args (save-excursion
+                              (let ((argument-index (- 
(elisp--beginning-of-sexp) 2)))
+                                (forward-sexp)
+                                (save-match-data
+                                  (and (looking-at (rx (* (or space "\n")) (or 
"`" "'" "#'")))
+                                       (goto-char (match-end 0))
+                                       (list (elisp--current-symbol) 
+                  (and args (apply #'elisp-get-fnsym-args-string args)))))
           (or (elisp-get-var-docstring current-symbol)
               (apply #'elisp-get-fnsym-args-string current-fnsym))))))

We could also make the displayed text more special to show that this is
actually an 'apply' call and handle the last argument specially but I
think it would be overkill to add so much code for this side case.  OTOH
the suggested patch above already feels like a big relief.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]