Re: [O] Bug: Description of org agenda columns format in manual not correct/misleading

2019-08-16 Thread Carsten Dominik
Hi,

On Thu, Aug 15, 2019 at 9:50 AM Fraga, Eric  wrote:

> On Wednesday, 14 Aug 2019 at 15:57, Nick Dokos wrote:
> > "Fraga, Eric"  writes:
> >
> >> I have this setting in my Emacs initialization:
> >>
> >> (setq org-agenda-overriding-columns-format "%5TODO %TIMESTAMP %40ITEM
> %LOCATION %TAGS")
> >>
> >> HTH,
> >> eric
> >
> > Shouldn't you be using org-columns-default-format instead?
>
> No because it's about setting the columns format for the agenda view
> alone, not the format for normal org buffers.  My error was in using a
> deprecated variable; the actual variable is
> org-overriding-columns-format.
>
> The OP's post was actually about the documentation (which I
> misunderstood).
>

I have discussed this problem with Allen Li, who fixed a bug in the agenda
column setting a while ago.

I think what is missing to make this more transparent is a variable
`org-default-columns-format-for-agenda' which is a proper user option.
This option can be set in your init.el or through customize, and it will
provide a default format for the agenda.  `org-overriding-columns-format
should ONLY EVER be used in the local setting section of a custom agenda
view.

This new variable is not available in master.

- Carsten


[O] Insert subheading at top respect content

2019-08-16 Thread Nathan Neff
Hello all,

Something that's eluded me all this time has been an
"Insert subheading, after the content, but before other subheadings"

For example:
If my cursor is anywhere between lines 1 and 4, I would like the subheading
to be inserted at line 5.

1* Heading
:PROPERTIES:...
2 Some content
3 More content
4
5** Subheading 1
6** Subheading 2
7
I know there's org-insert-subheading and C-u which respects content, but
respect-content will insert a subheading at line 7 in the example above.  I
would
like to have a new subheading at line 4.

Thanks,
--Nate


Re: [O] Insert subheading at top respect content

2019-08-16 Thread Carsten Dominik
On Fri, Aug 16, 2019 at 10:21 AM Nathan Neff  wrote:

> Hello all,
>
> Something that's eluded me all this time has been an
> "Insert subheading, after the content, but before other subheadings"
>
> For example:
> If my cursor is anywhere between lines 1 and 4, I would like the subheading
> to be inserted at line 5.
>
> 1* Heading
> :PROPERTIES:...
> 2 Some content
> 3 More content
> 4
> 5** Subheading 1
> 6** Subheading 2
> 7
> I know there's org-insert-subheading and C-u which respects content, but
> respect-content will insert a subheading at line 7 in the example above.
> I would
> like to have a new subheading at line 4.
>

What about C-c C-n M-RET

Carsten


>
> Thanks,
> --Nate
>


Re: [O] Bug: Description of org agenda columns format in manual not correct/misleading

2019-08-16 Thread Andrew Francis Swann
Dear Carsten,

This sounds like a very good solution.  I look forward to it being implemented.

Andrew

--
Andrew Swann | Associate Professor | Tel +45 871 55767 | 
sw...@math.au.dk | http://home.math.au.dk/swann/ | 
Department of Mathematics, Aarhus University, Ny Munkegade 118, Bldg 1530, 
DK-8000 Aarhus C, Denmark | Dept +45 871 5 | Fax +45 8613 1769


From: Emacs-orgmode  on behalf 
of Carsten Dominik 
Date: Friday, 16 August 2019 at 10:19
To: "Fraga, Eric" 
Cc: Nick Dokos , Org mode 
Subject: Re: [O] Bug: Description of org agenda columns format in manual not 
correct/misleading

Hi,

On Thu, Aug 15, 2019 at 9:50 AM Fraga, Eric 
mailto:e.fr...@ucl.ac.uk>> wrote:
On Wednesday, 14 Aug 2019 at 15:57, Nick Dokos wrote:
> "Fraga, Eric" mailto:e.fr...@ucl.ac.uk>> writes:
>
>> I have this setting in my Emacs initialization:
>>
>> (setq org-agenda-overriding-columns-format "%5TODO %TIMESTAMP %40ITEM 
>> %LOCATION %TAGS")
>>
>> HTH,
>> eric
>
> Shouldn't you be using org-columns-default-format instead?

No because it's about setting the columns format for the agenda view
alone, not the format for normal org buffers.  My error was in using a
deprecated variable; the actual variable is
org-overriding-columns-format.

The OP's post was actually about the documentation (which I
misunderstood).

I have discussed this problem with Allen Li, who fixed a bug in the agenda 
column setting a while ago.

I think what is missing to make this more transparent is a variable 
`org-default-columns-format-for-agenda' which is a proper user option.  This 
option can be set in your init.el or through customize, and it will provide a 
default format for the agenda.  `org-overriding-columns-format should ONLY EVER 
be used in the local setting section of a custom agenda view.

This new variable is not available in master.

- Carsten


Re: [O] Bug: Description of org agenda columns format in manual not correct/misleading

2019-08-16 Thread Carsten Dominik
It is already in the git master branch.

Carsten

On Fri, Aug 16, 2019 at 1:46 PM Andrew Francis Swann 
wrote:

> Dear Carsten,
>
>
>
> This sounds like a very good solution.  I look forward to it being
> implemented.
>
>
>
> Andrew
>
>
>
> --
>
> Andrew Swann | Associate Professor | Tel +45 871 55767 | sw...@math.au.dk |
> http://home.math.au.dk/swann/ | Department of Mathematics, Aarhus
> University, Ny Munkegade 118, Bldg 1530, DK-8000 Aarhus C, Denmark | Dept
> +45 871 5 | Fax +45 8613 1769
>
>
>
>
>
> *From: *Emacs-orgmode  on
> behalf of Carsten Dominik 
> *Date: *Friday, 16 August 2019 at 10:19
> *To: *"Fraga, Eric" 
> *Cc: *Nick Dokos , Org mode 
> *Subject: *Re: [O] Bug: Description of org agenda columns format in
> manual not correct/misleading
>
>
>
> Hi,
>
>
>
> On Thu, Aug 15, 2019 at 9:50 AM Fraga, Eric  wrote:
>
> On Wednesday, 14 Aug 2019 at 15:57, Nick Dokos wrote:
> > "Fraga, Eric"  writes:
> >
> >> I have this setting in my Emacs initialization:
> >>
> >> (setq org-agenda-overriding-columns-format "%5TODO %TIMESTAMP %40ITEM
> %LOCATION %TAGS")
> >>
> >> HTH,
> >> eric
> >
> > Shouldn't you be using org-columns-default-format instead?
>
> No because it's about setting the columns format for the agenda view
> alone, not the format for normal org buffers.  My error was in using a
> deprecated variable; the actual variable is
> org-overriding-columns-format.
>
> The OP's post was actually about the documentation (which I
> misunderstood).
>
>
>
> I have discussed this problem with Allen Li, who fixed a bug in the agenda
> column setting a while ago.
>
>
>
> I think what is missing to make this more transparent is a variable
> `org-default-columns-format-for-agenda' which is a proper user option.
> This option can be set in your init.el or through customize, and it will
> provide a default format for the agenda.  `org-overriding-columns-format
> should ONLY EVER be used in the local setting section of a custom agenda
> view.
>
>
>
> This new variable is not available in master.
>
>
>
> - Carsten
>


Re: [O] NLS/Augment

2019-08-16 Thread Jean Louis
* John Kitchin  [2019-08-14 15:53]:
> strange. It has always worked fine for me. It turns out in the long run I
> don't use it much, C-c C-c does the same thing on check boxes, and speed
> commands on headings end up being easier to use for me.  YMMV of course.

Please tell me how do you use it? How do you invoke mouse to work in
Org mode?

I do this:

emacs -Q

in scratch:

(require 'org-mouse)

Then I open Org file, nothing I can see nor change with mouse.

So tell me how do you do it that it works.

Thank you,
Jean



Re: [O] NLS/Augment

2019-08-16 Thread John Kitchin
That is the right thing to do I think.  The only differences you should see
is when the mouse pointer is over a star in a headline, it should highlight
with a mouse face, and if you click on the highlighted region it should
cycle the headline open and closed. Similarly, the [ ] in a checkbox should
get highlighted, and if you click on it, it should toggle its state. There
might also be some right click menus.


John

---
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



On Fri, Aug 16, 2019 at 10:05 AM Jean Louis  wrote:

> * John Kitchin  [2019-08-14 15:53]:
> > strange. It has always worked fine for me. It turns out in the long run I
> > don't use it much, C-c C-c does the same thing on check boxes, and speed
> > commands on headings end up being easier to use for me.  YMMV of course.
>
> Please tell me how do you use it? How do you invoke mouse to work in
> Org mode?
>
> I do this:
>
> emacs -Q
>
> in scratch:
>
> (require 'org-mouse)
>
> Then I open Org file, nothing I can see nor change with mouse.
>
> So tell me how do you do it that it works.
>
> Thank you,
> Jean
>


Re: [O] NLS/Augment

2019-08-16 Thread Jean Louis
* John Kitchin  [2019-08-16 16:15]:
> That is the right thing to do I think.  The only differences you
> should see is when the mouse pointer is over a star in a headline,
> it should highlight with a mouse face, and if you click on the
> highlighted region it should cycle the headline open and
> closed. Similarly, the [ ] in a checkbox should get highlighted, and
> if you click on it, it should toggle its state. There might also be
> some right click menus.

Now I got it, thank you.

Yes, it is good this way, at least for start.

I just wish Emacs would have the entry to structural and organized
information as Doug Engelbart envisioned it. There are many functions
for that, scattered around, not yet integrated.

Mouse is explained in Org documentation. But so short that common man
cannot quite find it.

Only this:
==
To toggle a checkbox, use ‘C-c C-c’, or use
the mouse (thanks to Piotr Zielinski’s ‘org-mouse.el’).

and

• Piotr Zielinski wrote ‘org-mouse.el’, proposed agenda blocks and
  contributed various ideas and code snippets.

that is scarce description. In fact it should be enabled by default or
exist in menu to be toggled.

Emacs has all capabilities for information management system, and yet
we are so far from what Doug Engelbart[1] envisioned 50 years ago.

Jean


Footnotes:
[1]  
http://www.dougengelbart.org/templates/bootstrap_template/images/bootstrap-alliance-2.jpg




Re: [O] NLS/Augment

2019-08-16 Thread Jean Louis
* Samuel Wales  [2019-08-14 21:57]:
> org-mouse works well for me and i depend on it frequently.
> 
> the main thing i am missing in it is the ability to select a todo kw
> for a header.
> 
> i use require.  i never understood modules or their purpose.

I would like to know if Carsten Dominik came up with idea by knowing
about Doug Engelbart?

Jean



[O] [PATCH] org.el (org-todo): Respect state argument when called from elisp

2019-08-16 Thread Renato Ferreira


(org-todo): Fast selection should only be shown if a state argument was not used
* list/org.el (org-todo): Respect argument when called from elisp
when calling from elisp (such as in `org-clock-in').

TINYCHANGE
---
 lisp/org.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 2451273e0..1b91adc18 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10100,9 +10100,6 @@ When called through ELisp, arg is also interpreted in 
the following way:
(length tail) 2)
 org-todo-keywords-1)
  (org-last org-todo-keywords-1
-((and org-todo-key-trigger 
org-use-fast-todo-selection)
- ;; Use fast selection.
- (org-fast-todo-selection this))
 (arg
  ;; User or caller requests a specific state.
  (cond
@@ -10121,7 +10118,9 @@ When called through ELisp, arg is also interpreted in 
the following way:
(user-error "State `%s' not valid in this file" 
arg))
   ((nth (1- (prefix-numeric-value arg))
 org-todo-keywords-1
+((and org-todo-key-trigger 
org-use-fast-todo-selection)
+ ;; Use fast selection.
+ (org-fast-todo-selection this))
 ((null member) (or head (car org-todo-keywords-1)))
 ((equal this final-done-word) nil) ;-> make empty
 ((null tail) nil) ;-> first entry
--
2.22.1

Message-ID: <87lfvtywo4@gmail.com>



Re: [O] NLS/Augment

2019-08-16 Thread Carsten Dominik
On Fri, Aug 16, 2019 at 4:59 PM Jean Louis  wrote:

> * Samuel Wales  [2019-08-14 21:57]:
> > org-mouse works well for me and i depend on it frequently.
> >
> > the main thing i am missing in it is the ability to select a todo kw
> > for a header.
> >
> > i use require.  i never understood modules or their purpose.
>

Yes, not sure if modules was a good idea.  I wanted a clickable list of
stuff
 to add, because the parts became so many.  Require is a fine replacement.


> I would like to know if Carsten Dominik came up with idea by knowing
> about Doug Engelbart?
>

Do you mean with Org-mode in general?  No, I learned about Engelbart later
and was amazed.

Carsten

>
> Jean
>
>


Re: [O] NLS/Augment

2019-08-16 Thread Jean Louis
* Carsten Dominik  [2019-08-16 23:13]:
> > I would like to know if Carsten Dominik came up with idea by
> > knowing about Doug Engelbart?
> >
> 
> Do you mean with Org-mode in general?  No, I learned about Engelbart
> later and was amazed.
> 
> Carsten

Thanks, good to know if you had inspiration by Engelbart.
Jean



Re: [O] [PATCH] org.el (org-todo): Respect state argument when called from elisp

2019-08-16 Thread Kyle Meyer
Renato Ferreira  writes:

> (org-todo): Fast selection should only be shown if a state argument was not 
> used
> * list/org.el (org-todo): Respect argument when called from elisp
> when calling from elisp (such as in `org-clock-in').

Thanks for the patch!  I hit this earlier today but hadn't yet looked
into it.  Testing this out, it fixes the issue introduced by f1c030bed
(Prefix argument to `org-todo' forces stage change logging, 2019-08-14),
while keeping the intended C-u behavior change from that patch.

> @@ -10121,7 +10118,9 @@ When called through ELisp, arg is also interpreted in 
> the following way:
>   (user-error "State `%s' not valid in this file" 
> arg))
>  ((nth (1- (prefix-numeric-value arg))
>org-todo-keywords-1
> +  ((and org-todo-key-trigger 
> org-use-fast-todo-selection)
> +   ;; Use fast selection.
> +   (org-fast-todo-selection this))
>((null member) (or head (car org-todo-keywords-1)))
>((equal this final-done-word) nil) ;-> make empty
>((null tail) nil) ;-> first entry

This patch didn't apply for me, and the hunk counts look off.  It should
be -10121,6, no?  Anyway, I've adjusted it so that it applies and pushed
it to master.  (I made a typo fix and a few small tweaks to your commit
message.)

-- 
Kyle



[O] Faster version of org-find-olp

2019-08-16 Thread Adam Porter
Hi,

While working on org-recent-headings, I thought I needed a version of
org-find-olp that behaved slightly differently, so I wrote a new
function.  It turned out that I didn't need the new function, but I
found that it seems to be much faster than org-find-olp, so it might be
worth using in Org.

Here is the code and test results.  The bench-multi-lexical macro is
from:

https://github.com/alphapapa/emacs-package-dev-handbook#bench-multi-macros

You'll note that it slightly differs in behavior in two ways:

1.  When an outline path is not found, it returns nil instead of raising
an error.  This could easily be changed to match the behavior of
org-find-olp, of course.  However, it makes the function easier to use
to check for the existence of an OLP without raising an error, and
AFAICT org-find-olp is only used in a few places, so it might be worth
considering to use this new behavior.

2.  Checking for duplicate OLPs is optional.  Sometimes it may be useful
to find an OLP regardless of whether a duplicate exists, and this allows
for that.

Provided are two versions of the function: the only difference between
them is that the *-named version uses:

  (format org-complex-heading-regexp-format ...)

...while the non-* version uses rx-to-string with an rx form.  The
rx-to-string version appears to be significantly faster.  I'm not sure
why.  Perhaps format is an expensive call--it's the only difference
between the two versions--but my cursory profiling didn't necessarily
indicate that was the source of the difference.

As far as finding duplicates, it seems to work properly in my testing.
But beware, I have only tested the code, not proven it correct.*  ;)

If this would be useful to have in Org, whether as a replacement for
org-find-olp or otherwise, I could submit a patch.

Thanks,
Adam#+BEGIN_SRC elisp :results silent
  (defun org-olp-marker (olp &optional this-buffer unique)
"Return a marker pointing to outline path OLP.
  Return nil if not found.  If THIS-BUFFER, search current buffer;
  otherwise search file found at path in first element of OLP.  If
  UNIQUE, display a warning if OLP points to multiple headings."
;; NOTE: Disabling `case-fold-search' is important to avoid voluntary hair loss.
(let* ((case-fold-search nil)
   (file (unless this-buffer
   (pop olp)))
   (buffer (if this-buffer
   (current-buffer)
 (or (find-file-noselect file)
 (error "File in outline path not found: %s" file)
  (cl-labels ((find-at (level headings)
   (let ((re (rx-to-string `(seq bol (repeat ,level "*") (1+ blank)
 (optional (1+ upper) (1+ blank)) ; To-do keyword
 (optional "[#" (in "ABC") "]" (1+ blank)) ; Priority
 ,(car headings) (0+ blank) (or eol ":")
 (when (re-search-forward re nil t)
   (when (and unique (save-excursion
   (save-restriction
 (when (re-search-forward re nil t)
   (if (cdr headings)
   (find-at (1+ level) (cdr headings))
 t)
 (display-warning 'org-recent-headings
  (format "Multiple headings found in %S for outline path: %S" (current-buffer) olp)
  :warning))
   (if (cdr headings)
   (progn
 (org-narrow-to-subtree)
 (find-at (1+ level) (cdr headings)))
 (copy-marker (point-at-bol)))
(with-current-buffer buffer
  (org-with-wide-buffer
   (goto-char (point-min))
   (find-at 1 olp))

  (defun org-olp-marker* (olp &optional this-buffer unique)
;; NOTE: This version uses `org-complex-heading-regexp-format'.
"Return a marker pointing to outline path OLP.
  Return nil if not found.  If THIS-BUFFER, search current buffer;
  otherwise search file found at path in first element of OLP.  If
  UNIQUE, display a warning if OLP points to multiple headings."
;; NOTE: Disabling `case-fold-search' is important to avoid voluntary hair loss.
(let* ((case-fold-search nil)
   (file (unless this-buffer
   (pop olp)))
   (buffer (if this-buffer
   (current-buffer)
 (or (find-file-noselect file)
 (error "File in outline path not found: %s" file)
  (c

Re: [O] Faster version of org-find-olp

2019-08-16 Thread Adam Porter
I see that using an "inline" attachment was a bad idea.  At least, the
lists.gnu.org Web UI wraps the lines.  Here it is as an "attachment"
attachment, in case that helps.

#+BEGIN_SRC elisp :results silent
  (defun org-olp-marker (olp &optional this-buffer unique)
"Return a marker pointing to outline path OLP.
  Return nil if not found.  If THIS-BUFFER, search current buffer;
  otherwise search file found at path in first element of OLP.  If
  UNIQUE, display a warning if OLP points to multiple headings."
;; NOTE: Disabling `case-fold-search' is important to avoid voluntary hair loss.
(let* ((case-fold-search nil)
   (file (unless this-buffer
   (pop olp)))
   (buffer (if this-buffer
   (current-buffer)
 (or (find-file-noselect file)
 (error "File in outline path not found: %s" file)
  (cl-labels ((find-at (level headings)
   (let ((re (rx-to-string `(seq bol (repeat ,level "*") (1+ blank)
 (optional (1+ upper) (1+ blank)) ; To-do keyword
 (optional "[#" (in "ABC") "]" (1+ blank)) ; Priority
 ,(car headings) (0+ blank) (or eol ":")
 (when (re-search-forward re nil t)
   (when (and unique (save-excursion
   (save-restriction
 (when (re-search-forward re nil t)
   (if (cdr headings)
   (find-at (1+ level) (cdr headings))
 t)
 (display-warning 'org-recent-headings
  (format "Multiple headings found in %S for outline path: %S" (current-buffer) olp)
  :warning))
   (if (cdr headings)
   (progn
 (org-narrow-to-subtree)
 (find-at (1+ level) (cdr headings)))
 (copy-marker (point-at-bol)))
(with-current-buffer buffer
  (org-with-wide-buffer
   (goto-char (point-min))
   (find-at 1 olp))

  (defun org-olp-marker* (olp &optional this-buffer unique)
;; NOTE: This version uses `org-complex-heading-regexp-format'.
"Return a marker pointing to outline path OLP.
  Return nil if not found.  If THIS-BUFFER, search current buffer;
  otherwise search file found at path in first element of OLP.  If
  UNIQUE, display a warning if OLP points to multiple headings."
;; NOTE: Disabling `case-fold-search' is important to avoid voluntary hair loss.
(let* ((case-fold-search nil)
   (file (unless this-buffer
   (pop olp)))
   (buffer (if this-buffer
   (current-buffer)
 (or (find-file-noselect file)
 (error "File in outline path not found: %s" file)
  (cl-labels ((find-at (level headings)
   (let ((re (format org-complex-heading-regexp-format (regexp-quote (car headings)
 (when (re-search-forward re nil t)
   (when (and unique (save-excursion
   (save-restriction
 (when (re-search-forward re nil t)
   (if (cdr headings)
   (find-at (1+ level) (cdr headings))
 t)
 (display-warning 'org-recent-headings
  (format "Multiple headings found in %S for outline path: %S" (current-buffer) olp)
  :warning))
   (if (cdr headings)
   (progn
 (org-narrow-to-subtree)
 (find-at (1+ level) (cdr headings)))
 (copy-marker (point-at-bol)))
(with-current-buffer buffer
  (org-with-wide-buffer
   (goto-char (point-min))
   (find-at 1 olp))
#+END_SRC

#+BEGIN_SRC elisp
  (let* ((content "* Text before [[Test heading]] Text after 1

  blah blah
  ,** Text before [[Test heading]] Text after 2

  foo bar
  ,*** Text before [[Test heading]] Text after 3

  buzz

  ")
 (olp '("Text before [[Test heading]] Text after 1