Re: [O] Bug: syntax highlighting in ox-odt and emacs26+ broken [9.1.2 (9.1.2-elpa @ /home/jay/Code/tmp/emacs/lisp/org/)]

2017-10-17 Thread Jay Kamat
I submitted a bug report to emacs core, and Eli says:

> Having read all of the references and discussions you've provided, I
> see no evidence that this is an Emacs issue, as opposed to an Org
> issue.  I think the Org developers should take a look at this first,
> and only if they provide clear evidence that the problem is due to
> Emacs, should the problem come here.

http://lists.gnu.org/archive/html/emacs-orgmode/2017-10/msg00163.html

I tried to take a look at this, but this problem seems more subtle than
I originally thought. The `org-odt-src-block' function seems to be
returning the exact same thing in both scenarios, so the problem
(unfortunately) must be related to the highest level (where the odt is
stitched together). I'll try to keep looking at this, but I would
appreciate if someone else could take a look. I would also be happy to
accept any pointers relating to the ox-odt build process.

-Jay

Jay Kamat  writes:

> Hi Tim,
>
>> My recommendation would be to confirm if the problem exists in the org
>> bundled with Emacs 26 (9.1.1) and if it is, report this on the emacs
>> devel list, making it clear the issue does not exist with emacs
>> 25.3. This will at least allow Emacs devel to note that something which
>> it is changing is either buggy and needs more work or is an incompatible
>> change for org (and possibly other modes) which will need to be
>> added to the changes/News file and addressed by mode authors prior to 26
>> being released.
>
> This bug does indeed exist in the org bundled with emacs. Reporting this
> to emacs-devel sounds like a good plan, and I'll do so in a couple days
> to let anyone on the org mailing list have a chance to correct me if I'm
> doing anything wrong on the org side. But I do agree this looks like a
> bug in emacs core (even though I wansn't able to find the cause).
>
> -Jay



Re: [O] Help with org related crash on OpenBSD

2017-10-17 Thread Nick Dokos
Adrian Bradd  writes:

> ‚ÄčInstrumenting 'org-capture' with edebug might be of some assistance. This 
> should at least allow you to step through org-capture and see where emacs is 
> hanging.
>
> HTH
>
> On 13 October 2017 at 12:51, Aaron Bieber  wrote:
>
> Hola,
>
> I am trying to track down an issue where emacs hangs on OpenBSD when
> using org-capture. I happens with org 9.1.2 and 8.2.10 in emacs
> 25.3.1.
>
> It seems that 3 out of 4 times, emacs completely hangs when adding a
> Todo. I have tried setting (toggle-debug-on-quit) and
> (toggle-debug-on-error), but once the hang happens emacs becomes
> completely unresponsive. The one time that it doesn't hang, it takes
> around 3 or 4 seconds to actually open up the gtd.org file.

In addition to the edebug suggestion, you might try these two (three?) as well:

If it's emacs that's hanging, then `strace -p ' might give a hint,
although it's probably better to run emacs under gdb as described in

  
https://www.gnu.org/software/emacs/manual/html_node/emacs/Checklist.html#Checklist

That can get hairy though.

If it's org-capture that's hanging, then setting debug-on-quit to t and 
pressing C-g when
you get a hang might give you a backtrace.

-- 
Nick




Re: [O] Help with org related crash on OpenBSD

2017-10-17 Thread Adrian Bradd
Sorry for the repeat. Forgot to copy the list the first time.



‚ÄčInstrumenting 'org-capture' with edebug might be of some assistance. This
should at least allow you to step through org-capture and see where emacs
is hanging.

HTH

On 13 October 2017 at 12:51, Aaron Bieber  wrote:

> Hola,
>
> I am trying to track down an issue where emacs hangs on OpenBSD when
> using org-capture. I happens with org 9.1.2 and 8.2.10 in emacs
> 25.3.1.
>
> It seems that 3 out of 4 times, emacs completely hangs when adding a
> Todo. I have tried setting (toggle-debug-on-quit) and
> (toggle-debug-on-error), but once the hang happens emacs becomes
> completely unresponsive. The one time that it doesn't hang, it takes
> around 3 or 4 seconds to actually open up the gtd.org file.
>
> I can't reproduce on non-OpenBSD systems
>
> The config is fairly simple:
>
> (require 'org)
>
> (setq org-directory "~/new_org")
> (setq org-agenda-files (file-expand-wildcards "~/new_org/*.org"))
> (setq org-journal-dir "~/new_org/journal/")
> (setq org-mobile-directory "~/new_org/MobileOrg")
> (setq org-log-done 'time)
>
> (setq org-capture-templates
>   `(("t" "Todo"
>  entry (file+headline "~/new_org/gtd.org" "TODOs")
>  "* TODO %?\n  :PROPERTIES:\n  :LOGGING: TODO(!) WAIT(!) DONE(!)
> CANCELED(!)\n  :END:\n")
> ("j" "Journal"
>  entry (file+olp+datetree "~/new_org/journal-%Y-%m.org")
>  "* %?\nEntered on %U\n  %i\n  %a")))
>
> (global-set-key "\C-cc" 'org-capture)
> (global-set-key "\C-cl" 'org-store-link)
> (global-set-key "\C-ca" 'org-agenda)
> (global-set-key "\C-cb" 'org-iswitchb)
>
> Any suggestions would be greatly appreciated!
>
> Cheers,
> Aaron
>
> --
> PGP: 0x1F81112D62A9ADCE / 3586 3350 BFEA C101 DB1A  4AF0 1F81 112D 62A9
> ADCE
>
>


Re: [O] function for inserting a block

2017-10-17 Thread Eric Abrahamsen
Eric Abrahamsen  writes:

> Nicolas Goaziou  writes:
>
>> Eric Abrahamsen  writes:
>>
>>> I'm still not quite seeing this. This chunk should take care of it:
>>>
>>> (goto-char e)
>>> (if (bolp)
>>> (progn
>>>   (skip-chars-backward " \n\t")
>>>   (forward-line))
>>>   (end-of-line)
>>>   (insert "\n"))
>>>
>>> If "e" is EOB, we do `end-of-line' and insert a newline, it should be
>>> taken care of. I added a new clause in the test for this case, and it
>>> seems to work fine... Am I missing anything?
>>
>> I don't think so. It looks correct, indeed.
>>
>> However, you sent the wrong patch. Could you send the updated patch
>> again?
>
> Ooof, maybe I need to take a little vacation from the computer. This
> should be the right one.

Backing away from the keyboard now...

>From d317f25abafe012e0a678ac0c0cc3b372d22113e Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen 
Date: Sat, 7 Oct 2017 13:01:14 -0700
Subject: [PATCH] New function org-insert-structure-template

* lisp/org.el (org-insert-structure-template): New function for
  wrapping region (or element at point) in a begin/end block.
* doc/org.texi (Structure of code blocks, Easy templates): And in
  manual.
* testing/lisp/test-org.el (test-org/insert-template): New test.
---
 doc/org.texi | 21 +++--
 etc/ORG-NEWS |  4 
 lisp/org.el  | 38 ++
 testing/lisp/test-org.el | 42 ++
 4 files changed, 99 insertions(+), 6 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index 728e73f87..3a4068ce5 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -15233,12 +15233,13 @@ A @samp{src} block conforms to this structure:
 #+END_SRC
 @end example
 
-Org mode's templates system (@pxref{Easy templates}) speeds up creating
-@samp{src} code blocks with just three keystrokes.  Do not be put-off by
-having to remember the source block syntax.  Org also works with other
-completion systems in Emacs, some of which predate Org and have custom
-domain-specific languages for defining templates.  Regular use of templates
-reduces errors, increases accuracy, and maintains consistency.
+Do not be put off by having to remember the source block syntax.  Org mode
+offers two ways of speeding up the creation of src code blocks: a template
+system that can create a new block with just three keystrokes, and a command
+for wrapping existing text in a block (@pxref{Easy templates}).  Org also
+works with other completion systems in Emacs, some of which predate Org and
+have custom domain-specific languages for defining templates.  Regular use of
+templates reduces errors, increases accuracy, and maintains consistency.
 
 @cindex source code, inline
 An inline code block conforms to this structure:
@@ -17409,6 +17410,14 @@ Org comes with these pre-defined easy templates:
 More templates can added by customizing the variable
 @code{org-structure-template-alist}, whose docstring has additional details.
 
+@findex org-insert-structure-template
+@kindex C-c C-x t
+Easy templates are ideal when writing new content, but sometimes it is
+necessary to mark up existing content.  For these cases, Org provides the
+function @code{org-insert-structure-template}, which prompts for a block
+type, and wraps either the active region or the current Org element in that
+block.  This command is bound to @kbd{C-c C-x t} by default.
+
 @node Speed keys
 @section Speed keys
 @cindex speed keys
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 1076dd970..d02148e84 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -109,6 +109,10 @@ you should expect to see something like:
 #+END_EXAMPLE
 
 ** New functions
+*** ~org-insert-structure-template~
+
+This function can be used to wrap existing text of Org elements in
+a #+BEGIN_FOO/#+END_FOO block.  Bound to C-c C-x t by default.
 
 *** ~org-export-excluded-from-toc-p~
 
diff --git a/lisp/org.el b/lisp/org.el
index 99eba2da3..c5f6279d4 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12188,6 +12188,43 @@ expands them."
 (insert rpl)
 (when (re-search-backward "\\?" start t) (delete-char 1
 
+(defun org-insert-structure-template (type)
+  "Insert a block structure of the type #+BEGIN_FOO/#+END_FOO.
+Prompts for a block type, and inserts the block.  With an active
+region, wrap the region in the block.  With an element under
+point, wrap the element in the block.  Otherwise, insert an empty
+block."
+  (interactive "sBlock type: ")
+  (unless (use-region-p)
+(when (org-element-at-point)
+  (org-mark-element)))
+  (let ((s (if (use-region-p)
+	   (region-beginning)
+	 (point)))
+	(e (copy-marker (if (use-region-p)
+			(region-end)
+			  (point))
+			t))
+	column)
+(when (string-equal (downcase type) "example")
+  (org-escape-code-in-region s e))
+(goto-char s)
+(setq column 

Re: [O] function for inserting a block

2017-10-17 Thread Eric Abrahamsen
Nicolas Goaziou  writes:

> Eric Abrahamsen  writes:
>
>> I'm still not quite seeing this. This chunk should take care of it:
>>
>> (goto-char e)
>> (if (bolp)
>>  (progn
>>(skip-chars-backward " \n\t")
>>(forward-line))
>>   (end-of-line)
>>   (insert "\n"))
>>
>> If "e" is EOB, we do `end-of-line' and insert a newline, it should be
>> taken care of. I added a new clause in the test for this case, and it
>> seems to work fine... Am I missing anything?
>
> I don't think so. It looks correct, indeed.
>
> However, you sent the wrong patch. Could you send the updated patch
> again?

Ooof, maybe I need to take a little vacation from the computer. This
should be the right one.

Thanks,
Eric




Re: [O] Unable to retrieve :parameters for src-block [org-element]

2017-10-17 Thread Berry, Charles

> On Oct 17, 2017, at 10:22 AM, Kaushal Modi  wrote:
> 
> On Tue, Oct 17, 2017 at 12:31 PM Berry, Charles  wrote:
> The copy buffer that org-export-as sets up will contain this src block 
> *after* the babel process runs.
> 
> As you can see the headers are stripped off of it.


Actually, I was wrong! It is only the headers that are in the #+BEGIN_SRC line 
that get stripped.  The contents of any #+header: lines are left  alone and the 
src-block transcoder will have access to them as the :header element of a plist 
in the src-block argument. 

[snip ox-ravel suggestion]


> I still hope there is some way to prevent doing this hack, or if a 
> non-intrusive change in Org code can still have the :parameters available 
> during export. Would it be possible to remove *only* babel-recognized 
> parameters and leave the unidentified parameters (which could be specific to 
> an exporter) intact?


I think this might work: Add `after' advice to `org-babel-exp-code' that copies 
the header args you want to retain and prepends a #+header: line with them to 
the string returned by org-babel-exp-code.  Then your src-block transcoder can 
find them.

Chuck


Re: [O] function for inserting a block

2017-10-17 Thread Nicolas Goaziou
Eric Abrahamsen  writes:

> I'm still not quite seeing this. This chunk should take care of it:
>
> (goto-char e)
> (if (bolp)
>   (progn
> (skip-chars-backward " \n\t")
> (forward-line))
>   (end-of-line)
>   (insert "\n"))
>
> If "e" is EOB, we do `end-of-line' and insert a newline, it should be
> taken care of. I added a new clause in the test for this case, and it
> seems to work fine... Am I missing anything?

I don't think so. It looks correct, indeed.

However, you sent the wrong patch. Could you send the updated patch
again?

Thank you.

Regards,



Re: [O] [PATCH] Update documentation on org-protocol template placeholders

2017-10-17 Thread Nicolas Goaziou
Hello,

Allen Li  writes:

> That sounds like a good idea, but the current behavior appears to be
> how it was added in 2009 by Carsten.  I'm only documenting the current
> behavior, not improving it.

True. Applied. Thank you.

Regards,

-- 
Nicolas Goaziou



Re: [O] [PATCH] Use the same TODO keyword as the current heading

2017-10-17 Thread Allen Li
On Tue, Oct 17, 2017 at 12:47 AM, Nicolas Goaziou
 wrote:
> Hello,
>
> Allen Li  writes:
>
>> This makes org-insert-todo-heading-respect-content use the previous
>> heading of the same level instead of the previous heading regardless
>> of level.
>>
>> Given:
>>
>>* TODO some task
>>** WAITING other task
>>
>> The original code yields:
>>
>>* TODO some task
>>** WAITING other task
>>* WAITING
>>
>> This commit yields:
>>
>>* TODO some task
>>** WAITING other task
>>* TODO
>>
>> * lisp/org.el (org-insert-todo-heading): Use keyword of previous same
>>   level heading
>
> Thank you.
>
> Would you mind adding a test in "test-org.el", to
> `insert-todo-heading-respect-content' test?
>
> Regards,
>
> --
> Nicolas Goaziou

Here's the new patch with tests

---
 lisp/org.el  | 3 +--
 testing/lisp/test-org.el | 7 +++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index d6cd77bf9..100fe9a58 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7947,8 +7947,7 @@ unchecked check box."
 (org-insert-heading (or (and (equal arg '(16)) '(16))
  force-heading))
 (save-excursion
-  (org-back-to-heading)
-  (outline-previous-heading)
+  (org-forward-heading-same-level -1)
   (let ((case-fold-search nil)) (looking-at org-todo-line-regexp)))
 (let* ((new-mark-x
  (if (or (equal arg '(4))
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 3bc8c7b23..1b9178426 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -1415,6 +1415,13 @@
 "* TODO \n"
 (org-test-with-temp-text "* H\n- an item\n- another one"
   (search-forward "an ")
+  (org-insert-todo-heading-respect-content)
+  (buffer-substring-no-properties (line-beginning-position) (point-max)
+  ;; Use the same TODO keyword as current heading.
+  (should
+   (equal
+"* TODO\n"
+(org-test-with-temp-text "* TODO\n** WAITING\n"
   (org-insert-todo-heading-respect-content)
   (buffer-substring-no-properties (line-beginning-position)
(point-max))

-- 
2.15.0.rc0.271.g36b669edcc-goog



Re: [O] [PATCH] Update documentation on org-protocol template placeholders

2017-10-17 Thread Allen Li
On Tue, Oct 17, 2017 at 1:01 AM, Nicolas Goaziou  wrote:
>
> This is not directly related to your patch, but isn't something wrong
> here?
>
> I.e., shouldn't Org Protocol be able to capture arbitrary keywords
> according to the attributes of the "org-protocol" link? What is the
> point of using
>
>   ?url=...=...=...
>
> if you cannot access directly to :url, :title and :body from the capture
> template thereafter?

That sounds like a good idea, but the current behavior appears to be
how it was added in 2009 by Carsten.  I'm only documenting the current
behavior, not improving it.

>
> Disclaimer: I'm not using Org Protocol at all so I may be missing
> something.
>
> Regards,
>
> --
> Nicolas Goaziou



Re: [O] Unable to retrieve :parameters for src-block [org-element]

2017-10-17 Thread Kaushal Modi
On Tue, Oct 17, 2017 at 12:31 PM Berry, Charles  wrote:

> The copy buffer that org-export-as sets up will contain this src block
> *after* the babel process runs.
>
> As you can see the headers are stripped off of it.
>

Oh! That explains!


> So you need to do something tricky to hold onto those headers.  I do not
> know of a seamless way to do this.  FWIW, this is handled in ox-ravel by
> hacking babel so it produces #+ATTR_ lines just before the src block result
> in the copy buffer. Those lines hold the header info which the ravel
> exporter trancoders can consult.
>

I like that approach. I found your ox-ravel project on GitHub and have
tangled it to ox-ravel.el.

It would be great if you an paste the revelant snippets of code here as
that library is ~800 lines.

I still hope there is some way to prevent doing this hack, or if a
non-intrusive change in Org code can still have the :parameters available
during export. Would it be possible to remove *only* babel-recognized
parameters and leave the unidentified parameters (which could be specific
to an exporter) intact?
-- 

Kaushal Modi


Re: [O] org-ellipsis after tag is bolded

2017-10-17 Thread Nicolas Goaziou
Hello,

Deepak Cherian  writes:

> E.g.
>
> * Heading 1 ...
> * Heading 2 :noexport:...
>
> The second ellipsis is bolded because it appears after a ':'.

FWIW, I cannot reproduce this. You may want to update Org.

Regards,

-- 
Nicolas Goaziou



Re: [O] Unable to retrieve :parameters for src-block [org-element]

2017-10-17 Thread Berry, Charles

> On Oct 17, 2017, at 5:51 AM, Kaushal Modi  wrote:
> 
> So it is clear that the parameters are read inside 
> org-element-src-block-parser, but I don't understand why 
> (org-element-property :parameters src-block) is unable to fetch the same.
> 
> Hints?
> -- 


The copy buffer that org-export-as sets up will contain this src block *after* 
the babel process runs.

#+BEGIN_SRC emacs-lisp -n
(message "This is line 1")
(message "This is line 2")
(message "This is line 3")
(message "This is line 4")
(message "This is line 5")
#+END_SRC


As you can see the headers are stripped off of it.

So you need to do something tricky to hold onto those headers.  I do not know 
of a seamless way to do this.  FWIW, this is handled in ox-ravel by hacking 
babel so it produces #+ATTR_ lines just before the src block result in the copy 
buffer. Those lines hold the header info which the ravel exporter trancoders 
can consult.

There might be a tricky way to use :wrap to rewrite the src block with the 
other headers intact.

HTH,

Chuck


Re: [O] function for inserting a block

2017-10-17 Thread Eric Abrahamsen
Nicolas Goaziou  writes:


[...]

> Then it's `forward-line', not `forward-char', because there could be
> trailing spaces at the end of the paragraph, e.g.
>
>This is a paragraph.

Okay, changed to `forward-line'.

> Also, my question still holds, what about the last paragraph in a buffer
> not ending with a newline character, e.g.
>
>   This is the last paragraph.
>
> You need to insert a newline character in this case.

I'm still not quite seeing this. This chunk should take care of it:

(goto-char e)
(if (bolp)
(progn
  (skip-chars-backward " \n\t")
  (forward-line))
  (end-of-line)
  (insert "\n"))

If "e" is EOB, we do `end-of-line' and insert a newline, it should be
taken care of. I added a new clause in the test for this case, and it
seems to work fine... Am I missing anything?

Eric

>From 7ac8883394bc2979dee731c54ef65c0a9c135d0b Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou 
Date: Tue, 17 Oct 2017 10:11:21 +0200
Subject: [PATCH] Move `org-completing-read' into "org-macs.el"

* lisp/org-macs.el (org-completing-read): Moved here...
* lisp/org.el: ... from there.
---
 lisp/org-macs.el | 35 +--
 lisp/org.el  | 10 --
 2 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index 1a2d8a49d..196a2ce22 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -168,6 +168,31 @@ point nowhere."
 
 
 
+;;; Input
+
+(defun org-read-function (prompt  allow-empty?)
+  "Prompt for a function.
+If ALLOW-EMPTY? is non-nil, return nil rather than raising an
+error when the user input is empty."
+  (let ((func (completing-read prompt obarray #'fboundp t)))
+(cond ((not (string= func ""))
+	   (intern func))
+	  (allow-empty? nil)
+	  (t (user-error "Empty input is not valid")
+
+(defun org-completing-read ( args)
+  "Completing-read with SPACE being a normal character."
+  (let ((enable-recursive-minibuffers t)
+	(minibuffer-local-completion-map
+	 (copy-keymap minibuffer-local-completion-map)))
+(org-defkey minibuffer-local-completion-map " " 'self-insert-command)
+(org-defkey minibuffer-local-completion-map "?" 'self-insert-command)
+(org-defkey minibuffer-local-completion-map (kbd "C-c !")
+		'org-time-stamp-inactive)
+(apply #'completing-read args)))
+
+
+
 ;;; Logic
 
 (defsubst org-xor (a b)
@@ -469,16 +494,6 @@ The number of levels is controlled by `org-inlinetask-min-level'"
 			  limit-level)))
 	   (format "\\*\\{1,%d\\} " nstars)
 
-(defun org-read-function (prompt  allow-empty?)
-  "Prompt for a function.
-If ALLOW-EMPTY? is non-nil, return nil rather than raising an
-error when the user input is empty."
-  (let ((func (completing-read prompt obarray #'fboundp t)))
-(cond ((not (string= func ""))
-	   (intern func))
-	  (allow-empty? nil)
-	  (t (user-error "Empty input is not valid")
-
 
 (provide 'org-macs)
 
diff --git a/lisp/org.el b/lisp/org.el
index e3b4ccef1..99eba2da3 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10322,16 +10322,6 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
 		   (match-string 1 (expand-file-name file
 	  (t (concat "file:" file)
 
-(defun org-completing-read ( args)
-  "Completing-read with SPACE being a normal character."
-  (let ((enable-recursive-minibuffers t)
-	(minibuffer-local-completion-map
-	 (copy-keymap minibuffer-local-completion-map)))
-(org-defkey minibuffer-local-completion-map " " 'self-insert-command)
-(org-defkey minibuffer-local-completion-map "?" 'self-insert-command)
-(org-defkey minibuffer-local-completion-map (kbd "C-c !")
-		'org-time-stamp-inactive)
-(apply #'completing-read args)))
 
 ;;; Opening/following a link
 
-- 
2.14.2



Re: [O] Unable to retrieve :parameters for src-block [org-element]

2017-10-17 Thread Kaushal Modi
On Tue, Oct 17, 2017 at 8:51 AM Kaushal Modi  wrote:

> Hello,
>
> I am using the latest Org master.
>
> I am trying to retrieving user-set parameters for a source block. While I
> am able to retrieve the :switches property for the src-block element,
> :parameters always returns as nil.
>

Here's a comprehensive/literate version (Org file) of the same test case..
requires only ox-ascii.

=
#+TITLE: Org Element :parameters parsing issue
* Activating debug
1. Hit =C-c C-c= on the below block, and allow its evaluation.
   #+BEGIN_SRC emacs-lisp -n :eval no-export :results output silent
   (defun debug/org-ascii-src-block (orig-fun  args)
 "Print few debug messages before executing `org-ascii-src-block'."
 (let* ((src-block (car args))
(switches (org-element-property :switches src-block))
(parameters (org-element-property :parameters src-block))
(number-lines (org-element-property :number-lines src-block)))
   (message "[src-block dbg] number-lines: %S" number-lines)
   (message "[src-block dbg] switches: %S" switches)
   (message "[src-block dbg] parameters: %S" parameters))
 (apply orig-fun args))
   (advice-add 'org-ascii-src-block :around #'debug/org-ascii-src-block)
   #+END_SRC
2. Do =C-c C-e t A= to export this file using Ascii backend, to a buffer.
/We do
   not need to see the exported file, just the messages output by debug
messages
   in above code snippet.
* Deactivating debug
Evaluate the below (and allow that evaluation) to deactivate these debug
messages.
#+BEGIN_SRC emacs-lisp :eval no-export :results output silent
(advice-remove 'org-ascii-src-block #'debug/org-ascii-src-block)
#+END_SRC
=

After following the 2 steps in the "Activating debug" section, you will
find this in *Messages* buffer:

[src-block dbg] number-lines: (new . 0)
[src-block dbg] switches: "-n"
[src-block dbg] parameters: nil
[src-block dbg] number-lines: nil
[src-block dbg] switches: nil
[src-block dbg] parameters: nil

(First 3 messages are for the first code block, and the next 3 messages for
the second code block.)

Why is parameters always nil?
-- 

Kaushal Modi


[O] org-ellipsis after tag is bolded

2017-10-17 Thread Deepak Cherian

E.g.

* Heading 1 ...
* Heading 2 :noexport:...

The second ellipsis is bolded because it appears after a ':'.

Deepak



[O] Unable to retrieve :parameters for src-block [org-element]

2017-10-17 Thread Kaushal Modi
Hello,

I am using the latest Org master.

I am trying to retrieving user-set parameters for a source block. While I
am able to retrieve the :switches property for the src-block element,
:parameters always returns as nil.

Here's a dummy version of the function I am using to parse source blocks in
my custom exporter:

=
(defun org-hugo-src-block (src-block _contents info)
  (let ((lang (org-element-property :language src-block))
;; See `org-element-src-block-parser' for all SRC-BLOCK properties.
(switches (org-element-property :switches src-block))
(parameters (org-element-property :parameters src-block))
(number-lines (org-element-property :number-lines src-block)))
;Non-nil if -n or +n switch is used
(message "ox-hugo src [dbg] number-lines: %S" number-lines)
(message "ox-hugo src [dbg] switches: %S" switches)
(message "ox-hugo src [dbg] parameters: %S" parameters)))
=

Here is the test Org snippet:

=
#+BEGIN_SRC emacs-lisp -n :hl 1,3-4 :eval no
(message "This is line 1")
(message "This is line 2")
(message "This is line 3")
(message "This is line 4")
(message "This is line 5")
#+END_SRC
=

(:hl 1,3-4 is something special that ox-hugo will handle.)

But on exporting that Org snippet, I get:

=
ox-hugo src [dbg] number-lines: (new . 0)
ox-hugo src [dbg] switches: "-n"
ox-hugo src [dbg] parameters: nil
=

If I put a debug statement directly in org-element-src-block-parser towards
the end:

=
;; SNIP
(message "dbg: parameters: %s" parameters)
(list 'src-block
  (nconc
   (list :language language
;; SNIP
=

I get these in the *Messages*:

=
dbg: parameters:  :hl 1,3-4 :eval no [3 times]
=

So it is clear that the parameters are read inside
org-element-src-block-parser, but I don't understand why
(org-element-property :parameters src-block) is unable to fetch the same.

Hints?
-- 

Kaushal Modi


[O] Add minlevel parameter to column view parameters

2017-10-17 Thread Thomas Cordival
Hello,

you will find attached a simple patch to add a new parameter to the
column view dynamic block: minlevel.

This parameter mirrors the behavior of the maxlevel parameter: only
headings below a given level will be included in the table.

I use this feature in documents where I want to keep a list of items
(headings) on which I define properties alongside a table summarizing
these properties:

* Summary
#+BEGIN: columnview :id input :minlevel 3
| Year | Title  | Theatre  |
|--++--|
| 1995 | Scream | New York |
| 1999 | Scream 2   | Tokyo|
| 2013 | 500 days of summer | Paris|
#+END:
* Movies
:PROPERTIES:
:ID: input
:COLUMNS: %Year %ITEM(Title) %Theatre
:END:
** Horror
*** Scream
:PROPERTIES:
:year: 1995
:theatre:  New York
:END:
*** Scream 2
:PROPERTIES:
:year: 1999
:theatre:  Tokyo
:END:
** Romance
*** 500 days of summer
:PROPERTIES:
:year: 2013
:theatre:  Paris
:END:
>From e72280536137057dfe2fb30d5e1a7147e43c9405 Mon Sep 17 00:00:00 2001
From: Thomas Cordival 
Date: Tue, 17 Oct 2017 13:57:11 +0200
Subject: [PATCH] Add minlevel to column view parameters

* lisp/org-colview.el (org-columns--capture-view): Add logic to
  build the match string
* testing/lisp/test-org-colview.el (test-org-colview/dblock): Add tests for maxlevel and minlevel
* doc/org.texi: Describe the new minlevel parameter
---
 doc/org.texi |  2 +
 lisp/org-colview.el  | 26 +
 testing/lisp/test-org-colview.el | 79 
 3 files changed, 99 insertions(+), 8 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index 728e73f87..cf0051c7d 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -5830,6 +5830,8 @@ When @code{t}, insert an hline after every line.  When a number @var{N}, insert
 an hline before each headline with level @code{<= @var{N}}.
 @item :vlines
 When set to @code{t}, force column groups to get vertical lines.
+@item :minlevel
+When set to a number, don't capture entries above this level.
 @item :maxlevel
 When set to a number, don't capture entries below this level.
 @item :skip-empty-rows
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 2a427aecc..074df3f08 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -1325,14 +1325,14 @@ and variances (respectively) of the individual estimates."
 
 ;;; Dynamic block for Column view
 
-(defun org-columns--capture-view (maxlevel skip-empty format local)
+(defun org-columns--capture-view (minlevel maxlevel skip-empty format local)
   "Get the column view of the current buffer.
 
-MAXLEVEL sets the level limit.  SKIP-EMPTY tells whether to skip
-empty rows, an empty row being one where all the column view
-specifiers but ITEM are empty.  FORMAT is a format string for
-columns, or nil.  When LOCAL is non-nil, only capture headings in
-current subtree.
+MINLEVEL set the upper level limit.  MAXLEVEL sets the deeper
+level limit.  SKIP-EMPTY tells whether to skip empty rows, an
+empty row being one where all the column view specifiers but ITEM
+are empty.  FORMAT is a format string for columns, or nil.  When
+LOCAL is non-nil, only capture headings in current subtree.
 
 This function returns a list containing the title row and all
 other rows.  Each row is a list of fields, as strings, or
@@ -1360,7 +1360,15 @@ other rows.  Each row is a list of fields, as strings, or
 			  (or (null r) (and has-item (= (length r) 1)
 	 (push (cons (org-reduced-level (org-current-level)) (nreverse row))
 		   table)
- (and maxlevel (format "LEVEL<=%d" maxlevel))
+ (if (and minlevel maxlevel)
+	 (format "LEVEL>=%d<=%d" minlevel maxlevel)
+   (if minlevel
+	   (format "LEVEL>=%d" minlevel)
+	 (if maxlevel
+	 (format "LEVEL<=%d" maxlevel))
+	 ))
+ ;; (and (or (not minlevel) (format "LEVEL>=%d" minlevel))
+ ;; 	  (or (not maxlevel) (format "LEVEL<=%d" maxlevel)))
  (and local 'tree)
  'archive 'comment)
 (org-columns-quit)
@@ -1397,6 +1405,7 @@ PARAMS is a property list of parameters:
 	  a hline before each level <= that number.
 :indent   When non-nil, indent each ITEM field according to its level.
 :vlines   When t, make each column a colgroup to enforce vertical lines.
+:minlevel When set to a number, don't capture headlines above this level.
 :maxlevel When set to a number, don't capture headlines below this level.
 :skip-empty-rows
 	  When t, skip rows where all specifiers other than ITEM are empty.
@@ -1422,7 +1431,8 @@ PARAMS is a property list of parameters:
   (current-buffer))
 	 (org-with-wide-buffer
 	  (when view-pos (goto-char view-pos))
-	  (org-columns--capture-view (plist-get params :maxlevel)
+	  (org-columns--capture-view (plist-get params :minlevel)
+	 (plist-get params :maxlevel)
 	 (plist-get params :skip-empty-rows)
 	 (plist-get params :format)
 	 view-pos))
diff --git 

Re: [O] [PATCH] Update documentation on org-protocol template placeholders

2017-10-17 Thread Nicolas Goaziou
Hello,

Allen Li  writes:

> * doc/org.texi (@code{capture} protocol): Fix placeholder names
> (Template expansion): Add org-protocol placeholders
>
> * lisp/org.el (org-store-link-plist): Fix docstring grammar
> (org-store-link-props): Fix docstring grammar

Thank you.

> +The following template placeholders are available:
> +
> +@example
> +%:link  The URL
> +%:description   The webpage title
> +%:annotationEquivalent to [[%:link][%:description]]
> +%i  The selected text
> +@end example

This is not directly related to your patch, but isn't something wrong
here? 

I.e., shouldn't Org Protocol be able to capture arbitrary keywords
according to the attributes of the "org-protocol" link? What is the
point of using

  ?url=...=...=...

if you cannot access directly to :url, :title and :body from the capture
template thereafter?

Disclaimer: I'm not using Org Protocol at all so I may be missing
something.

Regards,

-- 
Nicolas Goaziou



Re: [O] org-refile and Archive headings

2017-10-17 Thread Nicolas Goaziou
Hello,

Allen Li  writes:

> The current default behavior for org-refile and org-reverse-note-order
> does not treat Archive headings specially.  Consider a .org file:
>
> * Some projects
> ** Some item...
> ** Archive :ARCHIVE:...
>
> Refiling an entry to "Some projects" results in:
>
> * Some projects
> ** Some item...
> ** Archive :ARCHIVE:...
> ** New entry...
>
> Would it be desirable to instead append before the Archive heading?
>
> * Some projects
> ** Some item...
> ** New entry...
> ** Archive :ARCHIVE:...
>
> This could be configurable using a magic value for
> org-reverse-note-order.

AFAIK, there is no special location in the file for archived subtrees,
i.e., there is nothing wrong with

  * Some projects
  ** Some item...
  ** Archive :ARCHIVE:...
  ** New entry...

I guess you could use `org-after-refile-insert-hook' for that special
need.

Regards,

-- 
Nicolas Goaziou



Re: [O] function for inserting a block

2017-10-17 Thread Nicolas Goaziou
Hello,

Eric Abrahamsen  writes:

> Nicolas Goaziou  writes:

>>> +(if (bolp)
>>> +   (progn
>>> + (skip-chars-backward " \n\t")
>>> + (forward-char))
>>> +  (end-of-line)
>>> +  (insert "\n"))
>>
>> I don't understand this part. In particular, the `forward-char' looks
>> wrong. Do you mean `forward-line' ? If so, do you handle the case where
>> buffer doesn't end with a newline character?
>
> This was a bit of finicky code mostly for aesthetic purposes. It has to
> do with this case (the second clause in the test I added):
>
> #+BEGIN_SRC org
> This is a paragraph
>
> This is another paragraph
> #+END_SRC
>
>
> If point is on the first paragraph and the region is not active,
> `org-mark-element' will mark the paragraph and all following whitespace,
> which means we end up with:
>
> #+BEGIN_SRC org
> #+BEGIN_FOO
> This is a paragraph.
>
> #+END_FOO
>
> This is another paragraph.
> #+END_SRC
>
> Which just looked bad to me (even though it probably behaves perfectly
> correctly). So if point is at bol, it skips back over the whitespace and
> then moves forward one char, presumably leaving point right after the
> marked element.

Then it's `forward-line', not `forward-char', because there could be
trailing spaces at the end of the paragraph, e.g.

   This is a paragraph.

Also, my question still holds, what about the last paragraph in a buffer
not ending with a newline character, e.g.

  This is the last paragraph.

You need to insert a newline character in this case.

Regards,

-- 
Nicolas Goaziou



Re: [O] [PATCH] Use the same TODO keyword as the current heading

2017-10-17 Thread Nicolas Goaziou
Hello,

Allen Li  writes:

> This makes org-insert-todo-heading-respect-content use the previous
> heading of the same level instead of the previous heading regardless
> of level.
>
> Given:
>
>* TODO some task
>** WAITING other task
>
> The original code yields:
>
>* TODO some task
>** WAITING other task
>* WAITING
>
> This commit yields:
>
>* TODO some task
>** WAITING other task
>* TODO
>
> * lisp/org.el (org-insert-todo-heading): Use keyword of previous same
>   level heading

Thank you. 

Would you mind adding a test in "test-org.el", to
`insert-todo-heading-respect-content' test?

Regards,

-- 
Nicolas Goaziou