* Suggested patch for org-agenda.el
@ 2019-05-06 23:07 Stefan Monnier
2019-05-08 12:43 ` Nicolas Goaziou
0 siblings, 1 reply; 2+ messages in thread
From: Stefan Monnier @ 2019-05-06 23:07 UTC (permalink / raw)
To: emacs-orgmode
Misc changes:
- Assume Emacs≥22 (we're using defvaralias already anyway).
- Try to make sure <foo>-function only contain functions (and never nil).
- Use define-minor-mode and define-derived-mode.
- Use command remapping.
- Initialize map from within its definition.
- Use suppress-keymap.
There'd be more to do if we can assume ≥24.1, of course.
Stefan
diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el
index 23ee8d71e6..48e66c7acf 100644
--- a/lisp/org/org-agenda.el
+++ b/lisp/org/org-agenda.el
@@ -1928,7 +1928,7 @@ org-agenda-fontify-priorities
(string :tag "Color")
(sexp :tag "Face"))))))
-(defcustom org-agenda-day-face-function nil
+(defcustom org-agenda-day-face-function #'org-agenda--day-face-default
"Function called to determine what face should be used to display a day.
The only argument passed to that function is the day. It should
returns a face, or nil if does not want to specify a face and let
@@ -2067,10 +2067,6 @@ org-add-agenda-custom-command
;;; Define the org-agenda-mode
-(defvaralias 'org-agenda-keymap 'org-agenda-mode-map)
-(defvar org-agenda-mode-map (make-sparse-keymap)
- "Keymap for `org-agenda-mode'.")
-
(defvar org-agenda-menu) ; defined later in this file.
(defvar org-agenda-restrict nil) ; defined later in this file.
(defvar org-agenda-follow-mode nil)
@@ -2094,31 +2090,16 @@ org-agenda-current-date
;;; Multiple agenda buffers support
-(defcustom org-agenda-sticky nil
- "Non-nil means agenda q key will bury agenda buffers.
-Agenda commands will then show existing buffer instead of generating new ones.
-When nil, `q' will kill the single agenda buffer."
- :group 'org-agenda
- :version "24.3"
- :type 'boolean)
-
+(define-obsolete-variable-alias 'org-agenda-sticky 'org-agenda-sticky-mode "27.1")
\f
;;;###autoload
-(defun org-toggle-sticky-agenda (&optional arg)
- "Toggle `org-agenda-sticky'."
- (interactive "P")
- (let ((new-value (if arg
- (> (prefix-numeric-value arg) 0)
- (not org-agenda-sticky))))
- (if (equal new-value org-agenda-sticky)
- (and (called-interactively-p 'interactive)
- (message "Sticky agenda was already %s"
- (if org-agenda-sticky "enabled" "disabled")))
- (setq org-agenda-sticky new-value)
- (org-agenda-kill-all-agenda-buffers)
- (and (called-interactively-p 'interactive)
- (message "Sticky agenda %s"
- (if org-agenda-sticky "enabled" "disabled"))))))
+(define-obsolete-function-alias 'org-toggle-sticky-agenda #'org-agenda-sticky-mode "27.1")
+(define-minor-mode org-agenda-sticky-mode
+ "When enabled, agenda `q' key will bury agenda buffers.
+Agenda commands will then show existing buffer instead of generating new ones.
+When this minor mode is disabled, `q' will kill the single agenda buffer."
+ :global t
+ (org-agenda-kill-all-agenda-buffers))
(defvar org-agenda-buffer nil
"Agenda buffer currently being generated.")
@@ -2159,51 +2140,191 @@ org-agenda-local-vars
org-agenda-cycle-counter
org-agenda-last-prefix-arg)
"Variables that must be local in agenda buffers to allow multiple buffers.")
+(dolist (var org-agenda-local-vars)
+ (put var 'permanant-local t))
+
+(defvaralias 'org-agenda-keymap 'org-agenda-mode-map) ;FIXME: Unused!
+(defvar org-agenda-mode-map
+ (let ((map (make-sparse-keymap)))
+ (suppress-keymap map) ;FIXME: Derive from special-mode instead (Emacs≥23).
+ (org-defkey map [remap undo] org-agenda-undo)
+ (org-defkey map "\C-i" 'org-agenda-goto)
+ (org-defkey map [(tab)] 'org-agenda-goto)
+ (org-defkey map "\C-m" 'org-agenda-switch-to)
+ (org-defkey map "\C-k" 'org-agenda-kill)
+ (org-defkey map "\C-c\C-w" 'org-agenda-refile)
+ (org-defkey map [(meta down)] 'org-agenda-drag-line-forward)
+ (org-defkey map [(meta up)] 'org-agenda-drag-line-backward)
+ (org-defkey map "m" 'org-agenda-bulk-mark)
+ (org-defkey map "\M-m" 'org-agenda-bulk-toggle)
+ (org-defkey map "*" 'org-agenda-bulk-mark-all)
+ (org-defkey map "\M-*" 'org-agenda-bulk-toggle-all)
+ (org-defkey map "#" 'org-agenda-dim-blocked-tasks)
+ (org-defkey map "%" 'org-agenda-bulk-mark-regexp)
+ (org-defkey map "u" 'org-agenda-bulk-unmark)
+ (org-defkey map "U" 'org-agenda-bulk-unmark-all)
+ (org-defkey map "B" 'org-agenda-bulk-action)
+ (org-defkey map "k" 'org-agenda-capture)
+ (org-defkey map "A" 'org-agenda-append-agenda)
+ (org-defkey map "\C-c\C-x!" 'org-reload)
+ (org-defkey map "\C-c\C-x\C-a" 'org-agenda-archive-default)
+ (org-defkey map "\C-c\C-xa" 'org-agenda-toggle-archive-tag)
+ (org-defkey map "\C-c\C-xA" 'org-agenda-archive-to-archive-sibling)
+ (org-defkey map "\C-c\C-x\C-s" 'org-agenda-archive)
+ (org-defkey map "\C-c$" 'org-agenda-archive)
+ (org-defkey map "$" 'org-agenda-archive)
+ (org-defkey map "\C-c\C-o" 'org-agenda-open-link)
+ (org-defkey map " " 'org-agenda-show-and-scroll-up)
+ (org-defkey map [backspace] 'org-agenda-show-scroll-down)
+ (org-defkey map "\d" 'org-agenda-show-scroll-down)
+ (org-defkey map [(control shift right)] 'org-agenda-todo-nextset)
+ (org-defkey map [(control shift left)] 'org-agenda-todo-previousset)
+ (org-defkey map "\C-c\C-xb" 'org-agenda-tree-to-indirect-buffer)
+ (org-defkey map "o" 'delete-other-windows)
+ (org-defkey map "L" 'org-agenda-recenter)
+ (org-defkey map "\C-c\C-t" 'org-agenda-todo)
+ (org-defkey map "t" 'org-agenda-todo)
+ (org-defkey map "a" 'org-agenda-archive-default-with-confirmation)
+ (org-defkey map ":" 'org-agenda-set-tags)
+ (org-defkey map "\C-c\C-q" 'org-agenda-set-tags)
+ (org-defkey map "." 'org-agenda-goto-today)
+ (org-defkey map "j" 'org-agenda-goto-date)
+ (org-defkey map "d" 'org-agenda-day-view)
+ (org-defkey map "w" 'org-agenda-week-view)
+ (org-defkey map "y" 'org-agenda-year-view)
+ (org-defkey map "\C-c\C-z" 'org-agenda-add-note)
+ (org-defkey map "z" 'org-agenda-add-note)
+ (org-defkey map [(shift right)] 'org-agenda-do-date-later)
+ (org-defkey map [(shift left)] 'org-agenda-do-date-earlier)
+ (org-defkey map [?\C-c ?\C-x (right)] 'org-agenda-do-date-later)
+ (org-defkey map [?\C-c ?\C-x (left)] 'org-agenda-do-date-earlier)
+
+ (org-defkey map ">" 'org-agenda-date-prompt)
+ (org-defkey map "\C-c\C-s" 'org-agenda-schedule)
+ (org-defkey map "\C-c\C-d" 'org-agenda-deadline)
+
+ (org-defkey map "F" 'org-agenda-follow-mode)
+ (org-defkey map "R" 'org-agenda-clockreport-mode)
+ (org-defkey map "E" 'org-agenda-entry-text-mode)
+ (org-defkey map "l" 'org-agenda-log-mode)
+ (org-defkey map "v" 'org-agenda-view-mode-dispatch)
+ (org-defkey map "D" 'org-agenda-toggle-diary)
+ (org-defkey map "!" 'org-agenda-toggle-deadlines)
+ (org-defkey map "G" 'org-agenda-toggle-time-grid)
+ (org-defkey map "r" 'org-agenda-redo)
+ (org-defkey map "g" 'org-agenda-redo-all)
+ (org-defkey map "e" 'org-agenda-set-effort)
+ (org-defkey map "\C-c\C-xe" 'org-agenda-set-effort)
+ (org-defkey map "\C-c\C-x\C-e" 'org-clock-modify-effort-estimate)
+ (org-defkey map "\C-c\C-xp" 'org-agenda-set-property)
+ (org-defkey map "q" 'org-agenda-quit)
+ (org-defkey map "Q" 'org-agenda-Quit)
+ (org-defkey map "x" 'org-agenda-exit)
+ (org-defkey map "\C-x\C-w" 'org-agenda-write)
+ (org-defkey map "\C-x\C-s" 'org-save-all-org-buffers)
+ (org-defkey map "s" 'org-save-all-org-buffers)
+ (org-defkey map "T" 'org-agenda-show-tags)
+ (org-defkey map "n" 'org-agenda-next-line)
+ (org-defkey map "p" 'org-agenda-previous-line)
+ (org-defkey map "N" 'org-agenda-next-item)
+ (org-defkey map "P" 'org-agenda-previous-item)
+ (org-defkey map [remap next-line] 'org-agenda-next-line)
+ (org-defkey map [remap previous-line] 'org-agenda-previous-line)
+ (org-defkey map "\C-c\C-a" 'org-attach)
+ (org-defkey map "\C-c\C-n" 'org-agenda-next-date-line)
+ (org-defkey map "\C-c\C-p" 'org-agenda-previous-date-line)
+ (org-defkey map "\C-c," 'org-agenda-priority)
+ (org-defkey map "," 'org-agenda-priority)
+ (org-defkey map "i" 'org-agenda-diary-entry)
+ (org-defkey map "c" 'org-agenda-goto-calendar)
+ (org-defkey map "C" 'org-agenda-convert-date)
+ (org-defkey map "M" 'org-agenda-phases-of-moon)
+ (org-defkey map "S" 'org-agenda-sunrise-sunset)
+ (org-defkey map "h" 'org-agenda-holidays)
+ (org-defkey map "H" 'org-agenda-holidays)
+ (org-defkey map "\C-c\C-x\C-i" 'org-agenda-clock-in)
+ (org-defkey map "I" 'org-agenda-clock-in)
+ (org-defkey map "\C-c\C-x\C-o" 'org-agenda-clock-out)
+ (org-defkey map "O" 'org-agenda-clock-out)
+ (org-defkey map "\C-c\C-x\C-x" 'org-agenda-clock-cancel)
+ (org-defkey map "X" 'org-agenda-clock-cancel)
+ (org-defkey map "\C-c\C-x\C-j" 'org-clock-goto)
+ (org-defkey map "J" 'org-agenda-clock-goto)
+ (org-defkey map "+" 'org-agenda-priority-up)
+ (org-defkey map "-" 'org-agenda-priority-down)
+ (org-defkey map [(shift up)] 'org-agenda-priority-up)
+ (org-defkey map [(shift down)] 'org-agenda-priority-down)
+ (org-defkey map [?\C-c ?\C-x (up)] 'org-agenda-priority-up)
+ (org-defkey map [?\C-c ?\C-x (down)] 'org-agenda-priority-down)
+ (org-defkey map "f" 'org-agenda-later)
+ (org-defkey map "b" 'org-agenda-earlier)
+ (org-defkey map "\C-c\C-x\C-c" 'org-agenda-columns)
+ (org-defkey map "\C-c\C-x>" 'org-agenda-remove-restriction-lock)
+ (org-defkey map "\C-c\C-x<" 'org-agenda-set-restriction-lock-from-agenda)
+
+ (org-defkey map "[" 'org-agenda-manipulate-query-add)
+ (org-defkey map "]" 'org-agenda-manipulate-query-subtract)
+ (org-defkey map "{" 'org-agenda-manipulate-query-add-re)
+ (org-defkey map "}" 'org-agenda-manipulate-query-subtract-re)
+ (org-defkey map "/" 'org-agenda-filter-by-tag)
+ (org-defkey map "_" 'org-agenda-filter-by-effort)
+ (org-defkey map "=" 'org-agenda-filter-by-regexp)
+ (org-defkey map "|" 'org-agenda-filter-remove-all)
+ (org-defkey map "~" 'org-agenda-limit-interactively)
+ (org-defkey map "<" 'org-agenda-filter-by-category)
+ (org-defkey map "^" 'org-agenda-filter-by-top-headline)
+ (org-defkey map ";" 'org-timer-set-timer)
+ (org-defkey map "\C-c\C-x_" 'org-timer-stop)
+ (define-key map "?" 'org-agenda-show-the-flagging-note)
+ (org-defkey map "\C-c\C-x\C-mg" 'org-mobile-pull)
+ (org-defkey map "\C-c\C-x\C-mp" 'org-mobile-push)
+
+ (org-defkey map [mouse-2] 'org-agenda-goto-mouse)
+ (org-defkey map [mouse-3] 'org-agenda-show-mouse)
+
+ (define-key map [remap forward-paragraph] 'org-agenda-forward-block)
+ (define-key map [remap backward-paragraph] 'org-agenda-backward-block)
+
+ (when org-agenda-mouse-1-follows-link
+ (org-defkey map [follow-link] 'mouse-face))
+ map)
+ "Keymap for `org-agenda-mode'.")
-(defun org-agenda-mode ()
+(define-derived-mode org-agenda-mode fundamental-mode "Org-Agenda"
+ ;; FIXME: Derive from special-mode (Emacs≥23)
"Mode for time-sorted view on action items in Org files.
The following commands are available:
\\{org-agenda-mode-map}"
- (interactive)
(cond (org-agenda-doing-sticky-redo
;; Refreshing sticky agenda-buffer
- ;;
- ;; Preserve the value of `org-agenda-local-vars' variables,
- ;; while letting `kill-all-local-variables' kill the rest
- (let ((save (buffer-local-variables)))
- (kill-all-local-variables)
- (mapc #'make-local-variable org-agenda-local-vars)
- (dolist (elem save)
- (pcase elem
- (`(,var . ,val) ;ignore unbound variables
- (when (and val (memq var org-agenda-local-vars))
- (set var val))))))
(setq-local org-agenda-this-buffer-is-sticky t))
(org-agenda-sticky
;; Creating a sticky Agenda buffer for the first time
- (kill-all-local-variables)
- (mapc 'make-local-variable org-agenda-local-vars)
+ ;; FIXME: Not sure if kill-local-variable is needed since it's
+ ;; presumably a "new" buffer, but the old code uses
+ ;; non-permanent-local vars, so this better reproduces the
+ ;; old behavior.
+ (mapc #'kill-local-variable org-agenda-local-vars)
+ (mapc #'make-local-variable org-agenda-local-vars)
(setq-local org-agenda-this-buffer-is-sticky t))
(t
;; Creating a non-sticky agenda buffer
(kill-all-local-variables)
+ (mapc #'kill-local-variable org-agenda-local-vars)
(setq-local org-agenda-this-buffer-is-sticky nil)))
(setq org-agenda-undo-list nil
org-agenda-pending-undo-list nil
org-agenda-bulk-marked-entries nil)
- (setq major-mode 'org-agenda-mode)
;; Keep global-font-lock-mode from turning on font-lock-mode
(setq-local font-lock-global-modes (list 'not major-mode))
- (setq mode-name "Org-Agenda")
(setq indent-tabs-mode nil)
- (use-local-map org-agenda-mode-map)
(easy-menu-add org-agenda-menu)
(if org-startup-truncated (setq truncate-lines t))
(setq-local line-move-visual nil)
- (add-hook 'post-command-hook 'org-agenda-update-agenda-type nil 'local)
- (add-hook 'pre-command-hook 'org-unhighlight nil 'local)
+ (add-hook 'post-command-hook #'org-agenda-update-agenda-type nil 'local)
+ (add-hook 'pre-command-hook #'org-unhighlight nil 'local)
;; Make sure properties are removed when copying text
(if (boundp 'filter-buffer-substring-functions)
(add-hook 'filter-buffer-substring-functions
@@ -2231,159 +2352,9 @@ org-agenda-mode
'(org-edit-agenda-file-list)
(not (get 'org-agenda-files 'org-restrict)))
"--")
- (mapcar 'org-file-menu-entry (org-agenda-files))))
- (org-agenda-set-mode-name)
- (apply
- (if (fboundp 'run-mode-hooks) 'run-mode-hooks 'run-hooks)
- (list 'org-agenda-mode-hook)))
-
-(substitute-key-definition 'undo 'org-agenda-undo
- org-agenda-mode-map global-map)
-(org-defkey org-agenda-mode-map "\C-i" 'org-agenda-goto)
-(org-defkey org-agenda-mode-map [(tab)] 'org-agenda-goto)
-(org-defkey org-agenda-mode-map "\C-m" 'org-agenda-switch-to)
-(org-defkey org-agenda-mode-map "\C-k" 'org-agenda-kill)
-(org-defkey org-agenda-mode-map "\C-c\C-w" 'org-agenda-refile)
-(org-defkey org-agenda-mode-map [(meta down)] 'org-agenda-drag-line-forward)
-(org-defkey org-agenda-mode-map [(meta up)] 'org-agenda-drag-line-backward)
-(org-defkey org-agenda-mode-map "m" 'org-agenda-bulk-mark)
-(org-defkey org-agenda-mode-map "\M-m" 'org-agenda-bulk-toggle)
-(org-defkey org-agenda-mode-map "*" 'org-agenda-bulk-mark-all)
-(org-defkey org-agenda-mode-map "\M-*" 'org-agenda-bulk-toggle-all)
-(org-defkey org-agenda-mode-map "#" 'org-agenda-dim-blocked-tasks)
-(org-defkey org-agenda-mode-map "%" 'org-agenda-bulk-mark-regexp)
-(org-defkey org-agenda-mode-map "u" 'org-agenda-bulk-unmark)
-(org-defkey org-agenda-mode-map "U" 'org-agenda-bulk-unmark-all)
-(org-defkey org-agenda-mode-map "B" 'org-agenda-bulk-action)
-(org-defkey org-agenda-mode-map "k" 'org-agenda-capture)
-(org-defkey org-agenda-mode-map "A" 'org-agenda-append-agenda)
-(org-defkey org-agenda-mode-map "\C-c\C-x!" 'org-reload)
-(org-defkey org-agenda-mode-map "\C-c\C-x\C-a" 'org-agenda-archive-default)
-(org-defkey org-agenda-mode-map "\C-c\C-xa" 'org-agenda-toggle-archive-tag)
-(org-defkey org-agenda-mode-map "\C-c\C-xA" 'org-agenda-archive-to-archive-sibling)
-(org-defkey org-agenda-mode-map "\C-c\C-x\C-s" 'org-agenda-archive)
-(org-defkey org-agenda-mode-map "\C-c$" 'org-agenda-archive)
-(org-defkey org-agenda-mode-map "$" 'org-agenda-archive)
-(org-defkey org-agenda-mode-map "\C-c\C-o" 'org-agenda-open-link)
-(org-defkey org-agenda-mode-map " " 'org-agenda-show-and-scroll-up)
-(org-defkey org-agenda-mode-map [backspace] 'org-agenda-show-scroll-down)
-(org-defkey org-agenda-mode-map "\d" 'org-agenda-show-scroll-down)
-(org-defkey org-agenda-mode-map [(control shift right)] 'org-agenda-todo-nextset)
-(org-defkey org-agenda-mode-map [(control shift left)] 'org-agenda-todo-previousset)
-(org-defkey org-agenda-mode-map "\C-c\C-xb" 'org-agenda-tree-to-indirect-buffer)
-(org-defkey org-agenda-mode-map "o" 'delete-other-windows)
-(org-defkey org-agenda-mode-map "L" 'org-agenda-recenter)
-(org-defkey org-agenda-mode-map "\C-c\C-t" 'org-agenda-todo)
-(org-defkey org-agenda-mode-map "t" 'org-agenda-todo)
-(org-defkey org-agenda-mode-map "a" 'org-agenda-archive-default-with-confirmation)
-(org-defkey org-agenda-mode-map ":" 'org-agenda-set-tags)
-(org-defkey org-agenda-mode-map "\C-c\C-q" 'org-agenda-set-tags)
-(org-defkey org-agenda-mode-map "." 'org-agenda-goto-today)
-(org-defkey org-agenda-mode-map "j" 'org-agenda-goto-date)
-(org-defkey org-agenda-mode-map "d" 'org-agenda-day-view)
-(org-defkey org-agenda-mode-map "w" 'org-agenda-week-view)
-(org-defkey org-agenda-mode-map "y" 'org-agenda-year-view)
-(org-defkey org-agenda-mode-map "\C-c\C-z" 'org-agenda-add-note)
-(org-defkey org-agenda-mode-map "z" 'org-agenda-add-note)
-(org-defkey org-agenda-mode-map [(shift right)] 'org-agenda-do-date-later)
-(org-defkey org-agenda-mode-map [(shift left)] 'org-agenda-do-date-earlier)
-(org-defkey org-agenda-mode-map [?\C-c ?\C-x (right)] 'org-agenda-do-date-later)
-(org-defkey org-agenda-mode-map [?\C-c ?\C-x (left)] 'org-agenda-do-date-earlier)
-
-(org-defkey org-agenda-mode-map ">" 'org-agenda-date-prompt)
-(org-defkey org-agenda-mode-map "\C-c\C-s" 'org-agenda-schedule)
-(org-defkey org-agenda-mode-map "\C-c\C-d" 'org-agenda-deadline)
-(let ((l '(1 2 3 4 5 6 7 8 9 0)))
- (while l (org-defkey org-agenda-mode-map
- (int-to-string (pop l)) 'digit-argument)))
-
-(org-defkey org-agenda-mode-map "F" 'org-agenda-follow-mode)
-(org-defkey org-agenda-mode-map "R" 'org-agenda-clockreport-mode)
-(org-defkey org-agenda-mode-map "E" 'org-agenda-entry-text-mode)
-(org-defkey org-agenda-mode-map "l" 'org-agenda-log-mode)
-(org-defkey org-agenda-mode-map "v" 'org-agenda-view-mode-dispatch)
-(org-defkey org-agenda-mode-map "D" 'org-agenda-toggle-diary)
-(org-defkey org-agenda-mode-map "!" 'org-agenda-toggle-deadlines)
-(org-defkey org-agenda-mode-map "G" 'org-agenda-toggle-time-grid)
-(org-defkey org-agenda-mode-map "r" 'org-agenda-redo)
-(org-defkey org-agenda-mode-map "g" 'org-agenda-redo-all)
-(org-defkey org-agenda-mode-map "e" 'org-agenda-set-effort)
-(org-defkey org-agenda-mode-map "\C-c\C-xe" 'org-agenda-set-effort)
-(org-defkey org-agenda-mode-map "\C-c\C-x\C-e"
- 'org-clock-modify-effort-estimate)
-(org-defkey org-agenda-mode-map "\C-c\C-xp" 'org-agenda-set-property)
-(org-defkey org-agenda-mode-map "q" 'org-agenda-quit)
-(org-defkey org-agenda-mode-map "Q" 'org-agenda-Quit)
-(org-defkey org-agenda-mode-map "x" 'org-agenda-exit)
-(org-defkey org-agenda-mode-map "\C-x\C-w" 'org-agenda-write)
-(org-defkey org-agenda-mode-map "\C-x\C-s" 'org-save-all-org-buffers)
-(org-defkey org-agenda-mode-map "s" 'org-save-all-org-buffers)
-(org-defkey org-agenda-mode-map "T" 'org-agenda-show-tags)
-(org-defkey org-agenda-mode-map "n" 'org-agenda-next-line)
-(org-defkey org-agenda-mode-map "p" 'org-agenda-previous-line)
-(org-defkey org-agenda-mode-map "N" 'org-agenda-next-item)
-(org-defkey org-agenda-mode-map "P" 'org-agenda-previous-item)
-(substitute-key-definition 'next-line 'org-agenda-next-line
- org-agenda-mode-map global-map)
-(substitute-key-definition 'previous-line 'org-agenda-previous-line
- org-agenda-mode-map global-map)
-(org-defkey org-agenda-mode-map "\C-c\C-a" 'org-attach)
-(org-defkey org-agenda-mode-map "\C-c\C-n" 'org-agenda-next-date-line)
-(org-defkey org-agenda-mode-map "\C-c\C-p" 'org-agenda-previous-date-line)
-(org-defkey org-agenda-mode-map "\C-c," 'org-agenda-priority)
-(org-defkey org-agenda-mode-map "," 'org-agenda-priority)
-(org-defkey org-agenda-mode-map "i" 'org-agenda-diary-entry)
-(org-defkey org-agenda-mode-map "c" 'org-agenda-goto-calendar)
-(org-defkey org-agenda-mode-map "C" 'org-agenda-convert-date)
-(org-defkey org-agenda-mode-map "M" 'org-agenda-phases-of-moon)
-(org-defkey org-agenda-mode-map "S" 'org-agenda-sunrise-sunset)
-(org-defkey org-agenda-mode-map "h" 'org-agenda-holidays)
-(org-defkey org-agenda-mode-map "H" 'org-agenda-holidays)
-(org-defkey org-agenda-mode-map "\C-c\C-x\C-i" 'org-agenda-clock-in)
-(org-defkey org-agenda-mode-map "I" 'org-agenda-clock-in)
-(org-defkey org-agenda-mode-map "\C-c\C-x\C-o" 'org-agenda-clock-out)
-(org-defkey org-agenda-mode-map "O" 'org-agenda-clock-out)
-(org-defkey org-agenda-mode-map "\C-c\C-x\C-x" 'org-agenda-clock-cancel)
-(org-defkey org-agenda-mode-map "X" 'org-agenda-clock-cancel)
-(org-defkey org-agenda-mode-map "\C-c\C-x\C-j" 'org-clock-goto)
-(org-defkey org-agenda-mode-map "J" 'org-agenda-clock-goto)
-(org-defkey org-agenda-mode-map "+" 'org-agenda-priority-up)
-(org-defkey org-agenda-mode-map "-" 'org-agenda-priority-down)
-(org-defkey org-agenda-mode-map [(shift up)] 'org-agenda-priority-up)
-(org-defkey org-agenda-mode-map [(shift down)] 'org-agenda-priority-down)
-(org-defkey org-agenda-mode-map [?\C-c ?\C-x (up)] 'org-agenda-priority-up)
-(org-defkey org-agenda-mode-map [?\C-c ?\C-x (down)] 'org-agenda-priority-down)
-(org-defkey org-agenda-mode-map "f" 'org-agenda-later)
-(org-defkey org-agenda-mode-map "b" 'org-agenda-earlier)
-(org-defkey org-agenda-mode-map "\C-c\C-x\C-c" 'org-agenda-columns)
-(org-defkey org-agenda-mode-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock)
-(org-defkey org-agenda-mode-map "\C-c\C-x<" 'org-agenda-set-restriction-lock-from-agenda)
-
-(org-defkey org-agenda-mode-map "[" 'org-agenda-manipulate-query-add)
-(org-defkey org-agenda-mode-map "]" 'org-agenda-manipulate-query-subtract)
-(org-defkey org-agenda-mode-map "{" 'org-agenda-manipulate-query-add-re)
-(org-defkey org-agenda-mode-map "}" 'org-agenda-manipulate-query-subtract-re)
-(org-defkey org-agenda-mode-map "/" 'org-agenda-filter-by-tag)
-(org-defkey org-agenda-mode-map "_" 'org-agenda-filter-by-effort)
-(org-defkey org-agenda-mode-map "=" 'org-agenda-filter-by-regexp)
-(org-defkey org-agenda-mode-map "|" 'org-agenda-filter-remove-all)
-(org-defkey org-agenda-mode-map "~" 'org-agenda-limit-interactively)
-(org-defkey org-agenda-mode-map "<" 'org-agenda-filter-by-category)
-(org-defkey org-agenda-mode-map "^" 'org-agenda-filter-by-top-headline)
-(org-defkey org-agenda-mode-map ";" 'org-timer-set-timer)
-(org-defkey org-agenda-mode-map "\C-c\C-x_" 'org-timer-stop)
-(define-key org-agenda-mode-map "?" 'org-agenda-show-the-flagging-note)
-(org-defkey org-agenda-mode-map "\C-c\C-x\C-mg" 'org-mobile-pull)
-(org-defkey org-agenda-mode-map "\C-c\C-x\C-mp" 'org-mobile-push)
-
-(org-defkey org-agenda-mode-map [mouse-2] 'org-agenda-goto-mouse)
-(org-defkey org-agenda-mode-map [mouse-3] 'org-agenda-show-mouse)
-
-(define-key org-agenda-mode-map [remap forward-paragraph] 'org-agenda-forward-block)
-(define-key org-agenda-mode-map [remap backward-paragraph] 'org-agenda-backward-block)
-
-(when org-agenda-mouse-1-follows-link
- (org-defkey org-agenda-mode-map [follow-link] 'mouse-face))
+ (mapcar #'org-file-menu-entry (org-agenda-files))))
+ (org-agenda-set-mode-name))
+
(easy-menu-define org-agenda-menu org-agenda-mode-map "Agenda menu"
'("Agenda"
("Agenda Files")
@@ -3012,7 +2983,8 @@ org-agenda-get-restriction-and-command
(if (org-string-nw-p match)
(add-text-properties
0 (length line) (list 'help-echo
- (concat "Matcher: " match)) line)))
+ (concat "Matcher: " match))
+ line)))
(push line lines)))
(setq lines (nreverse lines))
(when prefixes
@@ -3253,7 +3225,7 @@ org-batch-agenda-csv
(setq org-agenda-info
(org-fix-agenda-info (text-properties-at 0 line)))
(princ
- (mapconcat 'org-agenda-export-csv-mapper
+ (mapconcat #'org-agenda-export-csv-mapper
'(org-category txt type todo tags date time extra
priority-letter priority agenda-day)
","))
@@ -3264,7 +3236,7 @@ org-fix-agenda-info
This ensures the export commands can easily use it."
(let (tmp re)
(when (setq tmp (plist-get props 'tags))
- (setq props (plist-put props 'tags (mapconcat 'identity tmp ":"))))
+ (setq props (plist-put props 'tags (mapconcat #'identity tmp ":"))))
(when (setq tmp (plist-get props 'date))
(if (integerp tmp) (setq tmp (calendar-gregorian-from-absolute tmp)))
(let ((calendar-date-display-form '(year "-" month "-" day)))
@@ -3793,7 +3765,7 @@ org-agenda-finalize
(put-text-property (point-at-bol) (point-at-eol)
'tags (org-with-point-at mrk
(delete-dups
- (mapcar 'downcase (org-get-tags-at))))))))))
+ (mapcar #'downcase (org-get-tags-at))))))))))
(run-hooks 'org-agenda-finalize-hook)
(when org-agenda-top-headline-filter
(org-agenda-filter-top-headline-apply
@@ -3818,7 +3790,7 @@ org-agenda-finalize
(when (get 'org-agenda-effort-filter :preset-filter)
(org-agenda-filter-apply
(get 'org-agenda-effort-filter :preset-filter) 'effort))
- (add-hook 'kill-buffer-hook 'org-agenda-reset-markers 'append 'local)))))
+ (add-hook 'kill-buffer-hook #'org-agenda-reset-markers 'append 'local)))))
(defun org-agenda-mark-clocking-task ()
"Mark the current clock entry in the agenda if it is present."
@@ -4062,9 +4034,11 @@ org-agenda-entry-text-hide
(defun org-agenda-get-day-face (date)
"Return the face DATE should be displayed with."
- (cond ((and (functionp org-agenda-day-face-function)
- (funcall org-agenda-day-face-function date)))
- ((org-agenda-today-p date) 'org-agenda-date-today)
+ (funcall (or org-agenda-day-face-function
+ #'org-agenda--day-face-default)
+ date))
+(defun org-agenda--day-face-default (face)
+ (cond ((org-agenda-today-p date) 'org-agenda-date-today)
((memq (calendar-day-of-week date) org-agenda-weekend-days)
'org-agenda-date-weekend)
(t 'org-agenda-date)))
@@ -4215,11 +4189,11 @@ org-agenda-list
(setq rtn (org-agenda-get-day-entries
file date :closed)))
(org-agenda-show-log-scoped
- (setq rtn (apply 'org-agenda-get-day-entries
+ (setq rtn (apply #'org-agenda-get-day-entries
file date
(append '(:closed) org-agenda-entry-types))))
(t
- (setq rtn (apply 'org-agenda-get-day-entries
+ (setq rtn (apply #'org-agenda-get-day-entries
file date
org-agenda-entry-types)))))
(setq rtnall (append rtnall rtn)))) ;; all entries
@@ -4260,7 +4234,7 @@ org-agenda-list
(setq p (plist-put p :tstart clocktable-start))
(setq p (plist-put p :tend clocktable-end))
(setq p (plist-put p :scope 'agenda))
- (setq tbl (apply 'org-clock-get-clocktable p))
+ (setq tbl (apply #'org-clock-get-clocktable p))
(insert tbl)))
(goto-char (point-min))
(or org-agenda-multi (org-agenda-fit-window-to-buffer))
@@ -4478,7 +4452,7 @@ org-search-view
(setq re (regexp-quote (downcase w)))))
(if neg (push re regexps-) (push re regexps+)))
words)
- (push (mapconcat (lambda (w) (regexp-quote w)) words "\\s-+")
+ (push (mapconcat #'regexp-quote words "\\s-+")
regexps+))
(setq regexps+ (sort regexps+ (lambda (a b) (> (length a) (length b)))))
(if (not regexps+)
@@ -5022,19 +4996,21 @@ diary-time-regexp
(defun org-get-entries-from-diary (date)
"Get the (Emacs Calendar) diary entries for DATE."
(require 'diary-lib)
+ (declare-function diary-fancy-display "diary-lib" ())
(let* ((diary-fancy-buffer "*temporary-fancy-diary-buffer*")
- (diary-display-function 'diary-fancy-display)
+ (diary-display-function #'diary-fancy-display)
(pop-up-frames nil)
(diary-list-entries-hook
- (cons 'org-diary-default-entry diary-list-entries-hook))
+ (cons #'org-diary-default-entry diary-list-entries-hook))
(diary-file-name-prefix nil) ; turn this feature off
- (diary-modify-entry-list-string-function 'org-modify-diary-entry-string)
+ (diary-modify-entry-list-string-function
+ #'org-modify-diary-entry-string)
entries
(org-disable-agenda-to-diary t))
(save-excursion
(save-window-excursion
(funcall (if (fboundp 'diary-list-entries)
- 'diary-list-entries 'list-diary-entries)
+ #'diary-list-entries 'list-diary-entries)
date 1)))
(if (not (get-buffer diary-fancy-buffer))
(setq entries nil)
@@ -5095,18 +5071,6 @@ org-agenda-cleanup-fancy-diary
(run-hooks 'org-agenda-cleanup-fancy-diary-hook))
;; Make sure entries from the diary have the right text properties.
-(eval-after-load "diary-lib"
- '(if (boundp 'diary-modify-entry-list-string-function)
- ;; We can rely on the hook, nothing to do
- nil
- ;; Hook not available, must use advice to make this work
- (defadvice add-to-diary-list (before org-mark-diary-entry activate)
- "Make the position visible."
- (if (and org-disable-agenda-to-diary ;; called from org-agenda
- (stringp string)
- buffer-file-name)
- (setq string (org-modify-diary-entry-string string))))))
-
(defun org-modify-diary-entry-string (string)
"Add text properties to string, allowing Org to act on it."
(org-add-props string nil
@@ -5130,7 +5094,7 @@ org-diary-default-entry
(defun org-add-to-diary-list (&rest args)
(if (fboundp 'diary-add-to-list)
- (apply 'diary-add-to-list args)
+ (apply #'diary-add-to-list args)
(apply 'add-to-diary-list args)))
(defvar org-diary-last-run-time nil)
@@ -5186,12 +5150,13 @@ org-diary
;; the calendar. Org Agenda will list these entries itself.
(if org-disable-agenda-to-diary (setq files nil))
(while (setq file (pop files))
- (setq rtn (apply 'org-agenda-get-day-entries file date args))
+ (setq rtn (apply #'org-agenda-get-day-entries file date args))
(setq results (append results rtn)))
(when results
(setq results
(mapcar (lambda (i) (replace-regexp-in-string
- org-bracket-link-regexp "\\3" i)) results))
+ org-bracket-link-regexp "\\3" i))
+ results))
(concat (org-agenda-finalize-entries results) "\n"))))
;;; Agenda entry finders
@@ -5328,7 +5293,7 @@ org-agenda-get-todos
org-todo-regexp)
(org-select-this-todo-keyword
(concat "\\("
- (mapconcat 'identity
+ (mapconcat #'identity
(org-split-string
org-select-this-todo-keyword
"|")
@@ -5732,7 +5697,7 @@ org-agenda-get-progress
(if (memq 'clock items) (concat "\\<" org-clock-string))
(if (memq 'state items)
(format "- State \"%s\".*?" org-todo-regexp)))))
- (parts-re (if parts (mapconcat 'identity parts "\\|")
+ (parts-re (if parts (mapconcat #'identity parts "\\|")
(error "`org-agenda-log-mode-items' is empty")))
(regexp (concat
"\\(" parts-re "\\)"
@@ -6563,7 +6528,7 @@ org-agenda-format-item
(remove-text-properties 0 (length rtn) '(line-prefix t wrap-prefix t) rtn)
(org-add-props rtn nil
'org-category category
- 'tags (mapcar 'org-downcase-keep-props tags)
+ 'tags (mapcar #'org-downcase-keep-props tags)
'org-highest-priority org-highest-priority
'org-lowest-priority org-lowest-priority
'time-of-day time-of-day
@@ -6762,7 +6727,7 @@ org-get-time-of-day
(int-to-string t0))))
(if string (concat (substring t1 -4 -2) ":" (substring t1 -2)) t0)))))
-(defvar org-agenda-before-sorting-filter-function nil
+(defvar org-agenda-before-sorting-filter-function #'identity
"Function to be applied to agenda items prior to sorting.
Prior to sorting also means just before they are inserted into the agenda.
@@ -6797,13 +6762,13 @@ org-agenda-finalize-entries
(max-entries (cond ((listp org-agenda-max-entries)
(cdr (assoc type org-agenda-max-entries)))
(t org-agenda-max-entries))))
- (when org-agenda-before-sorting-filter-function
+ (when (memq org-agenda-before-sorting-filter-function '(nil identity))
(setq list
(delq nil
(mapcar
org-agenda-before-sorting-filter-function list))))
- (setq list (mapcar 'org-agenda-highlight-todo list)
- list (mapcar 'identity (sort list 'org-entries-lessp)))
+ (setq list (mapcar #'org-agenda-highlight-todo list)
+ list (mapcar #'identity (sort list 'org-entries-lessp)))
(when max-effort
(setq list (org-agenda-limit-entries
list 'effort-minutes max-effort
@@ -6817,7 +6782,7 @@ org-agenda-finalize-entries
(setq list (org-agenda-limit-entries list 'org-hd-marker max-entries)))
(when (and org-agenda-dim-blocked-tasks org-blocker-hook)
(setq list (mapcar #'org-agenda--mark-blocked-entry list)))
- (mapconcat 'identity list "\n")))
+ (mapconcat #'identity list "\n")))
(defun org-agenda-limit-entries (list prop limit &optional fn)
"Limit the number of agenda entries."
@@ -7268,7 +7233,7 @@ org-agenda-kill-all-agenda-buffers
(dolist (buf (buffer-list))
(when (with-current-buffer buf (eq major-mode 'org-agenda-mode))
(push buf blist)))
- (mapc 'kill-buffer blist)))
+ (mapc #'kill-buffer blist)))
(defun org-agenda-execute (arg)
"Execute another agenda command, keeping same window.
@@ -8137,7 +8102,7 @@ org-unhighlight
(defun org-unhighlight-once ()
"Remove the highlight from its position, and this function from the hook."
- (remove-hook 'pre-command-hook 'org-unhighlight-once)
+ (remove-hook 'pre-command-hook #'org-unhighlight-once)
(org-unhighlight))
(defvar org-agenda-pre-follow-window-conf nil)
@@ -8282,7 +8247,7 @@ org-agenda-set-mode-name
'(:eval (propertize
(concat " <"
(mapconcat
- 'identity
+ #'identity
(append
(get 'org-agenda-category-filter :preset-filter)
org-agenda-category-filter)
@@ -8295,7 +8260,7 @@ org-agenda-set-mode-name
'(:eval (propertize
(concat " {"
(mapconcat
- 'identity
+ #'identity
(append
(get 'org-agenda-tag-filter :preset-filter)
org-agenda-tag-filter)
@@ -8308,7 +8273,7 @@ org-agenda-set-mode-name
'(:eval (propertize
(concat " {"
(mapconcat
- 'identity
+ #'identity
(append
(get 'org-agenda-effort-filter :preset-filter)
org-agenda-effort-filter)
@@ -8321,7 +8286,7 @@ org-agenda-set-mode-name
'(:eval (propertize
(concat " ["
(mapconcat
- 'identity
+ #'identity
(append
(get 'org-agenda-regexp-filter :preset-filter)
org-agenda-regexp-filter)
@@ -8395,7 +8360,7 @@ org-agenda-show-tags
(let* ((tags (org-get-at-bol 'tags)))
(if tags
(message "Tags are :%s:"
- (org-no-properties (mapconcat 'identity tags ":")))
+ (org-no-properties (mapconcat #'identity tags ":")))
(message "No tags associated with this line"))))
(defun org-agenda-goto (&optional highlight)
@@ -9991,8 +9956,8 @@ org-agenda-bulk-action
(let (org-loop-over-headlines-in-active-region) (funcall cmd))
;; `post-command-hook' is not run yet. We make sure any
;; pending log note is processed.
- (when (or (memq 'org-add-log-note (default-value 'post-command-hook))
- (memq 'org-add-log-note post-command-hook))
+ (when (or (memq #'org-add-log-note (default-value 'post-command-hook))
+ (memq #'org-add-log-note post-command-hook))
(org-add-log-note))
(cl-incf processed))))
(when redo-at-end (org-agenda-redo))
@@ -10166,7 +10131,7 @@ org-agenda-to-appt
(setq entries
(delq nil
(append entries
- (apply 'org-agenda-get-day-entries
+ (apply #'org-agenda-get-day-entries
file today scope)))))
;; Map thru entries and find if we should filter them out
(mapc
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: Suggested patch for org-agenda.el
2019-05-06 23:07 Suggested patch for org-agenda.el Stefan Monnier
@ 2019-05-08 12:43 ` Nicolas Goaziou
0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2019-05-08 12:43 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-orgmode
Hello,
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
> Misc changes:
Thank you.
> - Assume Emacs≥22 (we're using defvaralias already anyway).
> - Try to make sure <foo>-function only contain functions (and never nil).
> - Use define-minor-mode and define-derived-mode.
> - Use command remapping.
> - Initialize map from within its definition.
> - Use suppress-keymap.
>
> There'd be more to do if we can assume ≥24.1, of course.
Starting from 9.0, Org assumes ≥24.4, so we can go wild, if necessary.
However, I cannot apply your patch on top of master branch. Would you
mind building your patch from Org repository?
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-05-08 12:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-06 23:07 Suggested patch for org-agenda.el Stefan Monnier
2019-05-08 12:43 ` Nicolas Goaziou
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).