From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: inherit priority Date: Wed, 18 Jul 2018 14:54:34 +0200 Message-ID: <87efg5vkj1.fsf@nicolasgoaziou.fr> References: <87wp0ymxgy.fsf@nicolasgoaziou.fr> <92a7a7a4-a992-86f5-eb8f-2381213ad32f@gmail.com> <87o9mam43l.fsf@nicolasgoaziou.fr> <87bme5pmnf.fsf@bzg.fr> <7e082452-7450-c2fa-ac53-40d75b348b3c@gmail.com> <87tvrxz9wx.fsf@gnu.org> <3e785a53-293d-0faf-d3b0-86036ebd1747@gmail.com> <87a7r0ked5.fsf@nicolasgoaziou.fr> <01c7db31-72eb-be93-c772-e93b0327a906@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:32853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fflyl-0005ml-H2 for emacs-orgmode@gnu.org; Wed, 18 Jul 2018 08:54:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fflyk-00069I-DW for emacs-orgmode@gnu.org; Wed, 18 Jul 2018 08:54:51 -0400 In-Reply-To: <01c7db31-72eb-be93-c772-e93b0327a906@gmail.com> (Jesse Johnson's message of "Mon, 9 Jul 2018 22:03:12 -0700") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Jesse Johnson Cc: Bastien , emacs-orgmode@gnu.org Hello, Jesse Johnson 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 > 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): ... > =C2=A0(defcustom org-get-priority-function nil > -=C2=A0 "Function to extract the priority from a string. > -The string is normally the headline.=C2=A0 If this is nil Org computes t= he > -priority from the priority cookie like [#A] in the headline.=C2=A0 It re= turns > -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." > +=C2=A0 "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 > +=C2=A0 "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.=C2=A0 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." > +=C2=A0 :group 'org-priorities > +=C2=A0 :type 'boolean) You need to add the following keywords:=20 :package-version '(Org . "9.3") and possibly=20 :safe t > +(defun org-priority-char-to-integer (character) > +=C2=A0 "Convert priority CHARACTER to an integer priority." > +=C2=A0 (* 1000 (- org-lowest-priority character))) > + > +(defun org-priority-integer-to-char (integer) > +=C2=A0 "Convert priority INTEGER to a character priority." > +=C2=A0 (- 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) > +=C2=A0 "Get integer priority at POS. > +POS defaults to point.=C2=A0 If LOCAL is non-nil priority inheritance > +is ignored regardless of the value of > +`org-use-priority-inheritance'.=C2=A0 Returns nil if no priority can be Return nil if... > +determined at POS." > +=C2=A0 (save-excursion > +=C2=A0=C2=A0=C2=A0 (save-restriction > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (widen) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (goto-char (or pos (point))) `save-excursion' + `save-restriction' + `widen' + `goto-char' =3D `org-with= -point-at' So the above would be: (org-with-point-at pos ...) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (beginning-of-line) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (if (not (looking-at org-heading-regexp)) > +=C2=A0=C2=A0=C2=A0 =C2=A0 (return nil) Indentation looks wrong, but it should be: (unless (looking-at org-heading-regexp) ...) > +=C2=A0=C2=A0=C2=A0 (save-match-data > +=C2=A0=C2=A0=C2=A0 =C2=A0 (cl-loop > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 (if (functionp org-get-priority-function) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (let ((priority = (funcall org-get-priority-function))) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0(unless (eq priority t) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 (return priority))) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 (when (looking-at org-priori= ty-regexp) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (return (org-pri= ority-char-to-integer > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (string-to-char= (match-string-no-properties 2)))))) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 (unless (and (not local) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 org-use-priorit= y-inheritance > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (org-up-heading= -safe)) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 (return (org-priority-char-t= o-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, --=20 Nicolas Goaziou