emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Propertize some navigational keybindings
@ 2022-10-07 15:09 Rudolf Adamkovič
  2022-10-08  7:03 ` Ihor Radchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Rudolf Adamkovič @ 2022-10-07 15:09 UTC (permalink / raw)
  To: emacs-orgmode

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

Howdy, howdy!

Please review the attached patch that propertizes (i.e. adds style to)
the navigational keybindings displayed in the header of the Org Export
dispatch UI.

Thank you!

Rudy

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Propertize-keybindings-in-Org-Export-dispatch-UI.patch --]
[-- Type: text/x-patch, Size: 1228 bytes --]

From bfe0018037ba8ccfe961d7bd4c0b985bd7496898 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= <salutis@me.com>
Date: Fri, 7 Oct 2022 17:05:15 +0200
Subject: [PATCH] Propertize keybindings in Org Export dispatch UI

* lisp/ox.el (org-export--dispatch-ui): Propertize the keybindings
---
 lisp/ox.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lisp/ox.el b/lisp/ox.el
index 95268d3e3..4285cfc0f 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -7123,8 +7123,13 @@ back to standard interface."
 	(delete-other-windows)
 	(org-switch-to-buffer-other-window
 	 (get-buffer-create "*Org Export Dispatcher*"))
-	(setq cursor-type nil
-	      header-line-format "Use SPC, DEL, C-n or C-p to navigate.")
+	(setq cursor-type nil)
+        (setq header-line-format
+              (apply 'format
+                     (cons "Use %s, %s, %s, or %s to navigate."
+                           (mapcar (lambda (key)
+                                     (propertize key 'face 'help-key-binding))
+                                   (list "SPC" "DEL" "C-n" "C-p")))))
 	;; Make sure that invisible cursor will not highlight square
 	;; brackets.
 	(set-syntax-table (copy-syntax-table))
-- 
2.37.3


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

-- 
"Chop your own wood and it will warm you twice."
-- Henry Ford; Francis Kinloch, 1819; Henry David Thoreau, 1854

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

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

* Re: Propertize some navigational keybindings
  2022-10-07 15:09 Propertize some navigational keybindings Rudolf Adamkovič
@ 2022-10-08  7:03 ` Ihor Radchenko
  2022-10-08 20:42   ` Rudolf Adamkovič
  0 siblings, 1 reply; 5+ messages in thread
From: Ihor Radchenko @ 2022-10-08  7:03 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: emacs-orgmode

Rudolf Adamkovič <salutis@me.com> writes:

> Howdy, howdy!
>
> Please review the attached patch that propertizes (i.e. adds style to)
> the navigational keybindings displayed in the header of the Org Export
> dispatch UI.

Thanks!

> +	(setq cursor-type nil)
> +        (setq header-line-format
> +              (apply 'format
> +                     (cons "Use %s, %s, %s, or %s to navigate."
> +                           (mapcar (lambda (key)
> +                                     (propertize key 'face 'help-key-binding))
> +                                   (list "SPC" "DEL" "C-n" "C-p")))))

I think that the most thorough way to add this feature is following what
`help--key-description-fontified' does (we should not call this internal
function though):

(defun help--key-description-fontified (keys &optional prefix)
  "Like `key-description' but add face for \"*Help*\" buffers.
KEYS is the return value of `(where-is-internal \\='foo-cmd nil t)'.
Return nil if KEYS is nil."
  (when keys
    ;; We add both the `font-lock-face' and `face' properties here, as this
    ;; seems to be the only way to get this to work reliably in any
    ;; buffer.
    (propertize (key-description keys prefix)
                'font-lock-face 'help-key-binding
                'face 'help-key-binding)))

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

* Re: Propertize some navigational keybindings
  2022-10-08  7:03 ` Ihor Radchenko
@ 2022-10-08 20:42   ` Rudolf Adamkovič
  2022-10-09  7:47     ` Ihor Radchenko
  2022-10-09  7:48     ` Ihor Radchenko
  0 siblings, 2 replies; 5+ messages in thread
From: Rudolf Adamkovič @ 2022-10-08 20:42 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

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

Ihor Radchenko <yantar92@gmail.com> writes:

> I think that the most thorough way to add this feature is following
> what `help--key-description-fontified' does (we should not call this
> internal function though): [...]

How about the attached patch?

Rudy


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-export-Propertize-keybindings-in-Org-Export-disp.patch --]
[-- Type: text/x-patch, Size: 1658 bytes --]

From edc5dde6d3a68e15491a0273d283e38482e6390e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= <salutis@me.com>
Date: Fri, 7 Oct 2022 17:05:15 +0200
Subject: [PATCH] org-export: Propertize keybindings in Org Export dispatch UI

* lisp/ox.el (org-export--dispatch-ui): Propertize the navigational
keybindings.
---
 lisp/ox.el | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/lisp/ox.el b/lisp/ox.el
index e059983fb..6089a575b 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -7123,8 +7123,20 @@ back to standard interface."
 	(delete-other-windows)
 	(org-switch-to-buffer-other-window
 	 (get-buffer-create "*Org Export Dispatcher*"))
-	(setq cursor-type nil
-	      header-line-format "Use SPC, DEL, C-n or C-p to navigate.")
+        (setq cursor-type nil)
+        (setq header-line-format
+              (let ((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))))
+                (apply 'format
+                       (cons "Use %s, %s, %s, or %s to navigate."
+                             (mapcar propertize-help-key
+                                     (list "SPC" "DEL" "C-n" "C-p"))))))
 	;; Make sure that invisible cursor will not highlight square
 	;; brackets.
 	(set-syntax-table (copy-syntax-table))
-- 
2.38.0


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

-- 
"One can begin to reason only when a clear picture has been formed in
the imagination."
-- Walter Warwick Sawyer, Mathematician's Delight, 1943

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

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

* Re: Propertize some navigational keybindings
  2022-10-08 20:42   ` Rudolf Adamkovič
@ 2022-10-09  7:47     ` Ihor Radchenko
  2022-10-09  7:48     ` Ihor Radchenko
  1 sibling, 0 replies; 5+ messages in thread
From: Ihor Radchenko @ 2022-10-09  7:47 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: emacs-orgmode

Rudolf Adamkovič <salutis@me.com> writes:

> Ihor Radchenko <yantar92@gmail.com> writes:
>
>> I think that the most thorough way to add this feature is following
>> what `help--key-description-fontified' does (we should not call this
>> internal function though): [...]
>
> How about the attached patch?

Thanks!
Applied onto main.
https://orgmode.org/worg/org-contribute.html#first-patch


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

* Re: Propertize some navigational keybindings
  2022-10-08 20:42   ` Rudolf Adamkovič
  2022-10-09  7:47     ` Ihor Radchenko
@ 2022-10-09  7:48     ` Ihor Radchenko
  1 sibling, 0 replies; 5+ messages in thread
From: Ihor Radchenko @ 2022-10-09  7:48 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: emacs-orgmode

Rudolf Adamkovič <salutis@me.com> writes:

> Ihor Radchenko <yantar92@gmail.com> writes:
>
>> I think that the most thorough way to add this feature is following
>> what `help--key-description-fontified' does (we should not call this
>> internal function though): [...]
>
> How about the attached patch?

Thanks!
Applied onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e7feeb2225b59e6434881cb7bc425c6be650a08e


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

end of thread, other threads:[~2022-10-09  7:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-07 15:09 Propertize some navigational keybindings Rudolf Adamkovič
2022-10-08  7:03 ` Ihor Radchenko
2022-10-08 20:42   ` Rudolf Adamkovič
2022-10-09  7:47     ` Ihor Radchenko
2022-10-09  7:48     ` Ihor Radchenko

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).