unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: 35663@debbugs.gnu.org
Subject: bug#35663: 27.0.50; Eldoc support for apply
Date: Fri, 10 May 2019 02:11:34 +0200	[thread overview]
Message-ID: <871s17uq15.fsf@web.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 337 bytes --]


Hello,

when editing something like

(apply #'call-process
  (car command)
  nil
  (if stderr-file (list t stderr-file) t)
  nil
  (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?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-WIP-Make-eldoc-handle-apply-specially.patch --]
[-- Type: text/x-diff, Size: 1540 bytes --]

From 5eb45fe4a22bb8d130e5318335439b11ef00623b Mon Sep 17 00:00:00 2001
From: Michael Heerdegen <michael_heerdegen@web.de>
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) argument-index)))))))
+                  (and args (apply #'elisp-get-fnsym-args-string args)))))
 	  (t
 	   (or (elisp-get-var-docstring current-symbol)
 	       (apply #'elisp-get-fnsym-args-string current-fnsym))))))
--
2.20.1


[-- Attachment #3: Type: text/plain, Size: 288 bytes --]


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.


Michael.



             reply	other threads:[~2019-05-10  0:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-10  0:11 Michael Heerdegen [this message]
2019-05-10  0:58 ` bug#35663: 27.0.50; Eldoc support for apply Noam Postavsky
2019-05-10 10:24   ` Michael Heerdegen
2019-05-10 10:28     ` Noam Postavsky
2019-05-10 11:41       ` Michael Heerdegen
2020-08-26 10:32 ` Lars Ingebrigtsen
2020-08-26 11:11   ` João Távora
2020-08-27 13:07     ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871s17uq15.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=35663@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).