forked from mirrors/org-mode
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.
This commit is contained in:
parent
185e184e15
commit
2508dfa644
|
@ -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 "")
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue