From 4f8a2758cbd78fb43f45c7c7502847b8025d6f93 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Tue, 27 Apr 2021 17:26:11 +0200 Subject: [PATCH] ol: Factorize "help" link store function * lisp/ol.el (org-link--store-help): New function. (org-store-link): Do not hard-code "help" links. Use regular `org-link-set-parameters' process. --- lisp/ol.el | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/lisp/ol.el b/lisp/ol.el index 706a83884..aa8e6b049 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -1329,7 +1329,23 @@ PATH is a symbol name, as a string." ((and (pred boundp) function) (describe-variable function)) (name (user-error "Unknown function or variable: %s" name)))) -(org-link-set-parameters "help" :follow #'org-link--open-help) +(defun org-link--store-help () + (when (eq major-mode 'help-mode) + (let ((symbol + (replace-regexp-in-string + ;; Help mode escapes backquotes and backslashes before + ;; displaying them. E.g., "`" appears as "\'" for + ;; reasons. Work around this. + (rx "\\" (group (or "`" "\\"))) "\\1" + (save-excursion + (goto-char (point-min)) + (re-search-forward "\\S_" (line-end-position) t) + (buffer-substring (point-min) (point)))))) + (org-link-store-props :type "help" :link (concat "help:" symbol))))) + +(org-link-set-parameters "help" + :follow #'org-link--open-help + :store #'org-link--store-help) ;;;; "http", "https", "mailto", "ftp", and "news" link types (dolist (scheme '("ftp" "http" "https" "mailto" "news")) @@ -1546,19 +1562,6 @@ non-nil." nil nil nil)))) (org-link-store-props :type "calendar" :date cd))) - ((eq major-mode 'help-mode) - (let ((symbol (replace-regexp-in-string - ;; Help mode escapes backquotes and backslashes - ;; before displaying them. E.g., "`" appears - ;; as "\'" for reasons. Work around this. - (rx "\\" (group (or "`" "\\"))) "\\1" - (save-excursion - (goto-char (point-min)) - (looking-at "^[^ ]+") - (match-string 0))))) - (setq link (concat "help:" symbol))) - (org-link-store-props :type "help")) - ((eq major-mode 'w3-mode) (setq cpltxt (if (and (buffer-name) (not (string-match "Untitled" (buffer-name))))