From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Jesse Johnson <holocronweaver@gmail.com>
Cc: Bastien <bzg@gnu.org>, emacs-orgmode@gnu.org
Subject: Re: inherit priority
Date: Wed, 18 Jul 2018 14:54:34 +0200 [thread overview]
Message-ID: <87efg5vkj1.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <01c7db31-72eb-be93-c772-e93b0327a906@gmail.com> (Jesse Johnson's message of "Mon, 9 Jul 2018 22:03:12 -0700")
Hello,
Jesse Johnson <holocronweaver@gmail.com> writes:
> Since you want to comment I guess you want the patch in the e-mail
> body rather than attached. Here goes nothing.
Thank you!
It looks good. Some minor comments follow.
> From bb02cd6c00b32155c0a25f409f1bfa4160b2ddcd Mon Sep 17 00:00:00 2001
> From: Jesse Johnson <holocronweaver@gmail.com>
> Date: Sun, 22 Apr 2018 18:12:54 -0700
> Subject: [PATCH] Add priority inheritance
You need to describe here what functions or variables changed here,
e.g.,
* lisp/org-agenda (org-search-view): ...
> (defcustom org-get-priority-function nil
> - "Function to extract the priority from a string.
> -The string is normally the headline. If this is nil Org computes the
> -priority from the priority cookie like [#A] in the headline. It returns
> -an integer, increasing by 1000 for each priority level.
> -The user can set a different function here, which should take a string
> -as an argument and return the numeric priority."
> + "Function to extract the priority from current line.
> +The line is always a headline.
> +
> +If this is nil Org computes the priority of the headline from a
> +priority cookie like [#A]. It returns an integer, increasing by
You need to add two spaces after a full stop.
> +1000 for each priority level (see
> +`org-priority-char-to-integer').
> +(defcustom org-use-priority-inheritance nil
> + "Whether headline priority is inherited from its parents.
"Non-nil means headline priority is..."
> +If non-nil then the first explicit priority found when searching
> +up the headline tree applies. Thus a child headline can override
> +its parent's priority.
> +
> +When nil, explicit priorities only apply to the headline they are
> +given on.
> +
> +Regardless of setting, if no explicit priority is found then the
> +default priority is used."
> + :group 'org-priorities
> + :type 'boolean)
You need to add the following keywords:
:package-version '(Org . "9.3")
and possibly
:safe t
> +(defun org-priority-char-to-integer (character)
> + "Convert priority CHARACTER to an integer priority."
> + (* 1000 (- org-lowest-priority character)))
> +
> +(defun org-priority-integer-to-char (integer)
> + "Convert priority INTEGER to a character priority."
> + (- org-lowest-priority (/ integer 1000)))
I think those can be internal functions, so they should be renamed
`org--priority-char-to-integer' and `org--priority-integer-to-char'.
> +(defun org-get-priority (&optional pos local)
> + "Get integer priority at POS.
> +POS defaults to point. If LOCAL is non-nil priority inheritance
> +is ignored regardless of the value of
> +`org-use-priority-inheritance'. Returns nil if no priority can be
Return nil if...
> +determined at POS."
> + (save-excursion
> + (save-restriction
> + (widen)
> + (goto-char (or pos (point)))
`save-excursion' + `save-restriction' + `widen' + `goto-char' = `org-with-point-at'
So the above would be:
(org-with-point-at pos
...)
> + (beginning-of-line)
> + (if (not (looking-at org-heading-regexp))
> + (return nil)
Indentation looks wrong, but it should be:
(unless (looking-at org-heading-regexp)
...)
> + (save-match-data
> + (cl-loop
> + (if (functionp org-get-priority-function)
> + (let ((priority (funcall org-get-priority-function)))
> + (unless (eq priority t)
> + (return priority)))
> + (when (looking-at org-priority-regexp)
> + (return (org-priority-char-to-integer
> + (string-to-char (match-string-no-properties 2))))))
> + (unless (and (not local)
> + org-use-priority-inheritance
> + (org-up-heading-safe))
> + (return (org-priority-char-to-integer
> org-default-priority)))))))))
You can write a simpler function. Please have a look at `org-get-tags'
and use `org-complex-heading-regexp' to get priority cookie.
Also could you throw in a bunch of tests in "contrib/lisp/test-org.el"
and update the manual accordingly?
Regards,
--
Nicolas Goaziou
prev parent reply other threads:[~2018-07-18 12:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-31 18:14 inherit priority Jesse Johnson
2018-01-03 21:41 ` Nicolas Goaziou
2018-01-04 4:04 ` Jesse Johnson
2018-01-04 8:15 ` Nicolas Goaziou
2018-01-05 4:00 ` Jesse Johnson
2018-01-05 7:24 ` Nicolas Goaziou
2018-01-07 22:47 ` Jesse Johnson
2018-01-08 13:16 ` Nicolas Goaziou
2018-04-26 23:34 ` Bastien
2018-04-27 1:34 ` Jesse Johnson
2018-04-27 1:59 ` Bastien
2018-07-08 1:55 ` Jesse Johnson
2018-07-09 8:22 ` Nicolas Goaziou
2018-07-10 5:03 ` Jesse Johnson
2018-07-18 12:54 ` Nicolas Goaziou [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87efg5vkj1.fsf@nicolasgoaziou.fr \
--to=mail@nicolasgoaziou.fr \
--cc=bzg@gnu.org \
--cc=emacs-orgmode@gnu.org \
--cc=holocronweaver@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).