diff options
| author | Rudolf Adamkovič <salutis@me.com> | 2023-12-10 00:51:31 +0100 |
|---|---|---|
| committer | Ihor Radchenko <yantar92@posteo.net> | 2023-12-11 12:28:32 +0100 |
| commit | 664ffde1494fe07559c36bd219864b60074a689a (patch) | |
| tree | c42ba8277e81b71825ba7e8dd90974657c1f167d | |
| parent | b77f991c02ace5b62026a2f38eb5c16f9a161be6 (diff) | |
| download | org-mode-664ffde14.tar.gz | |
org-link: Improve UX of 'org-insert-link'
* lisp/ol.el (org-insert-link): Shorten the text in the *Org Links*
buffer to avoid unnecessary line breaks, reword it to better align
with the rest of Emacs, and propertize its key bindings to improve
readability. Further, move the default link to the minibuffer, as
seen elsewhere in Emacs, and make the *Org Links* buffer read-only.
| -rw-r--r-- | lisp/ol.el | 38 |
1 files changed, 27 insertions, 11 deletions
@@ -1868,16 +1868,32 @@ non-interactively, don't allow to edit the default description." (org-link--fontify-links-to-this-file) (org-switch-to-buffer-other-window "*Org Links*") (with-current-buffer "*Org Links*" - (erase-buffer) - (insert "Insert a link. -Use TAB to complete link prefixes, then RET for type-specific completion support\n") - (when org-stored-links - (insert "\nStored links are available with <up>/<down> or M-p/n \ -\(most recent with RET):\n\n") - (insert (mapconcat #'org-link--prettify - (reverse org-stored-links) - "\n"))) - (goto-char (point-min))) + (read-only-mode 1) + (let ((inhibit-read-only t) + ;; FIXME Duplicate: Also in 'ox.el'. + (propertize-help-key + (lambda (key) + ;; Add `face' *and* `font-lock-face' to "work + ;; reliably in any buffer", per a comment in + ;; `help--key-description-fontified'. + (propertize key + 'font-lock-face 'help-key-binding + 'face 'help-key-binding)))) + (erase-buffer) + (insert + (apply #'format "Type %s to complete link type, then %s to complete destination.\n" + (mapcar propertize-help-key + (list "TAB" "RET")))) + (when org-stored-links + (insert (apply #'format "\nStored links accessible with %s/%s or %s/%s are:\n\n" + (mapcar propertize-help-key + (list "<up>" "<down>" + "M-p" "M-n" + "RET")))) + (insert (mapconcat #'org-link--prettify + (reverse org-stored-links) + "\n")))) + (goto-char (point-min))) (when (get-buffer-window "*Org Links*" 'visible) (let ((cw (selected-window))) (select-window (get-buffer-window "*Org Links*" 'visible)) @@ -1892,7 +1908,7 @@ Use TAB to complete link prefixes, then RET for type-specific completion support org-link--insert-history))) (setq link (org-completing-read - "Link: " + (org-format-prompt "Insert link" (caar org-stored-links)) (append (mapcar (lambda (x) (concat x ":")) all-prefixes) (mapcar #'car org-stored-links) |
