Re: [O] Structured links to headings with endless depth

2019-05-06 Thread Ihor Radchenko
Dear Michael,

> ... I want self-explaining links with the already existing and
> complete heading structure and don't want to add any ID, CUSTOM_ID or
> <>. See this example:

I am wondering why you are strictly against ID properties.

The IDs can be set automatically. The property drawer can be hidden (see
https://stackoverflow.com/questions/17478260/completely-hide-the-properties-drawer-in-org-mode)
and will not clutter you org file.

An arbitrary id link can be self-explaining if you add a proper link
description: [[id:your_id][composer_1/work_1/movement_1]]. Moreover it
is not fragile against refiling or duplicate entries.

Best,
Ihor


Michael Brand  writes:

> Hi all
>
> On Wed, Mar 14, 2018 at 7:58 AM Michael Brand
>  wrote:
>
>> ,(arbitrarily more levels upwards)
>> ,  * [...]
>> ,* 
>> ,  * 
>> ,* TODO 
>> ,  *  :5:
>> ,- The tag 5 is my rating of this audio recording.
>> ,- The audio recording is stored under the file path
>> ,  [...]/.mp3
>> ,
>> ,* TODO [...]
>> ,  - The theme is very similar to this prelude
>> ,[[/://]].
>> ,* [...]
>> ,  - [...] like in this piano concert
>> ,[[/:/]].
>
> Despite all the valuable recommendations in this thread I implemented
> something simple for my very specific use case of a music database
> where I want self-explaining links with the already existing and
> complete heading structure and don't want to add any ID, CUSTOM_ID or
> <>. See this example:
>
> #+begin_src org
> ,#+STARTUP: oddeven showeverything
>
> Specs for outline path of links to a heading, any combinations allowed
> including none:
> - "/" delimits headings of adjacent levels.
> - A leading "/" requires matching the top level heading.
> - "//" delimits heading levels with 0 to n discarded heading levels
> between them.
>
> Demo examples:
> - Goes to tag 1: [[*Chopin/Prelude]]
> - Goes to tag 2: [[*/Prelude]]
> - Goes to tag 3: [[*d/c//b/a]]
> - Goes to tag 4: [[*d/c/b/a]]
> ,* Foo
> ,** Bach
> ,*** Prelude
> ,** Chopin
> ,*** Prelude :1:
> ,* Prelude :2:
> ,* d
> ,** c
> ,*** Bar
> , Baz
> ,* b
> ,** a :3:
> ,*** b
> , a :4:
> #+end_src
>
> Limitations of this simplified implementation:
> - Export of links with a path to a heading is not supported.
> - Links to a heading with "/" that existed before are broken.
> - There may be other issues for your use case already discussed in the
> current thread (
> http://lists.gnu.org/archive/html/emacs-orgmode/2018-03/msg00231.html
> ).
>
> Due to the limitations this implementation is for private use only and
> not meant to be commited upstream although the format of the attached
> patches might imply that.
>
> Michael
> From 3a594dfa9967ed4fd70aae04559dde757fb21b1b Mon Sep 17 00:00:00 2001
> From: Michael Brand 
> Date: Mon, 6 May 2019 18:17:52 +0200
> Subject: [PATCH 1/2] org-get-heading: New parameter no-cookie
>
> * lisp/ol.el (org-link-search): Remove regexps for comment and cookie.
> * lisp/org.el (org-get-heading:): New parameter no-cookie used above.
> ---
>  lisp/ol.el  | 10 ++
>  lisp/org.el | 11 +--
>  2 files changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/lisp/ol.el b/lisp/ol.el
> index a6f76a39f..f5bd63e96 100644
> --- a/lisp/ol.el
> +++ b/lisp/ol.el
> @@ -1108,18 +1108,12 @@ of matched result, which is either `dedicated' or 
> `fuzzy'."
> (format "%s.*\\(?:%s[ \t]\\)?.*%s"
> org-outline-regexp-bol
> org-comment-string
> -   (mapconcat #'regexp-quote words ".+")))
> -  (cookie-re "\\[[0-9]*\\(?:%\\|/[0-9]*\\)\\]")
> -  (comment-re (format "\\`%s[ \t]+" org-comment-string)))
> +   (mapconcat #'regexp-quote words ".+"
>(goto-char (point-min))
>(catch :found
>  (while (re-search-forward title-re nil t)
>(when (equal words
> -   (split-string
> -(replace-regexp-in-string
> - cookie-re ""
> - (replace-regexp-in-string
> -  comment-re "" (org-get-heading t t t)
> +   (split-string (org-get-heading t t t t t)))
>  (throw :found t)))
>  nil)))
>(beginning-of-line)
> diff --git a/lisp/org.el b/lisp/org.el
> index 94713a7e5..48f7874ac 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -6938,12 +6938,14 @@ So this will delete or add empty lines."
>  (insert (make-string n ?\n))
>  (move-to-column column)))
>  
> -(defun org-get-heading ( no-tags no-todo no-priority no-comment)
> +(defun org-get-heading (
> + no-tags no-todo no-priority no-comment no-cookie)
>"Return the heading of the current entry, without the stars.
>  When NO-TAGS is non-nil, don't include tags.

[O] Suggested patch for org-agenda.el

2019-05-06 Thread Stefan Monnier
Misc changes:

- Assume Emacs≥22 (we're using defvaralias already anyway).
- Try to make sure -function only contain functions (and never nil).
- Use define-minor-mode and define-derived-mode.
- Use command remapping.
- Initialize map from within its definition.
- Use suppress-keymap.

There'd be more to do if we can assume ≥24.1, of course.


Stefan


diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el
index 23ee8d71e6..48e66c7acf 100644
--- a/lisp/org/org-agenda.el
+++ b/lisp/org/org-agenda.el
@@ -1928,7 +1928,7 @@ org-agenda-fontify-priorities
   (string :tag "Color")
   (sexp :tag "Face"))
 
-(defcustom org-agenda-day-face-function nil
+(defcustom org-agenda-day-face-function #'org-agenda--day-face-default
   "Function called to determine what face should be used to display a day.
 The only argument passed to that function is the day.  It should
 returns a face, or nil if does not want to specify a face and let
@@ -2067,10 +2067,6 @@ org-add-agenda-custom-command
 
 ;;; Define the org-agenda-mode
 
-(defvaralias 'org-agenda-keymap 'org-agenda-mode-map)
-(defvar org-agenda-mode-map (make-sparse-keymap)
-  "Keymap for `org-agenda-mode'.")
-
 (defvar org-agenda-menu) ; defined later in this file.
 (defvar org-agenda-restrict nil) ; defined later in this file.
 (defvar org-agenda-follow-mode nil)
@@ -2094,31 +2090,16 @@ org-agenda-current-date
 
 ;;; Multiple agenda buffers support
 
-(defcustom org-agenda-sticky nil
-  "Non-nil means agenda q key will bury agenda buffers.
-Agenda commands will then show existing buffer instead of generating new ones.
-When nil, `q' will kill the single agenda buffer."
-  :group 'org-agenda
-  :version "24.3"
-  :type 'boolean)
-
+(define-obsolete-variable-alias 'org-agenda-sticky 'org-agenda-sticky-mode 
"27.1")

 ;;;###autoload
-(defun org-toggle-sticky-agenda ( arg)
-  "Toggle `org-agenda-sticky'."
-  (interactive "P")
-  (let ((new-value (if arg
-  (> (prefix-numeric-value arg) 0)
-(not org-agenda-sticky
-(if (equal new-value org-agenda-sticky)
-   (and (called-interactively-p 'interactive)
-(message "Sticky agenda was already %s"
- (if org-agenda-sticky "enabled" "disabled")))
-  (setq org-agenda-sticky new-value)
-  (org-agenda-kill-all-agenda-buffers)
-  (and (called-interactively-p 'interactive)
-  (message "Sticky agenda %s"
-   (if org-agenda-sticky "enabled" "disabled"))
+(define-obsolete-function-alias 'org-toggle-sticky-agenda 
#'org-agenda-sticky-mode "27.1")
+(define-minor-mode org-agenda-sticky-mode
+  "When enabled, agenda `q' key will bury agenda buffers.
+Agenda commands will then show existing buffer instead of generating new ones.
+When this minor mode is disabled, `q' will kill the single agenda buffer."
+  :global t
+  (org-agenda-kill-all-agenda-buffers))
 
 (defvar org-agenda-buffer nil
   "Agenda buffer currently being generated.")
@@ -2159,51 +2140,191 @@ org-agenda-local-vars
 org-agenda-cycle-counter
 org-agenda-last-prefix-arg)
   "Variables that must be local in agenda buffers to allow multiple buffers.")
+(dolist (var org-agenda-local-vars)
+  (put var 'permanant-local t))
+
+(defvaralias 'org-agenda-keymap 'org-agenda-mode-map) ;FIXME: Unused!
+(defvar org-agenda-mode-map
+  (let ((map (make-sparse-keymap)))
+(suppress-keymap map) ;FIXME: Derive from special-mode instead (Emacs≥23).
+(org-defkey map [remap undo] org-agenda-undo)
+(org-defkey map "\C-i" 'org-agenda-goto)
+(org-defkey map [(tab)]'org-agenda-goto)
+(org-defkey map "\C-m" 'org-agenda-switch-to)
+(org-defkey map "\C-k" 'org-agenda-kill)
+(org-defkey map "\C-c\C-w" 'org-agenda-refile)
+(org-defkey map [(meta down)] 'org-agenda-drag-line-forward)
+(org-defkey map [(meta up)] 'org-agenda-drag-line-backward)
+(org-defkey map "m"'org-agenda-bulk-mark)
+(org-defkey map "\M-m" 'org-agenda-bulk-toggle)
+(org-defkey map "*"'org-agenda-bulk-mark-all)
+(org-defkey map "\M-*" 'org-agenda-bulk-toggle-all)
+(org-defkey map "#"'org-agenda-dim-blocked-tasks)
+(org-defkey map "%"'org-agenda-bulk-mark-regexp)
+(org-defkey map "u"'org-agenda-bulk-unmark)
+(org-defkey map "U"'org-agenda-bulk-unmark-all)
+(org-defkey map "B"'org-agenda-bulk-action)
+(org-defkey map "k"'org-agenda-capture)
+(org-defkey map "A"'org-agenda-append-agenda)
+(org-defkey map "\C-c\C-x!" 'org-reload)
+(org-defkey map "\C-c\C-x\C-a" 'org-agenda-archive-default)
+(org-defkey map "\C-c\C-xa"'org-agenda-toggle-archive-tag)
+(org-defkey map "\C-c\C-xA"'org-agenda-archive-to-archive-sibling)
+(org-defkey map "\C-c\C-x\C-s" 'org-agenda-archive)
+(org-defkey map "\C-c$"'org-agenda-archive)
+(org-defkey 

Re: [O] LaTeX export section level cutoff?

2019-05-06 Thread Christian Lynbech
Thanks a lot!

  -- Christian


---
On Mon, May 06 2019, William Denton wrote:

On 6 May 2019, Christian Lynbech wrote:

> What determines at what level LaTeX export goes from sections to
> enumerations?

According to this, by default it's three levels of sections, then it
turns into lists:

https://orgmode.org/org.html#LaTeX-header-and-sectioning

But H in the export settings (or org-export-headline-levels) can change that:

https://orgmode.org/org.html#Export-Settings


Bill
--
William Denton :: Toronto, Canada   ---   Listening to Art: 
https://listeningtoart.org/
https://www.miskatonic.org/ ---   GHG.EARTH: https://ghg.earth/
Caveat lector.  ---   STAPLR: http://staplr.org/



Re: [O] best ways to generate simple diagrams?

2019-05-06 Thread ckelty ckelty



Matt,

Did you already decide against graphviz?  Admittedly it is only 
graphs and not "diagrams"... but it's very powerful and there is 
art in using a simple tool to make your life complex :)



#+BEGIN_SRC dot :file test-dot.png  :exports results
digraph D {

 Humanities -> {"Computing Tools and Methodologies"}
 {"Computing Tools and Methodologies"} -> Humanities 


}
#+END_SRC

#+RESULTS:
[[file:test-dot.png]]


ck



Matt Price  writes:

So, I'm finding more and more that I want to include simple 
diagrams in my
course materials. At present I am generating them as svg's using 
Inkscape,
but that feels really tiresome to me. I would much rather make 
them
programmatically, preferably including the source code as an 
org-mode block.


I thought ditaa would be the tool for this, but I cannot figure 
out how to
do this work efficiently in ditaa.  So for instance, I have this 
simple svg
file (attached). It consists of two text-containing  symmetrical 
rectangles
separated by a bit of whitespace and connected by two curved 
arrows (one

pointing from each of the rectangles to the other).

Trying to replicate this in ditaa did not prove easy.  Editing 
feels
extremely labourious.  Am I missing something?  Is there a 
really good
tutorial somehwere that I'm just not finding? Or is there maybe 
another

tool I should be using instead?

Thanks as always,

Matt





Re: [O] best ways to generate simple diagrams?

2019-05-06 Thread Heinz Tuechler

Matt Price wrote/hat geschrieben on/am 06.05.2019 19:17:

So, I'm finding more and more that I want to include simple diagrams in my
course materials. At present I am generating them as svg's using Inkscape,
but that feels really tiresome to me. I would much rather make them
programmatically, preferably including the source code as an org-mode block.

I thought ditaa would be the tool for this, but I cannot figure out how to
do this work efficiently in ditaa.  So for instance, I have this simple svg
file (attached). It consists of two text-containing  symmetrical rectangles
separated by a bit of whitespace and connected by two curved arrows (one
pointing from each of the rectangles to the other).

Trying to replicate this in ditaa did not prove easy.  Editing feels
extremely labourious.  Am I missing something?  Is there a really good
tutorial somehwere that I'm just not finding? Or is there maybe another
tool I should be using instead?

Thanks as always,

Matt


Maybe plantuml (http://plantuml.com/en/) is useful, e.g.


#+begin_src plantuml :file hum-cs-interface-test.svg
skinparam ArrowColor Blue
node "Humanities" as H #DeepSkyBlue
node "Computing\n Tools and\n Methodologies" as N #DeepSkyBlue

N =l=> H
H =r=> N

#+end_src

best regards,

Heinz



[O] best ways to generate simple diagrams?

2019-05-06 Thread Matt Price
So, I'm finding more and more that I want to include simple diagrams in my
course materials. At present I am generating them as svg's using Inkscape,
but that feels really tiresome to me. I would much rather make them
programmatically, preferably including the source code as an org-mode block.

I thought ditaa would be the tool for this, but I cannot figure out how to
do this work efficiently in ditaa.  So for instance, I have this simple svg
file (attached). It consists of two text-containing  symmetrical rectangles
separated by a bit of whitespace and connected by two curved arrows (one
pointing from each of the rectangles to the other).

Trying to replicate this in ditaa did not prove easy.  Editing feels
extremely labourious.  Am I missing something?  Is there a really good
tutorial somehwere that I'm just not finding? Or is there maybe another
tool I should be using instead?

Thanks as always,

Matt


Re: [O] Structured links to headings with endless depth

2019-05-06 Thread Michael Brand
Hi all

On Wed, Mar 14, 2018 at 7:58 AM Michael Brand
 wrote:

> ,(arbitrarily more levels upwards)
> ,  * [...]
> ,* 
> ,  * 
> ,* TODO 
> ,  *  :5:
> ,- The tag 5 is my rating of this audio recording.
> ,- The audio recording is stored under the file path
> ,  [...]/.mp3
> ,
> ,* TODO [...]
> ,  - The theme is very similar to this prelude
> ,[[/://]].
> ,* [...]
> ,  - [...] like in this piano concert
> ,[[/:/]].

Despite all the valuable recommendations in this thread I implemented
something simple for my very specific use case of a music database
where I want self-explaining links with the already existing and
complete heading structure and don't want to add any ID, CUSTOM_ID or
<>. See this example:

#+begin_src org
,#+STARTUP: oddeven showeverything

Specs for outline path of links to a heading, any combinations allowed
including none:
- "/" delimits headings of adjacent levels.
- A leading "/" requires matching the top level heading.
- "//" delimits heading levels with 0 to n discarded heading levels
between them.

Demo examples:
- Goes to tag 1: [[*Chopin/Prelude]]
- Goes to tag 2: [[*/Prelude]]
- Goes to tag 3: [[*d/c//b/a]]
- Goes to tag 4: [[*d/c/b/a]]
,* Foo
,** Bach
,*** Prelude
,** Chopin
,*** Prelude :1:
,* Prelude :2:
,* d
,** c
,*** Bar
, Baz
,* b
,** a :3:
,*** b
, a :4:
#+end_src

Limitations of this simplified implementation:
- Export of links with a path to a heading is not supported.
- Links to a heading with "/" that existed before are broken.
- There may be other issues for your use case already discussed in the
current thread (
http://lists.gnu.org/archive/html/emacs-orgmode/2018-03/msg00231.html
).

Due to the limitations this implementation is for private use only and
not meant to be commited upstream although the format of the attached
patches might imply that.

Michael
From 3a594dfa9967ed4fd70aae04559dde757fb21b1b Mon Sep 17 00:00:00 2001
From: Michael Brand 
Date: Mon, 6 May 2019 18:17:52 +0200
Subject: [PATCH 1/2] org-get-heading: New parameter no-cookie

* lisp/ol.el (org-link-search): Remove regexps for comment and cookie.
* lisp/org.el (org-get-heading:): New parameter no-cookie used above.
---
 lisp/ol.el  | 10 ++
 lisp/org.el | 11 +--
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/lisp/ol.el b/lisp/ol.el
index a6f76a39f..f5bd63e96 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1108,18 +1108,12 @@ of matched result, which is either `dedicated' or `fuzzy'."
 		  (format "%s.*\\(?:%s[ \t]\\)?.*%s"
 			  org-outline-regexp-bol
 			  org-comment-string
-			  (mapconcat #'regexp-quote words ".+")))
-		 (cookie-re "\\[[0-9]*\\(?:%\\|/[0-9]*\\)\\]")
-		 (comment-re (format "\\`%s[ \t]+" org-comment-string)))
+			  (mapconcat #'regexp-quote words ".+"
 	 (goto-char (point-min))
 	 (catch :found
 	   (while (re-search-forward title-re nil t)
 		 (when (equal words
-			  (split-string
-			   (replace-regexp-in-string
-cookie-re ""
-(replace-regexp-in-string
- comment-re "" (org-get-heading t t t)
+			  (split-string (org-get-heading t t t t t)))
 		   (throw :found t)))
 	   nil)))
   (beginning-of-line)
diff --git a/lisp/org.el b/lisp/org.el
index 94713a7e5..48f7874ac 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6938,12 +6938,14 @@ So this will delete or add empty lines."
 (insert (make-string n ?\n))
 (move-to-column column)))
 
-(defun org-get-heading ( no-tags no-todo no-priority no-comment)
+(defun org-get-heading (
+			no-tags no-todo no-priority no-comment no-cookie)
   "Return the heading of the current entry, without the stars.
 When NO-TAGS is non-nil, don't include tags.
 When NO-TODO is non-nil, don't include TODO keywords.
 When NO-PRIORITY is non-nil, don't include priority cookie.
 When NO-COMMENT is non-nil, don't include COMMENT string.
+When NO-COOKIE is non-nil, don't include cookie string.
 Return nil before first heading."
   (unless (org-before-first-heading-p)
 (save-excursion
@@ -6958,7 +6960,12 @@ Return nil before first heading."
 			   (replace-regexp-in-string
 			(eval-when-compile
 			  (format "\\`%s[ \t]+" org-comment-string))
-			"" h))
+			""
+			(if no-cookie
+(replace-regexp-in-string
+ "\\[[0-9]*\\(?:%\\|/[0-9]*\\)\\]"
+ "" h)
+			  h)))
 			  (h h)))
 	  (tags (and (not no-tags) (match-string 5
 	  (mapconcat #'identity
-- 
2.20.1

From fee37436abbe4a7d6b79161b9230f02de6e7d54d Mon Sep 17 00:00:00 2001
From: Michael Brand 
Date: Mon, 6 May 2019 18:19:44 +0200
Subject: [PATCH 2/2] org-link-search: Search for outline path

* lisp/ol.el (org-link-search): Externalize matching logic to new function
  org-link--heading-path-match-p.
  (org-link--heading-path-split):
  (org-link--heading-path-match-p): New function.
---
 lisp/ol.el | 69 

Re: [O] LaTeX export section level cutoff?

2019-05-06 Thread William Denton

On 6 May 2019, Christian Lynbech wrote:


What determines at what level LaTeX export goes from sections to
enumerations?


According to this, by default it's three levels of sections, then it turns into 
lists:


https://orgmode.org/org.html#LaTeX-header-and-sectioning

But H in the export settings (or org-export-headline-levels) can change that:

https://orgmode.org/org.html#Export-Settings


Bill
--
William Denton :: Toronto, Canada   ---   Listening to Art: 
https://listeningtoart.org/
https://www.miskatonic.org/ ---   GHG.EARTH: https://ghg.earth/
Caveat lector.  ---   STAPLR: http://staplr.org/



Re: [O] Is is possible to summarize contents of a task in the agenda headings?

2019-05-06 Thread joakim
Hello,

I made some progress. I can generate agendas where each todo shows how
many sub-tasks it has:

 Emacs ideas
  <  3> Emacs:  TODO [#0] show context of subtasks in agenda
  <  1> Emacs:  TODO [#0] fixate gnus structure
  <  1> Emacs:  TODO [#2] kungsgetens org-brain
  < 11> Emacs:  TODO [#3] emslaved (make initial repo)

The number inside the initial brackets < num > indicate number of open subtasks.

I'm also using org-super-agenda here.

This is the code, a little bit messy still.

#+BEGIN_SRC emacs-lisp :tangle yes

  (defun jv-todoinfo()
(let
((numchilds 0))

  (save-mark-and-excursion
(org-narrow-to-subtree)
(setq numchilds (length
 (--filter (eq 'todo it)
   (progn
 (let ((parsetree (org-element-parse-buffer 
'headline))) 
   (org-element-map parsetree 'headline 
 (lambda (hl) (org-element-property 
:todo-type hl
;;im not sure why the widen is needed, but otherwise agenda generating 
breaks
(widen))
  numchilds))


  (setq org-agenda-prefix-format
'((agenda . " %i %-20:c%?-12t% s")
  (timeline . "  % s")
  (todo . " %i <%3(jv-todoinfo)> %-20:c")
  (tags . " %i %-12:c")
  (search . " %i %-12:c"))
)


#+END_SRC

David Masterson  writes:

>  writes:
>
>> Thanks, I'm already using (setq org-agenda-todo-list-sublevels nil) and
>> org-super-agenda. Both reduce clutter which is good. OTOH I now lack
>> information about subtasks that has been removed from the agenda
>> view. It is this concern i would like to address.
>
> A bit of work, but, if you set a property name of (say) PARENT on each
> parent project and gave it the value of that parent project name, each
> child of the parent would pick up the property and then should show up
> in an :auto-property group under org-super-agenda-mode (I think).  That
> might get a bit cluttered, though, if you're doing a deep hierarchy of
> projects.
>
> --
> David
-- 
Joakim Verona
joa...@verona.se



[O] LaTeX export section level cutoff?

2019-05-06 Thread Christian Lynbech
What determines at what level LaTeX export goes from sections to
enumerations?

I am using `report', the definition of which looks like this:

("report" "\\documentclass[11pt]{report}"
   ("\\part{%s}" . "\\part*{%s}")
   ("\\chapter{%s}" . "\\chapter*{%s}")
   ("\\section{%s}" . "\\section*{%s}")
   ("\\subsection{%s}" . "\\subsection*{%s}")
   ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))

and my top-level (*) becomes parts, the next (**) becomes chapters and
so on, but when I get down to level 4 and 5, as in

 Testing

* Mailbox creation


the code exported looks like this:

\item Testing
\label{sec:orgf672eb5}

\begin{enumerate}
\item Mailbox creation
\label{sec:orgca67a92}



I have set a `toc' option of 2, but changing that does not seem to
affect the sectioning cutoff and there clearly are options available in
the "report" definition for levels 4 and 5.


--

+-
Christian Lynbech   | christian #\@ defun #\. dk
+-
Hit the philistines three times over the head with the Elisp reference manual.
- peto...@hal.com (Michael A. Petonic)