emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* problem with org-highest-priority
@ 2020-10-05 21:58 joakim
  2020-10-06  5:09 ` Kyle Meyer
  0 siblings, 1 reply; 4+ messages in thread
From: joakim @ 2020-10-05 21:58 UTC (permalink / raw)
  To: emacs-orgmode

This used to work:
  (defun jv-org-priorities ()
    (setq org-highest-priority ?0 ;; 64 @ 48 0, bugs start happening if you have higher prios tnan 0, like '!'
          org-lowest-priority  ?E ;; E
          org-default-priority ?0 ;; 0
          org-priority-regexp ".*?\\(\\[#\\([;:<=>?@A-Z0-9]\\)\\] ?\\)"
     ))

I could then have priority cookies from [#0] to [#E].

With the current org I get [#48] instead of [#0].

Is there any way to restore the previous behaviour?

-- 
Joakim Verona
joakim@verona.se



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: problem with org-highest-priority
  2020-10-05 21:58 problem with org-highest-priority joakim
@ 2020-10-06  5:09 ` Kyle Meyer
  2020-11-18 22:17   ` joakim
  0 siblings, 1 reply; 4+ messages in thread
From: Kyle Meyer @ 2020-10-06  5:09 UTC (permalink / raw)
  To: joakim; +Cc: emacs-orgmode

joakim@verona.se writes:

> This used to work:
>   (defun jv-org-priorities ()
>     (setq org-highest-priority ?0 ;; 64 @ 48 0, bugs start happening if you have higher prios tnan 0, like '!'
>           org-lowest-priority  ?E ;; E
>           org-default-priority ?0 ;; 0
>           org-priority-regexp ".*?\\(\\[#\\([;:<=>?@A-Z0-9]\\)\\] ?\\)"
>      ))
>
> I could then have priority cookies from [#0] to [#E].
>
> With the current org I get [#48] instead of [#0].
>
> Is there any way to restore the previous behaviour?

The change in behavior you describe came with 4f98694bf (Allow numeric
values for priorities, 2020-01-30).  Based on quickly skimming that
commit, I think the issue boils down to intentionally not supporting a
mix of numbers and letters.  I'm out of time tonight to look at it too
closely, but I think support for your use case could be restored with
something like the lightly tested patch below.

diff --git a/lisp/org.el b/lisp/org.el
index 425e9391b..8237f39f6 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11166,8 +11166,7 @@ (defun org-priority (&optional action show)
     (unless org-priority-enable-commands
       (user-error "Priority commands are disabled"))
     (setq action (or action 'set))
-    (let ((nump (< org-priority-lowest 65))
-	  current new news have remove)
+    (let (current new news have remove)
       (save-excursion
 	(org-back-to-heading t)
 	(when (looking-at org-priority-regexp)
@@ -11181,27 +11180,18 @@ (defun org-priority (&optional action show)
 	      (integerp action))
 	  (if (not (eq action 'set))
 	      (setq new action)
-	    (setq
-	     new
-	     (if nump
-		 (string-to-number
-		  (read-string (format "Priority %s-%s, SPC to remove: "
-				       (number-to-string org-priority-highest)
-				       (number-to-string org-priority-lowest))))
-	       (progn (message "Priority %c-%c, SPC to remove: "
-				 org-priority-highest org-priority-lowest)
-			(save-match-data
-			  (setq new (read-char-exclusive)))))))
+	    (setq new
+		  (progn (message "Priority %c-%c, SPC to remove: "
+				  org-priority-highest org-priority-lowest)
+			 (save-match-data
+			   (setq new (read-char-exclusive))))))
 	  (when (and (= (upcase org-priority-highest) org-priority-highest)
 		     (= (upcase org-priority-lowest) org-priority-lowest))
 	    (setq new (upcase new)))
 	  (cond ((equal new ?\s) (setq remove t))
 		((or (< (upcase new) org-priority-highest) (> (upcase new) org-priority-lowest))
-		 (user-error
-		  (if nump
-		      "Priority must be between `%s' and `%s'"
-		    "Priority must be between `%c' and `%c'")
-		  org-priority-highest org-priority-lowest))))
+		 (user-error "Priority must be between `%c' and `%c'"
+			     org-priority-highest org-priority-lowest))))
 	 ((eq action 'up)
 	  (setq new (if have
 			(1- current)  ; normal cycling
@@ -11235,7 +11225,7 @@ (defun org-priority (&optional action show)
 	    (setq remove t)))
 	;; Numerical priorities are limited to 64, beyond that number,
 	;; assume the priority cookie is a character.
-	(setq news (if (> new 64) (format "%c" new) (format "%s" new)))
+	(setq news (format "%c" new))
 	(if have
 	    (if remove
 		(replace-match "" t t nil 1)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: problem with org-highest-priority
  2020-10-06  5:09 ` Kyle Meyer
@ 2020-11-18 22:17   ` joakim
  2020-11-19  2:19     ` Kyle Meyer
  0 siblings, 1 reply; 4+ messages in thread
From: joakim @ 2020-11-18 22:17 UTC (permalink / raw)
  To: emacs-orgmode

Kyle Meyer <kyle@kyleam.com> writes:

> joakim@verona.se writes:
>
>> This used to work:
>>   (defun jv-org-priorities ()
>>     (setq org-highest-priority ?0 ;; 64 @ 48 0, bugs start happening if you have higher prios tnan 0, like '!'
>>           org-lowest-priority  ?E ;; E
>>           org-default-priority ?0 ;; 0
>>           org-priority-regexp ".*?\\(\\[#\\([;:<=>?@A-Z0-9]\\)\\] ?\\)"
>>      ))
>>
>> I could then have priority cookies from [#0] to [#E].
>>
>> With the current org I get [#48] instead of [#0].
>>
>> Is there any way to restore the previous behaviour?
>
> The change in behavior you describe came with 4f98694bf (Allow numeric
> values for priorities, 2020-01-30).  Based on quickly skimming that
> commit, I think the issue boils down to intentionally not supporting a
> mix of numbers and letters.  I'm out of time tonight to look at it too
> closely, but I think support for your use case could be restored with
> something like the lightly tested patch below.

Thanks, I tested your patch, and it helps a little bit.

- m-x org-priority works, I can set any priority from 0 to Z
- org-priority-down and org-priority-down doesn't work as expected, as
they worked previously. I dont step through all the priority cookies,
instead I quickly wind up in prio 0, then I'm stuck there, for lack of
better description.

- sorting of priorities still work with or withouth the patch, that is
  prio 0 is highest prio, prio Z is lowest prio. I would like to mention
  that in my case the characters between letters and numbers are also
  priority cookies, @ is a cookie as well as 0 and z. Limiting to just
  letters and numbers would be fine for me though, I dont use the
  in-between prios much.

Because the sorting still works, I have been able to work around this
new behaviour, by writing the cookie by hand.

I'm not sure how to proceed. It seems I'm the only org-user affected by
this change? Should I maintain a local patch to get the behaviour I
want? What is the recomended way to do that? I usually run
org-plus-contrib from elpa.

>
> diff --git a/lisp/org.el b/lisp/org.el
> index 425e9391b..8237f39f6 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -11166,8 +11166,7 @@ (defun org-priority (&optional action show)
>      (unless org-priority-enable-commands
>        (user-error "Priority commands are disabled"))
>      (setq action (or action 'set))
> -    (let ((nump (< org-priority-lowest 65))
> -	  current new news have remove)
> +    (let (current new news have remove)
>        (save-excursion
>  	(org-back-to-heading t)
>  	(when (looking-at org-priority-regexp)
> @@ -11181,27 +11180,18 @@ (defun org-priority (&optional action show)
>  	      (integerp action))
>  	  (if (not (eq action 'set))
>  	      (setq new action)
> -	    (setq
> -	     new
> -	     (if nump
> -		 (string-to-number
> -		  (read-string (format "Priority %s-%s, SPC to remove: "
> -				       (number-to-string org-priority-highest)
> -				       (number-to-string org-priority-lowest))))
> -	       (progn (message "Priority %c-%c, SPC to remove: "
> -				 org-priority-highest org-priority-lowest)
> -			(save-match-data
> -			  (setq new (read-char-exclusive)))))))
> +	    (setq new
> +		  (progn (message "Priority %c-%c, SPC to remove: "
> +				  org-priority-highest org-priority-lowest)
> +			 (save-match-data
> +			   (setq new (read-char-exclusive))))))
>  	  (when (and (= (upcase org-priority-highest) org-priority-highest)
>  		     (= (upcase org-priority-lowest) org-priority-lowest))
>  	    (setq new (upcase new)))
>  	  (cond ((equal new ?\s) (setq remove t))
>  		((or (< (upcase new) org-priority-highest) (> (upcase new) org-priority-lowest))
> -		 (user-error
> -		  (if nump
> -		      "Priority must be between `%s' and `%s'"
> -		    "Priority must be between `%c' and `%c'")
> -		  org-priority-highest org-priority-lowest))))
> +		 (user-error "Priority must be between `%c' and `%c'"
> +			     org-priority-highest org-priority-lowest))))
>  	 ((eq action 'up)
>  	  (setq new (if have
>  			(1- current)  ; normal cycling
> @@ -11235,7 +11225,7 @@ (defun org-priority (&optional action show)
>  	    (setq remove t)))
>  	;; Numerical priorities are limited to 64, beyond that number,
>  	;; assume the priority cookie is a character.
> -	(setq news (if (> new 64) (format "%c" new) (format "%s" new)))
> +	(setq news (format "%c" new))
>  	(if have
>  	    (if remove
>  		(replace-match "" t t nil 1)
>
>
-- 
Joakim Verona
joakim@verona.se



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: problem with org-highest-priority
  2020-11-18 22:17   ` joakim
@ 2020-11-19  2:19     ` Kyle Meyer
  0 siblings, 0 replies; 4+ messages in thread
From: Kyle Meyer @ 2020-11-19  2:19 UTC (permalink / raw)
  To: joakim; +Cc: emacs-orgmode

joakim@verona.se writes:

> Kyle Meyer <kyle@kyleam.com> writes:
>
>> The change in behavior you describe came with 4f98694bf (Allow numeric
>> values for priorities, 2020-01-30).  Based on quickly skimming that
>> commit, I think the issue boils down to intentionally not supporting a
>> mix of numbers and letters.  I'm out of time tonight to look at it too
>> closely, but I think support for your use case could be restored with
>> something like the lightly tested patch below.
>
> Thanks, I tested your patch, and it helps a little bit.
>
> - m-x org-priority works, I can set any priority from 0 to Z
> - org-priority-down and org-priority-down doesn't work as expected, as
> they worked previously. I dont step through all the priority cookies,
> instead I quickly wind up in prio 0, then I'm stuck there, for lack of
> better description.

Thanks for testing it out.  I haven't really reloaded the issue into my
head yet, but perhaps there's just a bit more to tweak then.

> I'm not sure how to proceed. It seems I'm the only org-user affected by
> this change?

Hard to say, though I'd bet not (especially if we consider users that
aren't on v9.4 yet).

As for proceeding, with your feedback, I'll plan to take another look,
but it won't be right away, so anyone is welcome to beat me to an
updated patch.  Even if your formerly working approach wasn't actually
envisioned (*), I think it'd make sense to bring back support (along
with tests) if it doesn't add much complication.

  (*) Again, I haven't refreshed on this issue, and I'm a very boring
      user of A, B, and C priorities.

> Should I maintain a local patch to get the behaviour I
> want? What is the recomended way to do that? I usually run
> org-plus-contrib from elpa.

I'm perhaps not the best person to answer this as a non-ELPA user,
though I'd imagine your two main options are

  1) defining org-priority in your local config to override the builtin
     version, either with a pure redefinition or with advice-add's
     :override.

  2) cloning the Org repo and keeping a branch with the patch on top of
     the maint branch

For maintaining a local variant over a longer period, the latter is the
better way to go because you'll be alerted when the patched version
conflicts.

But let's see...


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-19  2:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-05 21:58 problem with org-highest-priority joakim
2020-10-06  5:09 ` Kyle Meyer
2020-11-18 22:17   ` joakim
2020-11-19  2:19     ` Kyle Meyer

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).