lisp/org-agenda.el: Small refactoring and docstring enhancement

* lisp/org-agenda.el (org-agenda-priority): Small refactoring
and docstring enhancement.

Link: https://orgmode.org/list/87o8j3360f.fsf@kyleam.com/
This commit is contained in:
Bastien Guerry 2021-05-01 12:41:46 +02:00
parent 4394eaf0e2
commit e080eb759a
1 changed files with 28 additions and 26 deletions

View File

@ -9570,33 +9570,35 @@ current line."
(defun org-agenda-priority (&optional force-direction) (defun org-agenda-priority (&optional force-direction)
"Set the priority of line at point, also in Org file. "Set the priority of line at point, also in Org file.
This changes the line at point, all other lines in the agenda referring to This changes the line at point, all other lines in the agenda
the same tree node, and the headline of the tree node in the Org file. referring to the same tree node, and the headline of the tree
Called with a universal prefix arg, show the priority instead of setting it." node in the Org file.
Called with one universal prefix arg, show the priority instead
of setting it.
When called programmatically, FORCE-DIRECTION can be `set', `up',
`down', or a character."
(interactive "P") (interactive "P")
(if (equal force-direction '(4)) (unless org-priority-enable-commands
(org-priority-show) (user-error "Priority commands are disabled"))
(unless org-priority-enable-commands (org-agenda-check-no-diary)
(user-error "Priority commands are disabled")) (let* ((col (current-column))
(org-agenda-check-no-diary) (hdmarker (org-get-at-bol 'org-hd-marker))
(let* ((col (current-column)) (buffer (marker-buffer hdmarker))
;; (marker (or (org-get-at-bol 'org-marker) (pos (marker-position hdmarker))
;; (org-agenda-error))) (inhibit-read-only t)
(hdmarker (org-get-at-bol 'org-hd-marker)) newhead)
(buffer (marker-buffer hdmarker)) (org-with-remote-undo buffer
(pos (marker-position hdmarker)) (with-current-buffer buffer
(inhibit-read-only t) (widen)
newhead) (goto-char pos)
(org-with-remote-undo buffer (org-show-context 'agenda)
(with-current-buffer buffer (org-priority force-direction)
(widen) (end-of-line 1)
(goto-char pos) (setq newhead (org-get-heading)))
(org-show-context 'agenda) (org-agenda-change-all-lines newhead hdmarker)
(org-priority force-direction) (org-move-to-column col))))
(end-of-line 1)
(setq newhead (org-get-heading)))
(org-agenda-change-all-lines newhead hdmarker)
(org-move-to-column col)))))
;; FIXME: should fix the tags property of the agenda line. ;; FIXME: should fix the tags property of the agenda line.
(defun org-agenda-set-tags (&optional tag onoff) (defun org-agenda-set-tags (&optional tag onoff)