From e8b45bb947a967d571a93c2b5cae30182e0e7ebe Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Fri, 28 Sep 2012 08:29:38 +0200 Subject: [PATCH] Rebind `org-agenda-priority' to `C-c ," in agenda mode (`C-u C-c ,' now shows priority) * org.el (org-priority): Use a new argument to show priority instead of setting it. (org-show-priority): New function to show priority both in normal Org buffers and in Org Agenda buffers. (org-speed-commands-default): Use "," as a speed command for setting priority. * org-agenda.el (org-agenda-mode-map): Bind `org-agenda-priority' to `C-c ,' as it was before. (org-agenda-show-priority): Delete. (org-agenda-priority): Use a new argument to show priority instead of setting it. Thanks to Robert Horn for triggering this change. --- lisp/org-agenda.el | 19 ++++++------------- lisp/org.el | 23 ++++++++++++++++++++--- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 713622d5d..e0601465c 100755 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -2088,8 +2088,8 @@ The following commands are available: (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 "\C-c," 'org-agenda-show-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) @@ -2255,7 +2255,7 @@ The following commands are available: ["Set Priority" org-agenda-priority t] ["Increase Priority" org-agenda-priority-up t] ["Decrease Priority" org-agenda-priority-down t] - ["Show Priority" org-agenda-show-priority t]) + ["Show Priority" org-show-priority t]) ("Calendar/Diary" ["New Diary Entry" org-agenda-diary-entry (org-agenda-check-type nil 'agenda 'timeline)] ["Goto Calendar" org-agenda-goto-calendar (org-agenda-check-type nil 'agenda 'timeline)] @@ -7489,14 +7489,6 @@ When called with a prefix argument, include all archive files as well." (and org-agenda-show-outline-path (org-with-point-at m (org-display-outline-path t)))))) -(defun org-agenda-show-priority () - "Show the priority of the current item. -This priority is composed of the main priority given with the [#A] cookies, -and by additional input from the age of a schedules or deadline entry." - (interactive) - (let* ((pri (org-get-at-bol 'priority))) - (message "Priority is %d" (if pri pri -1000)))) - (defun org-agenda-show-tags () "Show the tags applicable to the current item." (interactive) @@ -8085,11 +8077,12 @@ If FORCE-TAGS is non nil, the car of it returns the new tags." (interactive) (org-agenda-priority 'down)) -(defun org-agenda-priority (&optional force-direction) +(defun org-agenda-priority (&optional force-direction show) "Set the priority of line at point, also in Org-mode file. This changes the line at point, all other lines in the agenda referring to the same tree node, and the headline of the tree node in the Org-mode file." - (interactive) + (interactive "P") + (if (equal force-direction '(4)) (setq show t)) (unless org-enable-priority-commands (error "Priority commands are disabled")) (org-agenda-check-no-diary) @@ -8108,7 +8101,7 @@ the same tree node, and the headline of the tree node in the Org-mode file." (save-excursion (and (outline-next-heading) (org-flag-heading nil))) ; show the next heading - (funcall 'org-priority force-direction) + (funcall 'org-priority force-direction show) (end-of-line 1) (setq newhead (org-get-heading))) (org-agenda-change-all-lines newhead hdmarker) diff --git a/lisp/org.el b/lisp/org.el index 3acacdc06..be8c84cdb 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -12997,10 +12997,12 @@ from the `before-change-functions' in the current buffer." (interactive) (org-priority 'down)) -(defun org-priority (&optional action) +(defun org-priority (&optional action show) "Change the priority of an item. ACTION can be `set', `up', `down', or a character." - (interactive) + (interactive "P") + (if (equal action '(4)) + (org-show-priority) (unless org-enable-priority-commands (error "Priority commands are disabled")) (setq action (or action 'set)) @@ -13077,7 +13079,21 @@ ACTION can be `set', `up', `down', or a character." (org-preserve-lc (org-set-tags nil 'align))) (if remove (message "Priority removed") - (message "Priority of current item set to %s" news)))) + (message "Priority of current item set to %s" news))))) + +(defun org-show-priority () + "Show the priority of the current item. +This priority is composed of the main priority given with the [#A] cookies, +and by additional input from the age of a schedules or deadline entry." + (interactive) + (let ((pri (if (eq major-mode 'org-agenda-mode) + (org-get-at-bol 'priority) + (save-excursion + (save-match-data + (beginning-of-line) + (and (looking-at org-heading-regexp) + (org-get-priority (match-string 0)))))))) + (message "Priority is %d" (if pri pri -1000)))) (defun org-get-priority (s) "Find priority cookie and return priority." @@ -18161,6 +18177,7 @@ BEG and END default to the buffer boundaries." ("O" . org-clock-out) ("Meta Data Editing") ("t" . org-todo) + ("," . (org-priority)) ("0" . (org-priority ?\ )) ("1" . (org-priority ?A)) ("2" . (org-priority ?B))