[patch] When inserting entry template, don't include last newline in narrowed zone

2020-06-28 Thread E.L.K.
Hello.

Org 9.3.6: when inserting the entry by capture mechanics, it narrows buffer
in a way that cursor can be moved to the last line, which is the beginning
of next (non-capture template) line in the original unnarowed buffer.

So this allows to: start capture, move point to the very last char of the
narrowed buffer, insert something. If this line in unnarowed buffer was
start of heading, it breaks structure of document.

This is patch in attempt to fix it. I followed same approach as in
org-capture-place-item function.

Thanks,
Alexey
Common subdirectories: org-9.3.6/etc and /home/elk/.emacs.d/elpa/org-9.3.6/etc
diff -U5 org-9.3.6/org-capture.el /home/elk/.emacs.d/elpa/org-9.3.6/org-capture.el
--- org-9.3.6/org-capture.el	2020-06-15 19:04:19.061012833 +0300
+++ /home/elk/.emacs.d/elpa/org-9.3.6/org-capture.el	2020-06-28 13:08:04.446045559 +0300
@@ -1149,11 +1149,11 @@
 	  (org-paste-subtree level template 'for-yank))
 	(org-capture-position-for-last-stored beg)
 	(org-capture-empty-lines-after)
 	(unless (org-at-heading-p) (outline-next-heading))
 	(org-capture-mark-kill-region origin (point))
-	(org-capture-narrow beg (point))
+	(org-capture-narrow beg (1- (point)))
 	(when (or (search-backward "%?" beg t)
 		  (search-forward "%?" nil t))
 	  (replace-match ""))
 
 (defun org-capture-place-item ()



Re: [patch] When inserting entry template, don't include last newline in narrowed zone

2020-06-28 Thread E.L.K.
Just found an issue with this patch: if I try to schedule the item,
SCHEDULED and timestamp get inserted into invisible area.

Thanks,
Alexey

On Sun, Jun 28, 2020 at 1:14 PM E.L.K.  wrote:

> Hello.
>
> Org 9.3.6: when inserting the entry by capture mechanics, it narrows
> buffer in a way that cursor can be moved to the last line, which is the
> beginning of next (non-capture template) line in the original unnarowed
> buffer.
>
> So this allows to: start capture, move point to the very last char of the
> narrowed buffer, insert something. If this line in unnarowed buffer was
> start of heading, it breaks structure of document.
>
> This is patch in attempt to fix it. I followed same approach as in
> org-capture-place-item function.
>
> Thanks,
> Alexey
>


Re: Babel: parse error when output contains opening bracket

2020-06-28 Thread ian martins
A little while back I submitted a patch to add org-babel integration for
haxe and mentioned that the same could be done for java to expand the
features of the java integration. There was no response which I took to
mean no interest in haxe or java, so I didn't think submitting a patch for
java would be fruitful. Then I thought I could just add them to the contrib
directory but was mistaken since that goes through the same ML patch
workflow.

Since you recommend it, I will try submitting a patch for java.

I still want to share the haxe integration. What is the best way to do that?

-Ian

On Sun, Jun 28, 2020 at 1:55 AM Jarmo Hurri  wrote:

>
> >> ian martins  writes:
> >>
> >> Would it be possible for us to fix the current version without
> >> introducing a new one? Can you identify the parts of your code that fix
> >> the issue?
> >>
> > The existing code creates the java program and runs it correctly, but
> > it uses `org-babel-import-elisp-from-file' to interpret the results,
> > and that sees the bracket and tries to make the response into a list,
> > and errors when it can't. I don't see a quick fix for it. If you allow
> > unbalanced brackets but that would be a change in ob-core and would
> > probably cause unwanted results in other places. If you don't try to
> > convert the output into a list, you can't present java results as
> > lists or tables.  Really the problem is that ob-java doesn't support
> > functional mode, so it tries to guess if scripting mode output should
> > be a table or list.  The version I wrote supports functional and
> > scripting modes and doesn't use `org-babel-import-elisp-from-file'.
>
> Ok.
>
> >> I am already a contributor, so if you can post your solution here I
> >> can create a patch and give you the credit.
> >>
> > I would really appreciate that if you are willing, but it's a
> > significant change (code is 400 lines, 600 lines of tests and test
> > data) and there might be iterations so you might be signing up for
> > more than you realize.
>
> Fair enough.
>
> 1. Have you considered writing a patch yourself?
>
> 2. If not, I think you lose nothing by posting your code here and
>patiently waiting if I can create something out of it.
>
> All the best,
>
> Jarmo
>
>
>


Re: [bug] select TODO items and unexpected behaviour

2020-06-28 Thread Mario Frasca
the "somehow", I can confirm it happened in the same session.  it was 
left like that when I ran toggle-debug-on-error and landed in the debugger.


I also noticed that the behaviour on the selection is only implemented 
for some actions, not all.


if you select items, then S- (to raise priority), the result is … 
difficult to describe, non-selected parts of the buffer disappear, I am 
asked about a Tag, for whatever reason, at this point I hit C-g, and the 
raise-priority is applied, but only on the line containing the point.


went looking in the code for these functions, and the leading test, 
recursively implementing the action on the selected lines, I only saw it 
repeated with variations in a couple such functions. as said, 
org-priority does not have it.  I think the block could better be 
generalized, my guess is by defining a well suited macro.


regards, MF

On 28/06/2020 01:32, Kyle Meyer wrote:

Mario Frasca writes:


this behaviour comes after somehow my
`org-loop-over-headlines-in-active-region' became nil.

Perhaps not the "somehow" but the default value of this option is
different between the last release and master.  It changed from nil to t
in e360cd8f3 (Change the default values for several options,
2020-02-21).


if I set it back to t, I get the message "Symbol's value as variable is
void: right".

Thanks for reporting.  Looks like org-todo's call to org-map-entries has
been broken since its introduction in 7.8.05.  Should be fixed with
8a2eb7d1b.




Re: [patch] When inserting entry template, don't include last newline in narrowed zone

2020-06-28 Thread Kyle Meyer
E.L.K. writes:

> Hello.
>
> Org 9.3.6: when inserting the entry by capture mechanics, it narrows buffer
> in a way that cursor can be moved to the last line, which is the beginning
> of next (non-capture template) line in the original unnarowed buffer.
>
> So this allows to: start capture, move point to the very last char of the
> narrowed buffer, insert something. If this line in unnarowed buffer was
> start of heading, it breaks structure of document.
>
> This is patch in attempt to fix it. I followed same approach as in
> org-capture-place-item function.

Thanks.  AFAICT this issue, along with the hidden SCHEDULE line you
mention in the next commit, is resolved on the master branch (what will
be v9.4).  The last commit in this area is 6882478ca (capture: Fix
org-capture-place-entry narrow bounds, 2020-05-29).

> Common subdirectories: org-9.3.6/etc and /home/elk/.emacs.d/elpa/org-9.3.6/etc
> diff -U5 org-9.3.6/org-capture.el 
> /home/elk/.emacs.d/elpa/org-9.3.6/org-capture.el
> --- org-9.3.6/org-capture.el  2020-06-15 19:04:19.061012833 +0300
> +++ /home/elk/.emacs.d/elpa/org-9.3.6/org-capture.el  2020-06-28 
> 13:08:04.446045559 +0300

For future reference: This doesn't quite match this project's
conventions for patch submissions.  More information is here:
.

Thanks again.



Re: [FR] Add check for attachments in org-lint

2020-06-28 Thread Nicolas Goaziou
Hello,

Gustavo Barros  writes:

> So, I'd like to kindly suggest that either "attachment" be included as
> a case in `org-lint-link-to-local-file' or that an equivalent check
> for attachments be included in `org-lint'.  I'd be much thankful.

This is done in master.

Regards,
-- 
Nicolas Goaziou



Re: [FR] Add check for attachments in org-lint

2020-06-28 Thread Gustavo Barros

Hi Nicolas,

On Sun, 28 Jun 2020 at 14:26, Nicolas Goaziou  
wrote:



This is done in master.


Thank you very much.

Regards,
Gustavo.




Re: [bug] select TODO items and unexpected behaviour

2020-06-28 Thread Mario Frasca

On 28/06/2020 01:32, Kyle Meyer wrote:

Thanks for reporting. Looks like org-todo's call to org-map-entries has
been broken since its introduction in 7.8.05.  Should be fixed with
8a2eb7d1b.


3ed035ce3

with this patch, you don't need to locally redefine the 
org-loop-over-headlines-in-active-region variable, do you?





Re: [bug] select TODO items and unexpected behaviour

2020-06-28 Thread Kyle Meyer
[ Please don't drop the list in your replies. ]

Mario Frasca writes:

> if we were using self-evaluating symbols, the issue would vanish, and 
> the code might result easier to read.

The "loop over headline" code in org-todo needs to be able to handle
every argument that org-todo accepts, including prefix arguments.  A
wholesale rewrite of all of its arguments isn't an option.

> On 28/06/2020 01:32, Kyle Meyer wrote:
>> Should be fixed with
>> 8a2eb7d1b.
>
> I have an extra doubt on this feature.  in fact, the completely 
> independent rotation of status is not what I would expect.  what I would 
> expect is more like having several 3-way switches next to each other, 
> and I pull them all together to a common position, stepwise … like, 
> imagine the status is 1-2-0…
>
> times I activate the tool ->
>
> 0 1 2 3 …
> ---
> 0 1 2 0
> 1 1 2 0
> 2 2 2 0
> 1 1 2 0
> 0 1 2 0
> 2 2 2 0
>
> now what happens is:
>
> 0 1 2 3 …
> -
> 0 1 2 0
> 1 2 0 1
> 2 0 1 2
> 1 2 0 1
> 0 1 2 0
> 2 0 1 2

This is orthogonal to the fix in 8a2eb7d1b.  I do not have an opinion,
at least at the moment.  Perhaps others that are interested will weigh
in.



Using regular expressions in custom agenda views

2020-06-28 Thread Nathan Neff
I'm having a difficult time using regular expressions in custom
"tags-todo" agenda views.

Is it possible to create custom agenda views using regular expressions,
and if so, do I need to escape certain characters?

I can't get a simple regex like this to work, so I'm suspecting that
I'm doing something wrong or, it's simply not possible to create custom
agenda views that use regular expressions to search for tags.

For example, this expression doesn't even find headings with :projectA:
as a tag

  (setq org-agenda-custom-commands
  '(
 ("1" tags-todo "{projectA}")))

I have the regex surrounded in {} because of the documentation about doing
a tags search - do I need those when using a custom agenda view?

The info page says:
"The second parameter is the search type followed by the string or regular
expression
to be used for the matching" - how do I specify a regular expression versus
a simple
string?

This attempt gives me back a bunch of headings that simply match :project:
but have no
capital A anywhere in the tags.
  (setq org-agenda-custom-commands
  '(
 ("1" tags-todo "project[A]")))

Any help appreciated
Thanks,
--Nate


Re: [bug] select TODO items and unexpected behaviour

2020-06-28 Thread Kyle Meyer
Mario Frasca writes:

> On 28/06/2020 01:32, Kyle Meyer wrote:
>> Thanks for reporting. Looks like org-todo's call to org-map-entries has
>> been broken since its introduction in 7.8.05.  Should be fixed with
>> 8a2eb7d1b.
>
> 3ed035ce3
>
> with this patch, you don't need to locally redefine the 
> org-loop-over-headlines-in-active-region variable, do you?

What have you tried on your end to answer that?  Here are some
approaches:

  * Read the commit message in 3ed035ce3 (org.el: Clarify argument in
org-todo's call to org-map-entries).  Does its explanation fit with
your understanding?  Perhaps it's wrong or not written clearly, but
it seems like a good starting point.

  * Drop the let-binding of org-loop-over-headlines-in-active-region in
org-todo, and try it out.  Does it work as before?  Better yet, step
through the call of the function, comparing the behavior before and
after.

  * Drop the let-binding and run the test I added in 8a2eb7d1b (org.el:
Fix org-todo argument handling when looping over region).



Smart processing of http(s) links

2020-06-28 Thread Ag Ibragimov

I want to make something like this:

Whenever I I use org-insert-link and it turns out to be a URI that starts with 
"https://github.com"; I would like it to be processed differently than any other 
link, one example - if it is a PR or a Github Issue, I'd like it to fetch summary(title) 
of it and create a link that looks like this:

[[https://github.com/user/repo/issues/3899][This issue needs to be fixed #3899]]

Do we have any "built-in" mechanism for doing something like this? Can someone 
suggest how I can make it. Thank you!



Re: Smart processing of http(s) links

2020-06-28 Thread Kyle Meyer
Ag Ibragimov writes:

> Whenever I I use org-insert-link and it turns out to be a URI that
> starts with "https://github.com"; I would like it to be processed
> differently than any other link, one example - if it is a PR or a
> Github Issue, I'd like it to fetch summary(title) of it and create a
> link that looks like this:
>
> [[https://github.com/user/repo/issues/3899][This issue needs to be fixed 
> #3899]]
>
> Do we have any "built-in" mechanism for doing something like this? Can
> someone suggest how I can make it. Thank you!

You can set org-link-make-description-function to a function that
detects links of interest and generates a custom description.



Re: Using regular expressions in custom agenda views

2020-06-28 Thread Kyle Meyer
Nathan Neff writes:

> I'm having a difficult time using regular expressions in custom
> "tags-todo" agenda views.
>
> Is it possible to create custom agenda views using regular expressions,
> and if so, do I need to escape certain characters?
>
> I can't get a simple regex like this to work, so I'm suspecting that
> I'm doing something wrong or, it's simply not possible to create custom
> agenda views that use regular expressions to search for tags.
>
> For example, this expression doesn't even find headings with :projectA:
> as a tag
>
>   (setq org-agenda-custom-commands
>   '(
>  ("1" tags-todo "{projectA}")))

My understanding is that the above should work.  I tried your
org-agenda-custom-commands value with this agenda file:

* TODO a   
:projectA:
* TODO b   
:projectB:
* TODO c   :project:

With an otherwise vanilla configuration and master (0c1740c91) checked
out, I see

Headlines with TAGS match: {projectA}
Press ‘C-u r’ to search again
  scratch:TODO a
  :projectA:

I see the same thing on maint (3ed035ce3).



[PATCH] partial rewrite of gnuplot-to-grid-data

2020-06-28 Thread Mario Frasca
according to me, this looks better, I'm curious about the reactions from 
the list.


in particular, I was surprised finding a duplicated evaluation of 
(string-to-number (nth col (nth row table))) inside a (dotimes (col 
num-cols) (dotimes (row num-rows) …))



>From 9822748dfbdb99f1ea534e695e818d7533920a61 Mon Sep 17 00:00:00 2001
From: mfrasca 
Date: Sun, 28 Jun 2020 16:24:54 -0500
Subject: [PATCH] org-plot/gnuplot-to-grid-data: code review for speed and
 readability

* lisp/org-plot.el (org-plot/gnuplot-to-grid-data): partial rewrite.

Optimizing for speed and readability: preprocessing data in order to
simplify removal on non-plotting columns; using available functions
like set-difference and org-remove-by-index; loop over elements
instead of counting indices and invoking `nth' (in a double loop).
---
 lisp/org-plot.el | 81 +---
 1 file changed, 36 insertions(+), 45 deletions(-)

diff --git a/lisp/org-plot.el b/lisp/org-plot.el
index bf81d3c37..38749c069 100644
--- a/lisp/org-plot.el
+++ b/lisp/org-plot.el
@@ -130,53 +130,44 @@ Pass PARAMS through to `orgtbl-to-generic' when exporting TABLE."
 (defun org-plot/gnuplot-to-grid-data (table data-file params)
   "Export the data in TABLE to DATA-FILE for gnuplot.
 This means in a format appropriate for grid plotting by gnuplot.
-PARAMS specifies which columns of TABLE should be plotted as independent
-and dependent variables."
-  (interactive)
-  (let* ((ind (- (plist-get params :ind) 1))
-	 (deps (if (plist-member params :deps)
-		   (mapcar (lambda (val) (- val 1)) (plist-get params :deps))
-		 (let (collector)
-		   (dotimes (col (length (nth 0 table)))
-		 (setf collector (cons col collector)))
-		   collector)))
-	 (counter 0)
-	 row-vals)
-(when (>= ind 0) ;; collect values of ind col
-  (setf row-vals (mapcar (lambda (row) (setf counter (+ 1 counter))
-			   (cons counter (nth ind row)))
-			 table)))
-(when (or deps (>= ind 0)) ;; remove non-plotting columns
-  (setf deps (delq ind deps))
-  (setf table (mapcar (lambda (row)
-			(dotimes (col (length row))
-			  (unless (memq col deps)
-(setf (nth col row) nil)))
-			(delq nil row))
-			  table)))
+PARAMS specifies which columns of TABLE should be plotted as
+independent and dependent variables.  Return the ind-column, as
+list of (cons 0-based-row-num . cell-value)."
+  (let* ((last-col (1- (length (car table
+ (ind (1- (plist-get params :ind)))
+ (deps (delq ind (if (plist-member params :deps)
+ (mapcar #'1- (plist-get params :deps))
+   (number-sequence 0 last-col
+ (skip-deps (set-difference
+ (number-sequence 0 last-col)
+ deps))
+ (row-vals ; the return value - indexed values from the ind column
+  (unless (< ind 0)
+(let ((i -1)) (mapcar (lambda (row)
+(incf i)
+(cons i (nth ind row)))
+  table)
+;; remove non-plotting columns
+(setq table (mapcar (lambda (row) 
+  (org-remove-by-index row skip-deps))
+table))
 ;; write table to gnuplot grid datafile format
 (with-temp-file data-file
-  (let ((num-rows (length table)) (num-cols (length (nth 0 table)))
-	(gnuplot-row (lambda (col row value)
-			   (setf col (+ 1 col)) (setf row (+ 1 row))
-			   (format "%f  %f  %f\n%f  %f  %f\n"
-   col (- row 0.5) value ;; lower edge
-   col (+ row 0.5) value))) ;; upper edge
-	front-edge back-edge)
-	(dotimes (col num-cols)
-	  (dotimes (row num-rows)
-	(setf back-edge
-		  (concat back-edge
-			  (funcall gnuplot-row (- col 1) row
-   (string-to-number (nth col (nth row table))
-	(setf front-edge
-		  (concat front-edge
-			  (funcall gnuplot-row col row
-   (string-to-number (nth col (nth row table)))
-	  ;; only insert once per row
-	  (insert back-edge) (insert "\n") ;; back edge
-	  (insert front-edge) (insert "\n") ;; front edge
-	  (setf back-edge "") (setf front-edge ""
+  (let ((gnuplot-row (lambda (c r value)
+   (format "%f  %f  %s\n%f  %f  %s\n"
+   c (+ r 0.5) value
+   c (+ r 1.5) value
+(dotimes (c (length (car table)))
+  (let ((column (mapcar (lambda (row) (nth c row)) table))
+(r 0)
+front-edge back-edge)
+(dolist (cell column)
+  (setq back-edge (concat back-edge
+  (funcall gnuplot-row c r cell)))
+  (setq front-edge (concat front-edge
+   (funcall gnuplot-row (1+ c) r cell)))
+  (incf r))
+(insert (concat back-edge "\n" front-edge "\n"))
 row-vals))
 

Re: Using regular expressions in custom agenda views

2020-06-28 Thread Nathan Neff
On Sun, Jun 28, 2020 at 4:12 PM Kyle Meyer  wrote:

> Nathan Neff writes:
>
> > I'm having a difficult time using regular expressions in custom
> > "tags-todo" agenda views.
> >
> > Is it possible to create custom agenda views using regular expressions,
> > and if so, do I need to escape certain characters?
> >
> > I can't get a simple regex like this to work, so I'm suspecting that
> > I'm doing something wrong or, it's simply not possible to create custom
> > agenda views that use regular expressions to search for tags.
> >
> > For example, this expression doesn't even find headings with :projectA:
> > as a tag
> >
> >   (setq org-agenda-custom-commands
> >   '(
> >  ("1" tags-todo "{projectA}")))
>
> My understanding is that the above should work.  I tried your
> org-agenda-custom-commands value with this agenda file:
>
> * TODO a
>  :projectA:
> * TODO b
>  :projectB:
> * TODO c
>  :project:
>
> With an otherwise vanilla configuration and master (0c1740c91) checked
> out, I see
>
> Headlines with TAGS match: {projectA}
> Press ‘C-u r’ to search again
>   scratch:TODO a
> :projectA:
>
> I see the same thing on maint (3ed035ce3).
>

Thanks - I'm using Org 9.3.6 and I'm getting no matches when using emacs -q

I had some other issues w/regexes and Bastien fixed them in "maint":
https://code.orgmode.org/bzg/org-mode/commit/c0d08b7efe740c17a3eec28984161c05e43da5ef

Is it relatively easy to try org-mode's "maint" version (e.g. just check
out branch from
https://code.orgmode.org/bzg/org-mode ?)  I'll try using the "maint"
version to see what's up.

Thanks,
--Nate


Re: Using regular expressions in custom agenda views

2020-06-28 Thread Nathan Neff
G I tried "package update" and package mgr in Emacs kept telling me
that Org 9.3.6 was the latest.  Now I look @ orgmode.org and see 9.3.7 -
I'll try that first
after I figure out how to get that "package" or whatever that thing is to
actually show the latest
versions of packages.

On Sun, Jun 28, 2020 at 5:27 PM Nathan Neff  wrote:

>
>
> On Sun, Jun 28, 2020 at 4:12 PM Kyle Meyer  wrote:
>
>> Nathan Neff writes:
>>
>> > I'm having a difficult time using regular expressions in custom
>> > "tags-todo" agenda views.
>> >
>> > Is it possible to create custom agenda views using regular expressions,
>> > and if so, do I need to escape certain characters?
>> >
>> > I can't get a simple regex like this to work, so I'm suspecting that
>> > I'm doing something wrong or, it's simply not possible to create custom
>> > agenda views that use regular expressions to search for tags.
>> >
>> > For example, this expression doesn't even find headings with :projectA:
>> > as a tag
>> >
>> >   (setq org-agenda-custom-commands
>> >   '(
>> >  ("1" tags-todo "{projectA}")))
>>
>> My understanding is that the above should work.  I tried your
>> org-agenda-custom-commands value with this agenda file:
>>
>> * TODO a
>>  :projectA:
>> * TODO b
>>  :projectB:
>> * TODO c
>>  :project:
>>
>> With an otherwise vanilla configuration and master (0c1740c91) checked
>> out, I see
>>
>> Headlines with TAGS match: {projectA}
>> Press ‘C-u r’ to search again
>>   scratch:TODO a
>> :projectA:
>>
>> I see the same thing on maint (3ed035ce3).
>>
>
> Thanks - I'm using Org 9.3.6 and I'm getting no matches when using emacs -q
>
> I had some other issues w/regexes and Bastien fixed them in "maint":
>
> https://code.orgmode.org/bzg/org-mode/commit/c0d08b7efe740c17a3eec28984161c05e43da5ef
>
> Is it relatively easy to try org-mode's "maint" version (e.g. just check
> out branch from
> https://code.orgmode.org/bzg/org-mode ?)  I'll try using the "maint"
> version to see what's up.
>
> Thanks,
> --Nate
>
>


Re: Using regular expressions in custom agenda views

2020-06-28 Thread Nathan Neff
Still isn't working with org-mode 9.3.7 (org-20200622) and
using emacs -q

I have this file:

* One
 :project:a:work:boss:projectA:
:PROPERTIES:
:Effort:   1:00
:END:
* Two
 :projectB:
:PROPERTIES:
:Effort:   2:00
:END:

* Bar
 :pt:project:b:


And this custom view returns nothing:
(setq org-agenda-custom-commands
 '(("1" tags-todo "{projectA}")))

If I do a tags-todo search manually and use this syntax: {projectA}
it works.

Ideas?

On Sun, Jun 28, 2020 at 5:28 PM Nathan Neff  wrote:

> G I tried "package update" and package mgr in Emacs kept telling me
> that Org 9.3.6 was the latest.  Now I look @ orgmode.org and see 9.3.7 -
> I'll try that first
> after I figure out how to get that "package" or whatever that thing is to
> actually show the latest
> versions of packages.
>
> On Sun, Jun 28, 2020 at 5:27 PM Nathan Neff  wrote:
>
>>
>>
>> On Sun, Jun 28, 2020 at 4:12 PM Kyle Meyer  wrote:
>>
>>> Nathan Neff writes:
>>>
>>> > I'm having a difficult time using regular expressions in custom
>>> > "tags-todo" agenda views.
>>> >
>>> > Is it possible to create custom agenda views using regular expressions,
>>> > and if so, do I need to escape certain characters?
>>> >
>>> > I can't get a simple regex like this to work, so I'm suspecting that
>>> > I'm doing something wrong or, it's simply not possible to create custom
>>> > agenda views that use regular expressions to search for tags.
>>> >
>>> > For example, this expression doesn't even find headings with :projectA:
>>> > as a tag
>>> >
>>> >   (setq org-agenda-custom-commands
>>> >   '(
>>> >  ("1" tags-todo "{projectA}")))
>>>
>>> My understanding is that the above should work.  I tried your
>>> org-agenda-custom-commands value with this agenda file:
>>>
>>> * TODO a
>>>  :projectA:
>>> * TODO b
>>>  :projectB:
>>> * TODO c
>>>  :project:
>>>
>>> With an otherwise vanilla configuration and master (0c1740c91) checked
>>> out, I see
>>>
>>> Headlines with TAGS match: {projectA}
>>> Press ‘C-u r’ to search again
>>>   scratch:TODO a
>>>   :projectA:
>>>
>>> I see the same thing on maint (3ed035ce3).
>>>
>>
>> Thanks - I'm using Org 9.3.6 and I'm getting no matches when using emacs
>> -q
>>
>> I had some other issues w/regexes and Bastien fixed them in "maint":
>>
>> https://code.orgmode.org/bzg/org-mode/commit/c0d08b7efe740c17a3eec28984161c05e43da5ef
>>
>> Is it relatively easy to try org-mode's "maint" version (e.g. just check
>> out branch from
>> https://code.orgmode.org/bzg/org-mode ?)  I'll try using the "maint"
>> version to see what's up.
>>
>> Thanks,
>> --Nate
>>
>>
>


Re: Using regular expressions in custom agenda views

2020-06-28 Thread Nathan Neff
More wonkiness:

This custom view (no regexes) doesn't work, but manually entering projectA
(no quotes) in a tags-todo search
*does* work - so maybe my problem isn't regexes, but something else with my
org-agenda-custom-commands . . . .

(setq org-agenda-custom-commands
 '(("1" tags-todo "projectA")))



On Sun, Jun 28, 2020 at 5:39 PM Nathan Neff  wrote:

> Still isn't working with org-mode 9.3.7 (org-20200622) and
> using emacs -q
>
> I have this file:
>
> * One
>  :project:a:work:boss:projectA:
> :PROPERTIES:
> :Effort:   1:00
> :END:
> * Two
>  :projectB:
> :PROPERTIES:
> :Effort:   2:00
> :END:
>
> * Bar
>  :pt:project:b:
>
>
> And this custom view returns nothing:
> (setq org-agenda-custom-commands
>  '(("1" tags-todo "{projectA}")))
>
> If I do a tags-todo search manually and use this syntax: {projectA}
> it works.
>
> Ideas?
>
> On Sun, Jun 28, 2020 at 5:28 PM Nathan Neff  wrote:
>
>> G I tried "package update" and package mgr in Emacs kept telling me
>> that Org 9.3.6 was the latest.  Now I look @ orgmode.org and see 9.3.7 -
>> I'll try that first
>> after I figure out how to get that "package" or whatever that thing is to
>> actually show the latest
>> versions of packages.
>>
>> On Sun, Jun 28, 2020 at 5:27 PM Nathan Neff 
>> wrote:
>>
>>>
>>>
>>> On Sun, Jun 28, 2020 at 4:12 PM Kyle Meyer  wrote:
>>>
 Nathan Neff writes:

 > I'm having a difficult time using regular expressions in custom
 > "tags-todo" agenda views.
 >
 > Is it possible to create custom agenda views using regular
 expressions,
 > and if so, do I need to escape certain characters?
 >
 > I can't get a simple regex like this to work, so I'm suspecting that
 > I'm doing something wrong or, it's simply not possible to create
 custom
 > agenda views that use regular expressions to search for tags.
 >
 > For example, this expression doesn't even find headings with
 :projectA:
 > as a tag
 >
 >   (setq org-agenda-custom-commands
 >   '(
 >  ("1" tags-todo "{projectA}")))

 My understanding is that the above should work.  I tried your
 org-agenda-custom-commands value with this agenda file:

 * TODO a
  :projectA:
 * TODO b
  :projectB:
 * TODO c
  :project:

 With an otherwise vanilla configuration and master (0c1740c91) checked
 out, I see

 Headlines with TAGS match: {projectA}
 Press ‘C-u r’ to search again
   scratch:TODO a
   :projectA:

 I see the same thing on maint (3ed035ce3).

>>>
>>> Thanks - I'm using Org 9.3.6 and I'm getting no matches when using emacs
>>> -q
>>>
>>> I had some other issues w/regexes and Bastien fixed them in "maint":
>>>
>>> https://code.orgmode.org/bzg/org-mode/commit/c0d08b7efe740c17a3eec28984161c05e43da5ef
>>>
>>> Is it relatively easy to try org-mode's "maint" version (e.g. just check
>>> out branch from
>>> https://code.orgmode.org/bzg/org-mode ?)  I'll try using the "maint"
>>> version to see what's up.
>>>
>>> Thanks,
>>> --Nate
>>>
>>>
>>


Re: Using regular expressions in custom agenda views

2020-06-28 Thread Nathan Neff
On Sun, Jun 28, 2020 at 5:48 PM Nathan Neff  wrote:

> More wonkiness:
>
> This custom view (no regexes) doesn't work, but manually entering projectA
> (no quotes) in a tags-todo search
> *does* work - so maybe my problem isn't regexes, but something else with
> my org-agenda-custom-commands . . . .
>
> (setq org-agenda-custom-commands
>  '(("1" tags-todo "projectA")))
>
>
Okay - calm down - it was the fact that I was using the "tags" search to
manually search and
my custom view was using tags-todo.

Regexes are working now - sorry for the spam!

--Nate


>
>
> On Sun, Jun 28, 2020 at 5:39 PM Nathan Neff  wrote:
>
>> Still isn't working with org-mode 9.3.7 (org-20200622) and
>> using emacs -q
>>
>> I have this file:
>>
>> * One
>>  :project:a:work:boss:projectA:
>> :PROPERTIES:
>> :Effort:   1:00
>> :END:
>> * Two
>>  :projectB:
>> :PROPERTIES:
>> :Effort:   2:00
>> :END:
>>
>> * Bar
>>  :pt:project:b:
>>
>>
>> And this custom view returns nothing:
>> (setq org-agenda-custom-commands
>>  '(("1" tags-todo "{projectA}")))
>>
>> If I do a tags-todo search manually and use this syntax: {projectA}
>> it works.
>>
>> Ideas?
>>
>> On Sun, Jun 28, 2020 at 5:28 PM Nathan Neff 
>> wrote:
>>
>>> G I tried "package update" and package mgr in Emacs kept telling me
>>> that Org 9.3.6 was the latest.  Now I look @ orgmode.org and see 9.3.7
>>> - I'll try that first
>>> after I figure out how to get that "package" or whatever that thing is
>>> to actually show the latest
>>> versions of packages.
>>>
>>> On Sun, Jun 28, 2020 at 5:27 PM Nathan Neff 
>>> wrote:
>>>


 On Sun, Jun 28, 2020 at 4:12 PM Kyle Meyer  wrote:

> Nathan Neff writes:
>
> > I'm having a difficult time using regular expressions in custom
> > "tags-todo" agenda views.
> >
> > Is it possible to create custom agenda views using regular
> expressions,
> > and if so, do I need to escape certain characters?
> >
> > I can't get a simple regex like this to work, so I'm suspecting that
> > I'm doing something wrong or, it's simply not possible to create
> custom
> > agenda views that use regular expressions to search for tags.
> >
> > For example, this expression doesn't even find headings with
> :projectA:
> > as a tag
> >
> >   (setq org-agenda-custom-commands
> >   '(
> >  ("1" tags-todo "{projectA}")))
>
> My understanding is that the above should work.  I tried your
> org-agenda-custom-commands value with this agenda file:
>
> * TODO a
>  :projectA:
> * TODO b
>  :projectB:
> * TODO c
>  :project:
>
> With an otherwise vanilla configuration and master (0c1740c91) checked
> out, I see
>
> Headlines with TAGS match: {projectA}
> Press ‘C-u r’ to search again
>   scratch:TODO a
> :projectA:
>
> I see the same thing on maint (3ed035ce3).
>

 Thanks - I'm using Org 9.3.6 and I'm getting no matches when using
 emacs -q

 I had some other issues w/regexes and Bastien fixed them in "maint":

 https://code.orgmode.org/bzg/org-mode/commit/c0d08b7efe740c17a3eec28984161c05e43da5ef

 Is it relatively easy to try org-mode's "maint" version (e.g. just
 check out branch from
 https://code.orgmode.org/bzg/org-mode ?)  I'll try using the "maint"
 version to see what's up.

 Thanks,
 --Nate


>>>


Re: [PATCH] allow for multiline headers

2020-06-28 Thread Nicolas Goaziou
Hello,

Mario Frasca  writes:

> On 24/06/2020 02:19, Nicolas Goaziou wrote:
>>
 This could be extracted as an independent function, which would return
 the header, or nil. We can also imagine a function returning a cons cell
 (HEADER . BODY), both HEADER and BODY being list of rows (possibly
 empty).
>>> I was thinking of this myself too.  but, after all, the goal of this
>>> function is not only to find the header, but to collapse it into
>>> a single line.
>> I suggested this because you were saying earlier in this thread IIRC
>> that Org has no tooling to handle table headers.
> I would like to discuss this in a chat, who's available to join
> #org-mode on freenode?

Note that, usually, discussions happen on this mailing list, so anyone
can comment, not only those available on the IRC channel at a given
time.

>>> if it was splitting the header from the body, then yes, it would
>>> definitely make sense, the cons cell you suggest.
>> It _is_ splitting the header from the body. Barring initial `hline'
>> symbols, header-lines and trailer variables are exactly HEADER and BODY
>> above.
> same as above, I wish to hear opinions, collect them, and that we take
> a decision with shorter communication lines.

I'm sorry if I'm not fast enough to answer. In any case, the above is
just a suggestion.

>>> +  (table (org-table-collapse-header (org-table-to-lisp)))
>>> +  (num-cols (length (car table
>> Note that there is no guarantee that all rows have the same length.
>> E.g.,
>>
>>| a |
>>| b | c |
>
> many other points in the code assume rows have the same length.

That's true. However, the above is still a correct table, so it is good
to keep it in mind. No worries if you don't want to take care of that
particular point.

> I think I have processed most other remarks in the new patch.

I applied your patch. Thank you.

Regards,
-- 
Nicolas Goaziou



Re: Smart processing of http(s) links

2020-06-28 Thread Ag Ibragimov



Oh cool. This is exactly what I needed:

I was able to build this:

#+begin_src emacs-lisp
(defun get-gh-item-title (uri &optional include-number?)
 "Based on given github URI for (pull request or an issue),
 returns its title"
 (when (string-match "\\(github.com\\).*\\(issues\\|pull\\)" uri) ; either PR 
or issue
   (pcase-let* ((`(_ _ ,owner ,repo ,type ,number) (remove "" (split-string uri 
"/")))
(gh-resource (format "/repos/%s/%s/%s/%s"
 owner
 repo
 (if (string= type "pull") "pulls" type)
 number))
(resp (ghub-get gh-resource nil :auth 'forge)))
 (when resp
   (format "%s%s" (alist-get 'title resp)
   (when include-number? (format " #%s" number)))

(defun org-link-make-description-function* (link desc)
 (cond ((string-match "\\(github.com\\).*\\(issues\\|pull\\)" link)
(get-gh-item-title link :with-number))
   (t desc)))

(setq org-link-make-description-function 'org-link-make-description-function*)
#+end_src

https://gist.github.com/agzam/b2f2d441acb96e1d693a2c81e9c4518f
On Sun 28 Jun 2020 at 14:02, Kyle Meyer  wrote:


Ag Ibragimov writes:


Whenever I I use org-insert-link and it turns out to be a URI that
starts with "https://github.com"; I would like it to be processed
differently than any other link, one example - if it is a PR or a
Github Issue, I'd like it to fetch summary(title) of it and create a
link that looks like this:

[[https://github.com/user/repo/issues/3899][This issue needs to be fixed #3899]]

Do we have any "built-in" mechanism for doing something like this? Can
someone suggest how I can make it. Thank you!


You can set org-link-make-description-function to a function that
detects links of interest and generates a custom description.





[PATCH] ob-java support for variables, functional mode, tramp, add tests

2020-06-28 Thread ian martins
Hello. Attached is a patch to update the ob-java.el implementation. This
allows package, class and imports to be provided in the code or header
arguments or omitted, accepts variables, supports functional mode (:results
value), writes temp files to the temp directory instead of current dir,
works with tramp, and adds tests.

The "writes temp files to the temp directory" forced changes in ob-core in
order to write and delete directories to the temp directory.

Please review.
Ian
From 3d66247e3aabead7cf1bda4930f0b7a84e3ee324 Mon Sep 17 00:00:00 2001
From: Ian Martins 
Date: Sun, 28 Jun 2020 19:27:08 -0400
Subject: [PATCH] Update ob-java to allow functional mode, accept variables,
 work with tramp, etc

* ob-core.el (org-babel-temp-file,
org-babel-remove-temporary-directory): Create and remove temp
directories.
* ob-java.el: Add support for functional mode, variables, make class
and main method definitions optional, write files in temporary
directory, work with tramp.
* ob-java-test.org: New test data.
* test-ob-java.el: New tests.

Java requires source files names and directories to match their class
and package names.  The old implementation wrote these directories and
files in the current directory.  We move these files to the temporary
directory to work with tramp and avoid polluting the current
directory.  In order to move these files to the temporary directory we
have to modify ob-core to write and remove diretories.
---
 lisp/ob-core.el   |  55 ++---
 lisp/ob-java.el   | 340 ++
 testing/examples/ob-java-test.org | 310 +++
 testing/lisp/test-ob-java.el  | 294 ++
 4 files changed, 932 insertions(+), 67 deletions(-)
 create mode 100644 testing/examples/ob-java-test.org
 create mode 100644 testing/lisp/test-ob-java.el

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index e798595bd..4c22522e3 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -3078,17 +3078,17 @@ Emacs shutdown."))
 	   ,@table-forms)
 (def-edebug-spec org-babel-result-cond (form form body))
 
-(defun org-babel-temp-file (prefix &optional suffix)
+(defun org-babel-temp-file (prefix &optional suffix dir-flag)
   "Create a temporary file in the `org-babel-temporary-directory'.
-Passes PREFIX and SUFFIX directly to `make-temp-file' with the
-value of `temporary-file-directory' temporarily set to the value
-of `org-babel-temporary-directory'."
+Passes PREFIX, SUFFIX and DIR-FLAG directly to `make-temp-file'
+with the value of `temporary-file-directory' temporarily set to
+the value of `org-babel-temporary-directory'."
   (if (file-remote-p default-directory)
   (let ((prefix
  (concat (file-remote-p default-directory)
  (expand-file-name
 		  prefix org-babel-remote-temporary-directory
-(make-temp-file prefix nil suffix))
+(make-temp-file prefix dir-flag suffix))
 (let ((temporary-file-directory
 	   (or (and (boundp 'org-babel-temporary-directory)
 		(file-exists-p org-babel-temporary-directory)
@@ -3099,25 +3099,32 @@ of `org-babel-temporary-directory'."
 (defun org-babel-remove-temporary-directory ()
   "Remove `org-babel-temporary-directory' on Emacs shutdown."
   (when (and (boundp 'org-babel-temporary-directory)
-	 (file-exists-p org-babel-temporary-directory))
-;; taken from `delete-directory' in files.el
-(condition-case nil
-	(progn
-	  (mapc (lambda (file)
-		  ;; This test is equivalent to
-		  ;; (and (file-directory-p fn) (not (file-symlink-p fn)))
-		  ;; but more efficient
-		  (if (eq t (car (file-attributes file)))
-		  (delete-directory file)
-		(delete-file file)))
-		(directory-files org-babel-temporary-directory 'full
- directory-files-no-dot-files-regexp))
-	  (delete-directory org-babel-temporary-directory))
-  (error
-   (message "Failed to remove temporary Org-babel directory %s"
-		(if (boundp 'org-babel-temporary-directory)
-		org-babel-temporary-directory
-		  "[directory not defined]"))
+ (file-exists-p org-babel-temporary-directory))
+;; This is equivalent to "rm -rf * dir" so we should be really
+;; sure `dir' isn't /.  This is made safer but more brittle by
+;; filtering the first level files by the emacs tmpfile format.
+(if (< (length org-babel-temporary-directory) 3)
+(message (concat "Not deleting babel temp subdirectories since "
+ "`babel-temporary-directory' doesn't appear "
+ "to be set to a temporary directory."))
+  ;; taken from `delete-directory' in files.el
+  (condition-case nil
+  (progn
+(mapc (lambda (file)
+;; This test is equivalent to
+;; (and (file-directory-p fn) (not (file-symlink-p fn)))
+;; but more efficient
+(if (eq t (car (file-attributes file)))
+(de

Re: [PATCH] allow for multiline headers

2020-06-28 Thread Mario Frasca

On 28/06/2020 18:17, Nicolas Goaziou wrote:

This could be extracted as an independent function, which would return
the header, or nil. We can also imagine a function returning a cons cell
(HEADER . BODY), both HEADER and BODY being list of rows (possibly
empty).


not only this … it could also be like (:header HEADER :body BODY :body 
BODY), that is, repeating block.


I don't know, just doubting how to be more general.

in practice, I'm thinking of the case when I have a header, a body, and 
a summary, and I'm only interested in the header and body, not the summary.


just scattered thoughts … who fills in?




Re: Smart processing of http(s) links

2020-06-28 Thread Tim Cross


Ag Ibragimov  writes:

> I want to make something like this:
>
> Whenever I I use org-insert-link and it turns out to be a URI that starts 
> with "https://github.com"; I would like it to be processed differently than 
> any other link, one example - if it is a PR or a Github Issue, I'd like it to 
> fetch summary(title) of it and create a link that looks like this:
>
> [[https://github.com/user/repo/issues/3899][This issue needs to be fixed 
> #3899]]
>
> Do we have any "built-in" mechanism for doing something like this? Can 
> someone suggest how I can make it. Thank you!

I suspect you could do something with browse-url. The issue I see here
is why you would want the contents fetched whenever you insert a link or
where this summary(title). I guess I don't really understand what
exactly is your use case here - everything I can think of seems more
complicated and requiring more maintenance than just typing the
appropriate description when you insert the link.


-- 
Tim Cross



Re: Smart processing of http(s) links

2020-06-28 Thread Ag Ibragimov

seems more
complicated and requiring more maintenance than just typing the
appropriate description when you insert the link.


Actually, it is not. See my reply to Kyle. You still can modify the link 
description, it just gives you an option to make it as the title of the GitHub 
issue or PR.

https://gist.github.com/agzam/b2f2d441acb96e1d693a2c81e9c4518f