[PATCH v2 16/23] emacs: inline notmuch-documentation-first-line

Subject: [PATCH v2 16/23] emacs: inline notmuch-documentation-first-line

Date: Mon, 16 Nov 2020 22:28:36 +0100

To: notmuch@notmuchmail.org

Cc:

From: Jonas Bernoulli


Inline a simplified version of `notmuch-documentation-first-line'
into its only caller.  The new code snippet differs from the
removed function in that it returns nil instead of the empty string
for symbols that have no function documentation.  That value is
ultimately used as an argument to `concat', which treats nil like
the empty string.  So we can do the logical thing without changing
the behavior.
---
 emacs/notmuch-lib.el | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index d7c6b737..61107e38 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -287,18 +287,6 @@ (defun notmuch-bury-or-kill-this-buffer ()
       (bury-buffer)
     (kill-buffer)))
 
-(defun notmuch-documentation-first-line (symbol)
-  "Return the first line of the documentation string for SYMBOL."
-  (let ((doc (documentation symbol)))
-    (if doc
-	(with-temp-buffer
-	  (insert (documentation symbol t))
-	  (goto-char (point-min))
-	  (let ((beg (point)))
-	    (end-of-line)
-	    (buffer-substring beg (point))))
-      "")))
-
 (defun notmuch-prefix-key-description (key)
   "Given a prefix key code, return a human-readable string representation.
 
@@ -331,7 +319,10 @@ (defun notmuch-describe-key (actual-key binding prefix ua-keys tail)
 		  (or (and (symbolp binding)
 			   (get binding 'notmuch-doc))
 		      (and (functionp binding)
-			   (notmuch-documentation-first-line binding))))
+			   (let ((doc (documentation binding)))
+			     (and doc
+				  (string-match "\\`.+" doc)
+				  (match-string 0 doc))))))
 	    tail)))
   tail)
 
-- 
2.29.1
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: