summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien <bzg@gnu.org>2020-02-11 01:04:28 +0100
committerBastien <bzg@gnu.org>2020-02-11 01:04:28 +0100
commit2508dfa6443fc41157fe060c6111bcdf52996dc6 (patch)
treef2a5a5f70cbbfb9848da66d9cab189bea406bd4b
parent185e184e15e763918a40e5f2c6e8fc4739ef21d0 (diff)
downloadorg-mode-2508dfa6443fc41157fe060c6111bcdf52996dc6.tar.gz
Factor out org-scroll and use it in ox.el, org-agenda/attach.el
* lisp/ox.el (org-export--dispatch-ui): Update message in the header line to promote the use of C-v and M-v while SPC and DEL are still allowed for backward compatibility reasons. * lisp/org-macs.el (org-scroll): New function. * lisp/org-attach.el (org-attach): Use `org-scroll'. * lisp/org-agenda.el (org-agenda-get-restriction-and-command): Allow C-v, M-v, C-n and C-p to scroll. This change adverize C-v, M-v, C-n and C-p as the default keys for scrolling the window, while SPC and DEL are still available in the export dispatch window. In particular, don't use SPC as a way to scroll the window in the agenda commands dispatch window, as this key might be used for a custom agenda command.
-rw-r--r--lisp/org-agenda.el4
-rw-r--r--lisp/org-attach.el16
-rw-r--r--lisp/org-macs.el49
-rw-r--r--lisp/ox.el4
4 files changed, 37 insertions, 36 deletions
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 68b7907..fc9cb0b 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -3119,7 +3119,7 @@ s Search for keywords M Like m, but only TODO entries
;; Hint to navigation if window too small for all information
(setq header-line-format
(when (not (pos-visible-in-window-p (point-max)))
- "Use SPC, DEL, C-n or C-p to navigate."))
+ "Use C-v, M-v, C-n or C-p to navigate."))
;; Ask for selection
(cl-loop
@@ -3133,7 +3133,7 @@ s Search for keywords M Like m, but only TODO entries
" (unrestricted)"))
""))
(setq c (read-char-exclusive)))
- until (not (memq c '(14 16 ?\s ?\d)))
+ until (not (memq c '(14 16 22 134217846)))
do (org-scroll c))
(message "")
diff --git a/lisp/org-attach.el b/lisp/org-attach.el
index 0fac627..b8575cc 100644
--- a/lisp/org-attach.el
+++ b/lisp/org-attach.el
@@ -263,7 +263,7 @@ Shows a list of commands and prompts for another key to execute a command."
(switch-to-buffer-other-window (get-buffer-create "*Org Attach*"))
(erase-buffer)
(setq cursor-type nil
- header-line-format "Use SPC, DEL, C-n or C-p to navigate.")
+ header-line-format "Use C-v, M-v, C-n or C-p to navigate.")
(insert
(concat "Attachment folder:\n"
(or dir
@@ -290,16 +290,12 @@ Shows a list of commands and prompts for another key to execute a command."
"\n")))))
(org-fit-window-to-buffer (get-buffer-window "*Org Attach*"))
(let ((msg (format "Select command: [%s]"
- (concat (mapcar #'caar org-attach-commands)))))
+ (concat (mapcar #'caar org-attach-commands))))
+ key)
(message msg)
- (setq c (read-char-exclusive))
- (while (memq c '(14 16 32 127))
- (cond ((= c 14) (ignore-errors (call-interactively 'scroll-up-line)))
- ((= c 16) (ignore-errors (call-interactively 'scroll-down-line)))
- ((= c 32) (ignore-errors (call-interactively 'scroll-up)))
- ((= c 127) (ignore-errors (call-interactively 'scroll-down))))
- (message msg)
- (setq c (read-char-exclusive))))
+ (while (and (setq key (read-char-exclusive prompt))
+ (memq key '(14 16 22 134217846)))
+ (org-scroll key t)))
(and (get-buffer "*Org Attach*") (kill-buffer "*Org Attach*"))))
(let ((command (cl-some (lambda (entry)
(and (memq c (nth 0 entry)) (nth 1 entry)))
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index 0d7c2c6..1e3ce48 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -1202,31 +1202,36 @@ Return 0. if S is not recognized as a valid value."
((string-match org-ts-regexp0 s) (org-2ft s))
(t 0.)))))
-(defun org-scroll (key)
- "Receive KEY and scroll the current window accordingly."
- (cl-case key
- ;; C-n
- (14 (if (not (pos-visible-in-window-p (point-max)))
- (ignore-errors (scroll-up 1))
- (message "End of buffer")
- (sit-for 1)))
- ;; C-p
- (16 (if (not (pos-visible-in-window-p (point-min)))
- (ignore-errors (scroll-down 1))
- (message "Beginning of buffer")
- (sit-for 1)))
- ;; SPC
- (?\s (if (not (pos-visible-in-window-p (point-max)))
+(defun org-scroll (key &optional additional-keys)
+ "Receive KEY and scroll the current window accordingly.
+When ADDITIONAL-KEYS is not nil, also include SPC and DEL in the
+allowed keys for scrolling, as expected in the export dispatch
+window."
+ (let ((scrlup (if additional-keys '(?\s 22) 22))
+ (scrldn (if additional-keys `(?\d 134217846) 134217846)))
+ (eval
+ `(case ,key
+ ;; C-n
+ (14 (if (not (pos-visible-in-window-p (point-max)))
+ (ignore-errors (scroll-up 1))
+ (message "End of buffer")
+ (sit-for 1)))
+ ;; C-p
+ (16 (if (not (pos-visible-in-window-p (point-min)))
+ (ignore-errors (scroll-down 1))
+ (message "Beginning of buffer")
+ (sit-for 1)))
+ ;; SPC or
+ (,scrlup
+ (if (not (pos-visible-in-window-p (point-max)))
(scroll-up nil)
(message "End of buffer")
(sit-for 1)))
- ;; DEL
- (?\d (if (not (pos-visible-in-window-p (point-min)))
- (scroll-down nil)
- (message "Beginning of buffer")
- (sit-for 1)))))
-
-
+ ;; DEL
+ (,scrldn (if (not (pos-visible-in-window-p (point-min)))
+ (scroll-down nil)
+ (message "Beginning of buffer")
+ (sit-for 1)))))))
(provide 'org-macs)
diff --git a/lisp/ox.el b/lisp/ox.el
index 5d39b4c..80e3f7e 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -6864,7 +6864,7 @@ back to standard interface."
(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.")
+ header-line-format "Use C-v, M-v, C-n or C-p to navigate.")
;; Make sure that invisible cursor will not highlight square
;; brackets.
(set-syntax-table (copy-syntax-table))
@@ -6901,7 +6901,7 @@ options as CDR."
(while (and (setq key (read-char-exclusive prompt))
(not expertp)
(memq key '(14 16 ?\s ?\d)))
- (org-scroll key))
+ (org-scroll key t))
(cond
;; Ignore undefined associations.
((not (memq key allowed-keys))