summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien <bzg@gnu.org>2020-02-10 23:22:51 +0100
committerBastien <bzg@gnu.org>2020-02-10 23:22:51 +0100
commitceb80863015840d91f21283ab435a4dcbc584f0b (patch)
treeef4415daed7910edbd94840d0cae417ebd3d5183
parentd9b586ce34bafc4c6b9746bc5b966c1c226bed5d (diff)
downloadorg-mode-ceb80863015840d91f21283ab435a4dcbc584f0b.tar.gz
Small refactoring
* lisp/org-macs.el (org-scroll): New function. * lisp/ox.el (org-export--dispatch-action): * lisp/org-agenda.el (org-agenda-get-restriction-and-command): Use the new function.
-rw-r--r--lisp/org-agenda.el18
-rw-r--r--lisp/org-macs.el24
-rw-r--r--lisp/ox.el18
3 files changed, 26 insertions, 34 deletions
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index d03923e..68b7907 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -3134,23 +3134,7 @@ s Search for keywords M Like m, but only TODO entries
""))
(setq c (read-char-exclusive)))
until (not (memq c '(14 16 ?\s ?\d)))
- do (cl-case c
- (14 (if (not (pos-visible-in-window-p (point-max)))
- (ignore-errors (scroll-up 1))
- (message "End of buffer")
- (sit-for 1)))
- (16 (if (not (pos-visible-in-window-p (point-min)))
- (ignore-errors (scroll-down 1))
- (message "Beginning of buffer")
- (sit-for 1)))
- (?\s (if (not (pos-visible-in-window-p (point-max)))
- (scroll-up nil)
- (message "End of buffer")
- (sit-for 1)))
- (?\d (if (not (pos-visible-in-window-p (point-min)))
- (scroll-down nil)
- (message "Beginning of buffer")
- (sit-for 1)))))
+ do (org-scroll c))
(message "")
(cond
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index c1aef0c..0d7c2c6 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -1202,6 +1202,30 @@ 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)))
+ (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)))))
+
(provide 'org-macs)
diff --git a/lisp/ox.el b/lisp/ox.el
index 22cf1d5..c3ecb66 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -6904,23 +6904,7 @@ options as CDR."
(while (and (setq key (read-char-exclusive prompt))
(not expertp)
(memq key '(14 16 ?\s ?\d)))
- (cl-case key
- (14 (if (not (pos-visible-in-window-p (point-max)))
- (ignore-errors (scroll-up 1))
- (message "End of buffer")
- (sit-for 1)))
- (16 (if (not (pos-visible-in-window-p (point-min)))
- (ignore-errors (scroll-down 1))
- (message "Beginning of buffer")
- (sit-for 1)))
- (?\s (if (not (pos-visible-in-window-p (point-max)))
- (scroll-up nil)
- (message "End of buffer")
- (sit-for 1)))
- (?\d (if (not (pos-visible-in-window-p (point-min)))
- (scroll-down nil)
- (message "Beginning of buffer")
- (sit-for 1)))))
+ (org-scroll key))
(cond
;; Ignore undefined associations.
((not (memq key allowed-keys))