emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Rudolf Adamkovič" <salutis@me.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Salih Muhammed <lr0@gmx.com>, emacs-orgmode@gnu.org
Subject: Re: Consider removing newlines from org-insert-link help message
Date: Mon, 11 Dec 2023 00:25:00 +0100	[thread overview]
Message-ID: <m27cllsks3.fsf@me.com> (raw)
In-Reply-To: <87edfuqhgt.fsf@localhost>

[-- Attachment #1: Type: text/plain, Size: 166 bytes --]

Ihor Radchenko <yantar92@posteo.net> writes:

> You can just use `org-format-prompt'.

TIL!  Updated.

Thank you!

P.S. I have also updated the commit message.

Rudy

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-link-Improve-UX-of-org-insert-link.patch --]
[-- Type: text/x-patch, Size: 3299 bytes --]

From aa947b42186fca813d3fcc702f7f5daa554980f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= <salutis@me.com>
Date: Sun, 10 Dec 2023 00:51:31 +0100
Subject: [PATCH] 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.
---
 lisp/ol.el | 40 +++++++++++++++++++++++++++++-----------
 1 file changed, 29 insertions(+), 11 deletions(-)

diff --git a/lisp/ol.el b/lisp/ol.el
index c38a30378..bd89415e8 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1868,16 +1868,34 @@ 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
+                  (cons "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
+                           (cons "\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 +1910,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)
-- 
2.39.3 (Apple Git-145)


[-- Attachment #3: Type: text/plain, Size: 301 bytes --]

-- 
"Mathematics takes us still further from what is human into the region
of absolute necessity, to which not only the actual world, but every
possible world, must conform."  --- Bertrand Russell, 1902

Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia

  reply	other threads:[~2023-12-10 23:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-17  6:00 Consider removing newlines from org-insert-link help message Salih Muhammed
2023-10-17 10:53 ` Ihor Radchenko
2023-10-17 21:44   ` Salih Muhammed
2023-10-18 10:43     ` Ihor Radchenko
2023-10-20 11:01     ` Rudolf Adamkovič
2023-10-20 12:30       ` Ihor Radchenko
2023-12-10  0:22         ` Rudolf Adamkovič
2023-12-10 14:07           ` Ihor Radchenko
2023-12-10 23:25             ` Rudolf Adamkovič [this message]
2023-12-11 11:30               ` Ihor Radchenko
2023-12-17 23:36                 ` Rudolf Adamkovič
2024-01-18  5:13                 ` Salih Muhammed
2024-01-18 12:41                   ` Ihor Radchenko

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=m27cllsks3.fsf@me.com \
    --to=salutis@me.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=lr0@gmx.com \
    --cc=yantar92@posteo.net \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).