all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#39842: [PATCH] Use help-fns-short-filename in other describe- commands
@ 2020-02-29 19:00 Štěpán Němec
  2020-02-29 20:02 ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Štěpán Němec @ 2020-02-29 19:00 UTC (permalink / raw)
  To: 39842; +Cc: monnier

The commit

2015-01-16T22:52:15-05:00!monnier@iro.umontreal.ca
24b7f77581
(Improve handling of doc-strings and describe-function for cl-generic)

added 'help-fns-short-filename', which provides file name shortening
smarter than a simple 'file-name-nondirectory' call, but besides the
generic/eieio functions ('cl--generic-describe', 'cl--describe-class',
'eieio-help-constructor'), it is currently only used by
'describe-function' (via 'help-fns-function-description-header').

Make the other help commands use it, too.

(Other than the obvious consistency/maintenance argument, my immediate
motivation for this change is the possibility to customize the file
name abbreviation by advising the function.)

* lisp/help-fns.el (help-fns-short-filename): Autoload.
(describe-variable) (describe-face) (describe-keymap):
Use 'help-fns-short-filename'.
* lisp/help.el (describe-mode): Declare and use 'help-fns-short-filename'.
---
 lisp/help-fns.el | 7 ++++---
 lisp/help.el     | 3 ++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 36c2a8b186..e204be72ad 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -661,6 +661,7 @@ help-fns--mention-first-release
         (insert (format "  Probably introduced at or before Emacs version %s.\n"
                         first))))))
 
+;;;###autoload
 (defun help-fns-short-filename (filename)
   (let* ((abbrev (abbreviate-file-name filename))
          (short abbrev))
@@ -968,7 +969,7 @@ describe-variable
                                    " is a variable defined in `%s'.\n"
                                    (if (eq file-name 'C-source)
                                        "C source code"
-                                     (file-name-nondirectory file-name))))
+                                     (help-fns-short-filename file-name))))
 		           (with-current-buffer standard-output
 		             (save-excursion
 			       (re-search-backward (substitute-command-keys
@@ -1350,7 +1351,7 @@ describe-face
 	      (setq file-name (find-lisp-object-file-name f 'defface))
 	      (when file-name
 		(princ (substitute-command-keys "Defined in `"))
-		(princ (file-name-nondirectory file-name))
+		(princ (help-fns-short-filename file-name))
 		(princ (substitute-command-keys "'"))
 		;; Make a hyperlink to the library.
 		(save-excursion
@@ -1642,7 +1643,7 @@ describe-keymap
                       " defined in `%s'.\n\n"
                       (if (eq file-name 'C-source)
                           "C source code"
-                        (file-name-nondirectory file-name))))
+                        (help-fns-short-filename file-name))))
               (save-excursion
                 (re-search-backward (substitute-command-keys
                                      "`\\([^`']+\\)'")
diff --git a/lisp/help.el b/lisp/help.el
index 45cbaad4e8..32204d04e3 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -879,6 +879,7 @@ describe-key
             (princ ", which is ")
 	    (describe-function-1 defn)))))))
 \f
+(declare-function help-fns-short-filename "help-fns" (filename))
 (defun describe-mode (&optional buffer)
   "Display documentation of current major mode and minor modes.
 A brief summary of the minor modes comes first, followed by the
@@ -975,7 +976,7 @@ describe-mode
 	       (file-name (find-lisp-object-file-name mode nil)))
 	  (when file-name
 	    (princ (format-message " defined in `%s'"
-                                   (file-name-nondirectory file-name)))
+                                   (help-fns-short-filename file-name)))
 	    ;; Make a hyperlink to the library.
 	    (with-current-buffer standard-output
 	      (save-excursion
-- 
2.25.1






^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-03-03 15:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-29 19:00 bug#39842: [PATCH] Use help-fns-short-filename in other describe- commands Štěpán Němec
2020-02-29 20:02 ` Stefan Monnier
2020-02-29 20:18   ` Štěpán Němec
2020-02-29 20:29     ` Stefan Monnier
2020-02-29 20:40       ` Štěpán Němec
2020-02-29 21:07         ` Stefan Monnier
2020-02-29 21:47           ` Štěpán Němec
2020-03-03 15:53             ` Stefan Monnier

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.