all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>, emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] emacs-25 d0d9f55: Allow newlines inside cl function arglists
Date: Tue, 10 May 2016 13:11:05 +0300	[thread overview]
Message-ID: <a0fdb9ea-c2d0-a9df-6ec7-0e843b96a99a@yandex.ru> (raw)
In-Reply-To: <jwvoa8er948.fsf-monnier+emacsdiffs@gnu.org>

On 05/10/2016 04:34 AM, Stefan Monnier wrote:

> Why?

Because nobody has proposed a better patch until now.

> This is problematic since it might be difficult to adjust
> help-split-fundoc correspondingly.

We already have this problem with e.g.

   (cl-defgeneric asdasd (&optional (separator "\n")))

because when that is evaluated, ARGLIST passed to help-add-fundoc-usage 
is a form, not a string. I think it's better than not being able to 
define the function at all.

We could escape the newlines in the returned string. What's the best 
place to do that? Do we have a handier function that turns "\n" into 
"\\n", and does the same for \r, \t, and maybe unprintable characters?

This seems to work:

diff --git a/lisp/help.el b/lisp/help.el
index 7289375..4bd9cc1 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -1394,11 +1394,14 @@ help-add-fundoc-usage
  	    (if (string-match "\n?\n\\'" docstring)
  		(if (< (- (match-end 0) (match-beginning 0)) 2) "\n" "")
  	      "\n\n")
-	    (if (stringp arglist)
-                (if (string-match "\\`[^ ]+\\(\\(?:.\\|\n\\)*\\))\\'" 
arglist)
-                    (concat "(fn" (match-string 1 arglist) ")")
-                  (error "Unrecognized usage format"))
-	      (help--make-usage-docstring 'fn arglist)))))
+            (replace-regexp-in-string
+             "\n" "\\n"
+             (if (stringp arglist)
+                 (if (string-match "\\`[^ ]+\\(\\(?:.\\|\n\\)*\\))\\'" 
arglist)
+                     (concat "(fn" (match-string 1 arglist) ")")
+                   (error "Unrecognized usage format"))
+               (help--make-usage-docstring 'fn arglist))
+             t t))))

  (defun help-function-arglist (def &optional preserve-names)
    "Return a formal argument list for the function DEF.




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

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20160509235343.17047.73943@vcs.savannah.gnu.org>
     [not found] ` <20160509235343.759D0220128@vcs.savannah.gnu.org>
2016-05-10  1:34   ` [Emacs-diffs] emacs-25 d0d9f55: Allow newlines inside cl function arglists Stefan Monnier
2016-05-10 10:11     ` Dmitry Gutov [this message]
2016-05-10 10:21       ` Andreas Schwab
2016-05-10 10:31         ` Dmitry Gutov
2016-05-10 11:27           ` Andreas Schwab
2016-05-10 11:33             ` Dmitry Gutov
2016-05-10 11:57               ` Andreas Schwab
2016-05-10 12:01                 ` Dmitry Gutov
2016-05-10 12:36                   ` Andreas Schwab
2016-05-10 12:49                     ` Dmitry Gutov
2016-05-10 21:14                       ` Stefan Monnier
2016-05-10 21:26                         ` Dmitry Gutov
2016-05-11  0:39                           ` Dmitry Gutov
2016-05-11 22:40                             ` Dmitry Gutov
2016-05-11  1:47   ` John Wiegley
2016-05-12 19:23     ` Eli Zaretskii
2016-05-12 21:23       ` John Wiegley
2016-05-13  8:47         ` Eli Zaretskii
2016-05-13 16:26           ` John Wiegley
2016-05-12 21:35     ` Removing bugs from the blockers Dmitry Gutov
2016-05-13  8:36       ` Eli Zaretskii
2016-05-13 10:30         ` Lars Ingebrigtsen
2016-05-13 14:12           ` Eli Zaretskii
2016-05-13 16:28             ` John Wiegley
2016-05-13 20:20             ` Lars Ingebrigtsen
2016-05-16 17:51               ` Eli Zaretskii
2016-05-13 12:48         ` Dmitry Gutov
2016-05-13 16:33         ` John Wiegley
2016-06-09 13:04         ` Nix
2016-06-09 21:09           ` bug#21182 (was Removing bugs from the blockers) Mike Kupfer
2016-06-10 11:33             ` Nix
2016-05-13 11:30       ` Removing bugs from the blockers Kaushal Modi
2016-05-13 11:38         ` Dmitry Gutov

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

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

  git send-email \
    --in-reply-to=a0fdb9ea-c2d0-a9df-6ec7-0e843b96a99a@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@IRO.UMontreal.CA \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.