Bug: [PATCH] org-agenda: "Invalid face reference: t" errors [9.4 (release_9.4-49-g4b150d @ /home/n/.emacs.d/straight/build/org/)]

2020-10-05 Thread No Wayman


I noticed recently that my message buffer was getting clobbered 
with thousands of Invalid face reference errors when moving point 
around an org-agenda buffer. e.g.:



Invalid face reference: t [4519 times]


Git bisect points to commit 
7a12e149907b5921011710d869b7554c35859c89



org.el (org-display-outline-path): Fix faces of the message

* lisp/org.el (org-display-outline-path): Set :height as the
default face height, and don't change other face attributes.

See a3576543f for a previous fix, and this discussion:



As a workaround, setting `org-agenda-show-outline-path' to nil 
prevents the errors.
I believe the face spec in the call to `add-face-text-property' in 
`org-display-outline-path' is incorrect.
The attached patch replaces it with an anonymous face, which works 
on my end.


>From 4b150d7ca3f8d7d9fe30f6b562b35a5f4072e5e1 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Tue, 6 Oct 2020 01:30:09 -0400
Subject: [PATCH] org.el (org-display-outline-path): Fix invalid face reference
 error

* lisp/org.el (org-display-outline-path): Use an anonymous face when
adding default :height to outline path
---
 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 425e9391b..beb830b36 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8057,7 +8057,7 @@ If JUST-RETURN-STRING is non-nil, return a string, don't display a message."
 	   (and file bfn (concat (file-name-nondirectory bfn) separator))
 	   separator))
 (add-face-text-property 0 (length res)
-			`((t :height ,(face-attribute 'default :height)))
+			`(:height ,(face-attribute 'default :height))
 			nil res)
 (if just-return-string
 	res
-- 
2.28.0



Re: problem with org-highest-priority

2020-10-05 Thread Kyle Meyer
joa...@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 ( 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 ( 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 ( 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)



problem with org-highest-priority

2020-10-05 Thread joakim
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
joa...@verona.se




Re: Proposal: do not align tags in Agenda

2020-10-05 Thread No Wayman
I recently proposed a patch that would allow a workaround for this:

https://orgmode.org/list/87ft8gelpn@gmail.com/

It allows custom placement of the habit consistency graph within the agenda.
There is an accompanying example that places the graph on its own line
under the agenda item.
I've attached an org file with my current workaround which advises
`org-habit-insert-consistency-graphs'.


org-habit-single-line-suggestion.org
Description: Lotus Organizer


Re: [PATCH] ob-java

2020-10-05 Thread ian martins
I wrote those examples in an org file so I could test as I wrote them, and
then exported it to make it more readable, but the export resulted in
source block headers being lost.  Here is the same without export:

* Changes

- support for functional mode (~:results value~)
- accept variables
- don't require package, class, and main definitions
- write source and result tempfiles to ~org-babel-temporary-directory~, but
respects the ~:dir~ header
- work with tramp

* Examples
** Example 1
This outputs "hello."  If class and main definitions aren't given the
code block will be wrapped in generic ones.

#+begin_src java :results output silent
  System.out.print("hello");
#+end_src

This is exactly equivalent:

#+begin_src java :results output silent
  public class Main {
  public static void main(String[] args) {
  System.out.print("hello");
  }
  }
#+end_src

** Example 2
This also outputs "hello."

#+begin_src java :results value silent
  return "hello";
#+end_src

** Example 3
This generates the class "Example" in the package "org.orgmode" in the
current directory.

#+begin_src java :results output silent :classname org.orgmode.Example :dir
.
  System.out.print("hello, org-mode");
#+end_src

** Example 4
The "Hey" class defines a static method but no main. C-c C-c on the
"Hey" source block will write "./org/orgmode/Hey.java" and compile it.

The "Main" class calls the "Hey" class. C-c C-c on the "Main" source
block will write "./org/orgmode/Main.java" and compile and run it.

#+begin_src java :results output silent :dir .
  package org.orgmode;

  public class Hey {
  public static String say() {
  return "hey";
  }
  }
#+end_src

#+begin_src java :results output silent :dir .
  package org.orgmode;

  public class Main {
  public static void main(String[] args) {
  System.out.print(Hey.say());
  }
  }
#+end_src

Instead of C-c C-c, we could have added tangle headers and written the
source files out by tangling.

** Example 5
This prints the variable from the header

#+begin_src java :var msg="hello, org-mode" :results output silent
  System.out.print(msg);
#+end_src

** Example 6
This prints "hello, org-mode." The table is provided to the method as a
list of lists.

#+name: table
| message | hello, org-mode  |

#+begin_src java :var tbl=table :results output silent
  System.out.print(tbl.get(0).get(1));
#+end_src

** Example 7
This example returns a list.

Note that you're allowed to specify imports without defining the class
or main methods.

#+begin_src java :results value :exports both
  import java.util.Arrays;

  return Arrays.asList("message", "hello, org-mode");
#+end_src

#+RESULTS:
| message | hello, org-mode |

On Mon, Oct 5, 2020 at 8:35 AM ian martins  wrote:

> 1 Changes
> =
>
>   - support for functional mode (`:results value')
>   - accept variables
>   - don't require package, class, and main definitions
>   - write source and result tempfiles to
> `org-babel-temporary-directory', but respects the `:dir' header
>   - work with tramp
>
>
> 2 Examples
> ==
> Some examples follow.  See the tests for more examples.  I'll write proper
> docs after review.
>
> 2.1 Example 1
> ~
>
>   This outputs "hello."  If class and main definitions aren't given the
>   code block will be wrapped in generic ones.
>
>   ,
>   | System.out.print("hello");
>   `
>
>   This is exactly equivalent:
>
>   ,
>   | public class Main {
>   | public static void main(String[] args) {
>   | System.out.print("hello");
>   | }
>   | }
>   `
>
>
> 2.2 Example 2
> ~
>
>   This also outputs "hello."
>
>   ,
>   | return "hello";
>   `
>
>
> 2.3 Example 3
> ~
>
>   This generates the class "Example" in the package "org.orgmode" in the
>   current directory.
>
>   ,
>   | System.out.print("hello, org-mode");
>   `
>
>
> 2.4 Example 4
> ~
>
>   The "Hey" class defines a static method but no main. C-c C-c on the
>   "Hey" source block will write "./org/orgmode/Hey.java" and compile it.
>
>   The "Main" class calls the "Hey" class. C-c C-c on the "Main" source
>   block will write "./org/orgmode/Main.java" and compile and run it.
>
>   ,
>   | package org.orgmode;
>   |
>   | public class Hey {
>   | public static String say() {
>   | return "hey";
>   | }
>   | }
>   `
>
>   ,
>   | package org.orgmode;
>   |
>   | public class Main {
>   | public static void main(String[] args) {
>   | System.out.print(Hey.say());
>   | }
>   | }
>   `
>
>   Instead of C-c C-c, we could have added tangle headers and written the
>   source files out by tangling.
>
>
> 2.5 Example 5
> ~
>
>   This prints the variable from the header
>
>   ,
>   | System.out.print(msg);
>   `
>
>
> 2.6 Example 6
> ~
>
>   This prints "hello, org-mode." The table is provided to the method as
>   a list of lists.
>
>

[PATCH] ob-java

2020-10-05 Thread ian martins
1 Changes
=

  - support for functional mode (`:results value')
  - accept variables
  - don't require package, class, and main definitions
  - write source and result tempfiles to
`org-babel-temporary-directory', but respects the `:dir' header
  - work with tramp


2 Examples
==
Some examples follow.  See the tests for more examples.  I'll write proper
docs after review.

2.1 Example 1
~

  This outputs "hello."  If class and main definitions aren't given the
  code block will be wrapped in generic ones.

  ,
  | System.out.print("hello");
  `

  This is exactly equivalent:

  ,
  | public class Main {
  | public static void main(String[] args) {
  | System.out.print("hello");
  | }
  | }
  `


2.2 Example 2
~

  This also outputs "hello."

  ,
  | return "hello";
  `


2.3 Example 3
~

  This generates the class "Example" in the package "org.orgmode" in the
  current directory.

  ,
  | System.out.print("hello, org-mode");
  `


2.4 Example 4
~

  The "Hey" class defines a static method but no main. C-c C-c on the
  "Hey" source block will write "./org/orgmode/Hey.java" and compile it.

  The "Main" class calls the "Hey" class. C-c C-c on the "Main" source
  block will write "./org/orgmode/Main.java" and compile and run it.

  ,
  | package org.orgmode;
  |
  | public class Hey {
  | public static String say() {
  | return "hey";
  | }
  | }
  `

  ,
  | package org.orgmode;
  |
  | public class Main {
  | public static void main(String[] args) {
  | System.out.print(Hey.say());
  | }
  | }
  `

  Instead of C-c C-c, we could have added tangle headers and written the
  source files out by tangling.


2.5 Example 5
~

  This prints the variable from the header

  ,
  | System.out.print(msg);
  `


2.6 Example 6
~

  This prints "hello, org-mode." The table is provided to the method as
  a list of lists.

   message  hello, org-mode

  ,
  | System.out.print(tbl.get(0).get(1));
  `


2.7 Example 7
~

  This example returns a list.

  Note that you're allowed to specify imports without defining the class
  or main methods.

  ,
  | import java.util.Arrays;
  |
  | return Arrays.asList("message", "hello, org-mode");
  `

   message  hello, org-mode
From e525a1328fee6f764c40a2158376d78e406391ae Mon Sep 17 00:00:00 2001
From: Ian Martins 
Date: Mon, 5 Oct 2020 08:07:25 -0400
Subject: [PATCH] ob-java.el: Add support for variables, return values, tramp

* lisp/ob-java.el: Add support for variables and return values.  Write
tempfiles to the org-babel-temporary-directory.  Make package, class,
and main method definitions optional.

* testing/lisp/test-ob-java.el: Add tests.
---
 lisp/ob-java.el  | 425 +++---
 testing/lisp/test-ob-java.el | 574 +++
 2 files changed, 958 insertions(+), 41 deletions(-)
 create mode 100644 testing/lisp/test-ob-java.el

diff --git a/lisp/ob-java.el b/lisp/ob-java.el
index fee695bb9..94c3f69cf 100644
--- a/lisp/ob-java.el
+++ b/lisp/ob-java.el
@@ -1,9 +1,8 @@
-;;; ob-java.el --- Babel Functions for Java  -*- lexical-binding: t; -*-
+;;; ob-java.el --- org-babel functions for java evaluation -*- lexical-binding: t -*-
 
 ;; Copyright (C) 2011-2020 Free Software Foundation, Inc.
 
-;; Author: Eric Schulte
-;; Maintainer: Ian Martins 
+;; Author: Ian Martins 
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: https://orgmode.org
 
@@ -24,61 +23,405 @@
 
 ;;; Commentary:
 
-;; Currently this only supports the external compilation and execution
-;; of java code blocks (i.e., no session support).
+;; Org-Babel support for evaluating java source code.
 
 ;;; Code:
 (require 'ob)
 
+(defvar org-babel-temporary-directory) ; from ob-core
+
 (defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '("java" . "java"))
 
-(defcustom org-babel-java-command "java"
-  "Name of the java command.
-May be either a command in the path, like java
-or an absolute path name, like /usr/local/bin/java
-parameters may be used, like java -verbose"
+(defvar org-babel-default-header-args:java '()
+  "Default header args for java source blocks.")
+
+(defconst org-babel-header-args:java '((imports . :any))
+  "Java-specific header arguments.")
+
+(defvar org-babel-java-compiler-command "javac"
+  "Name of the command to execute the java compiler.")
+
+(defvar org-babel-java-runtime-command "java"
+  "Name of the command to run the java runtime.")
+
+(defcustom org-babel-java-hline-to "null"
+  "Replace hlines in incoming tables with this when translating to java."
   :group 'org-babel
-  :version "24.3"
+  :version "25.2"
+  :package-version '(Org . "9.3")
   :type 'string)
 
-(defcustom org-babel-java-compiler "javac"
-  "Name of the java compiler.
-May be either a command in the 

Re: [PATCH] Adaptive Org faces in headings?

2020-10-05 Thread Protesilaos Stavrou
On 2020-09-26, 08:31 +0200, Bastien  wrote:

> Bastien  writes:
>
>> Ihor Radchenko  writes:
>>
>>> The attached patch seems to fix the issue.
>>
>> Applied as 979e82fc3, thanks a lot!
>
> Also, marking the initial bug report as closed, thanks again.

Sorry to re-open this issue.  The following change extends Ihor's patch
to also cover checkbox statistics.  Seems to work just fine on my end.
Thanks again!


#+begin_src diff
 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 425e9391b..23c86ba0c 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5684,7 +5684,7 @@ needs to be inserted at a specific position in the 
font-lock sequence.")
 1 'org-checkbox prepend)
   (when (cdr (assq 'checkbox org-list-automatic-rules))
 '("\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\)/\\([0-9]*\\)\\]"
-  (0 (org-get-checkbox-statistics-face) t)))
+  (0 (org-get-checkbox-statistics-face) prepend)))
   ;; Description list items
   '("^[ \t]*[-+*][ \t]+\\(.*?[ \t]+::\\)\\([ \t]+\\|$\\)"
 1 'org-list-dt prepend)
#+end_src

-- 
Protesilaos Stavrou
protesilaos.com



Re: org-->latex add local variables after \end{document}

2020-10-05 Thread Eric S Fraga
On Monday,  5 Oct 2020 at 10:11, Uwe Brauer wrote:
> Right this is correct and this is what I tried, however I hoped for a
> more, hm, elegant solution. But on the other hand, what the heck...

This is pretty much my view: elegance is a bonus but anything that works
is enough!  But if somebody does know an elegant solution, please chime
in. :-)

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4-38-g16f505



Re: Two tables with same data but different sorting

2020-10-05 Thread Robert Pluim
> On Mon, 5 Oct 2020 11:21:24 +0200, Axel Kielhorn 
>  said:

>> Am 05.10.2020 um 10:32 schrieb Robert Pluim :
>> 
>>> On Mon, 5 Oct 2020 10:08:08 +0200, Axel Kielhorn 
 said:
>> 
>> From the docstring:
 Return the last link of LIST.  Its car is the last element.
>> 
Axel> But I get:
Axel> Wrong type argument: stringp, ("30 $“)
>> 
>> You need to do (car (last …))

Axel> So =first= returns an element, but =last= returns a list.
Axel> I get it.

You'll have to get a time machine and take it up with the common lisp
folks from about 40 years ago :-)

Robert
-- 



Re: Two tables with same data but different sorting

2020-10-05 Thread Axel Kielhorn



> Am 05.10.2020 um 10:32 schrieb Robert Pluim :
> 
>> On Mon, 5 Oct 2020 10:08:08 +0200, Axel Kielhorn 
>>  said:
> 
> From the docstring:
>>> Return the last link of LIST.  Its car is the last element.
> 
>Axel> But I get:
>Axel> Wrong type argument: stringp, ("30 $“)
> 
> You need to do (car (last …))

So =first= returns an element, but =last= returns a list.
I get it.

>  If N is non-nil, return the Nth-to-last link of LIST.
I was interpreting link as element and didn’t look at the docstring.

> and you'll want some calls to 'string-to-number', since
> 
> (string< "30 $" "127 $")
> => nil

Yes, I know. But I wanted to keep the change as minimal as possible.

Thanks for you help, my example is working now.

Greetings Axel


Re: Two tables with same data but different sorting

2020-10-05 Thread Robert Pluim
> On Mon, 5 Oct 2020 10:08:08 +0200, Axel Kielhorn 
>  said:

>From the docstring:
>> Return the last link of LIST.  Its car is the last element.

Axel> But I get:
Axel> Wrong type argument: stringp, ("30 $“)

You need to do (car (last ...))

and you'll want some calls to 'string-to-number', since

(string< "30 $" "127 $")
=> nil

Robert
-- 



Re: org-->latex add local variables after \end{document}

2020-10-05 Thread Uwe Brauer
>>> "ESF" == Eric S Fraga  writes:

> On Monday,  5 Oct 2020 at 09:27, Uwe Brauer wrote:
>> I have a org file that I want to export to latex but would like to add 

> [...]

>> It is added before \end{document}
>> 
>> Any idea how to do that?

> You could always add the '\end{document}' line as the first line of your
> LaTeX src block?  Untested but LaTeX should stop processing anything
> after it encounters that line.  It shouldn't matter that you have
> another such line inserted by org after.

Right this is correct and this is what I tried, however I hoped for a
more, hm, elegant solution. But on the other hand, what the heck...


smime.p7s
Description: S/MIME cryptographic signature


Re: Two tables with same data but different sorting

2020-10-05 Thread Axel Kielhorn



> Am 02.10.2020 um 11:36 schrieb Robert Pluim :
> 
>> On Fri, 2 Oct 2020 08:25:03 +0200, Axel Kielhorn 
>>  said:
> 
>>> Am 01.10.2020 um 17:47 schrieb John Kitchin :
>>> 
>>> Glad it was helpful. You might also try (seventh row1) or (nth 6 row1). I 
>>> think it is the same thing, but more obvious to read!
> 
>Axel> I agree that „first second …“ would be easier for an english speaker.
>Axel> Having the ordinal number 1 based but the nth number 0 based is 
> irritating (and sadly there is no „last“ or „penultimate“).
> 
> ? C-h f last
> 
>last is a compiled Lisp function in `subr.el'.
> 
>(last LIST  N)
> 
>  Probably introduced at or before Emacs version 1.1.
>  This function does not change global state, including the match data.
> 
>Return the last link of LIST.  Its car is the last element.
>If LIST is nil, return nil.
>If N is non-nil, return the Nth-to-last link of LIST.
>If N is bigger than the length of LIST, return LIST.

As i understand it, this should work:

* Table

#+name: table1
| Manufacturer| Name| Price |
|-+-+---|
| ACME| super cheep | 127 $ |
| Roadrunner Inc. | Kaboom  | 27 $  |
| ACME| cheep   | 30 $  |

#+RESULTS: resorted
| Manufacturer| Name| Price |
|-+-+---|
| ACME| super cheep | 127 $ |
| ACME| cheep   | 30 $  |
| Roadrunner Inc. | Kaboom  | 27 $  |

** Code for resorting

#+name: resorted
#+BEGIN_SRC emacs-lisp :var data=table1 :colnames t
(sort data (lambda (row1 row2) (string< (last row1) (last row2
#+END_SRC

But I get:
Wrong type argument: stringp, ("30 $“)

Greeting Axel


Re: org-->latex add local variables after \end{document}

2020-10-05 Thread Eric S Fraga
On Monday,  5 Oct 2020 at 09:27, Uwe Brauer wrote:
> I have a org file that I want to export to latex but would like to add 

[...]

> It is added before \end{document}
>
> Any idea how to do that?

You could always add the '\end{document}' line as the first line of your
LaTeX src block?  Untested but LaTeX should stop processing anything
after it encounters that line.  It shouldn't matter that you have
another such line inserted by org after.

But I could be mistaken!

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4-38-g16f505



org-->latex add local variables after \end{document}

2020-10-05 Thread Uwe Brauer



Hi

I have a org file that I want to export to latex but would like to add 

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% TeX-output-dir: "/home/oub/ALLES/HGs/TFG-2020/build"
%%% End:


*after* \end{document}

If I do 
#+begin_src latex :results latex replace :exports results :eval t
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% TeX-output-dir: "/home/oub/ALLES/HGs/TFG-2020/build"
%%% End:
#+end_src

It is added before \end{document}

Any idea how to do that?

Thanks