[O] Org agenda started behaving badly

2018-06-08 Thread Marcin Borkowski
Hi all,

so out of nowhere my org agenda started behaving in a strange way.  It
seems not to respect my TODO-keywords settings:

--8<---cut here---start->8---
(setq org-todo-keywords
  '((sequence "TODO(t!)" "DONE(d!)")
(sequence "SOMEDAY(s!)")
(sequence "CANCELLED(c@)")
(sequence "WAIT(w!)" "|")))
--8<---cut here---end--->8---

i.e., it now shows all the "CANCELLED" items as if "CANCELLED" was not
a todo keyword at all.  When I visit the offending file and issue M-x
normal-mode, everything is back to normal again.

Now the strange thing is, I haven't updated Org in a while.  I did now,
but the problem persists.  I am on

Org mode version 9.1.13 (release_9.1.13-791-g842002 @ [...])

and

GNU Emacs 27.0.50 (commit f1e65b7)

I also can't remember changing my config (but it's quite possible that
I'm forgetting something).

What I did do is I updated some packages through the Emacs package
manager, but I don't think this is related.

Now I know this is a bit vague, but does anyone have any idea what might
cause this, or how I could try to debug this problem?

Of course, I have a lot of Org-mode-related customizations in my
init.el, but I don't think they are related.  If I'm wrong, I can post
them here, of course.

Best,

--
Marcin Borkowski
http://mbork.pl



[O] How do I debug agenda-skip-functions?

2018-06-08 Thread Akater

To quote the following 2013 message from this mailing list
http://lists.gnu.org/archive/html/emacs-orgmode/2013-06/msg00841.html

> This is quite strange because I can debug skipping functions
> for tags-todo blocks, but for some reason I cannot debug skipping
> functions for agenda blocks.

I try to debug a skipping function for agenda. debug-on-entry has no
effect. debug-on-entry org-agenda-skip-eval had an effect once but I
can't reproduce it; besides, another message
http://lists.gnu.org/archive/html/emacs-orgmode/2013-06/msg00854.html
from the same thread reads:

> It would be great except for the following: as soon as I use the
> debugger, my function works as intended.

so I won't feel confident I won't be hit by the same bug.

How do you debug agenda skip functions?


signature.asc
Description: PGP signature


Re: [O] ANN/RFC: org-sidebar

2018-06-08 Thread Adam Porter
On Mon, Jun 4, 2018 at 9:19 AM, Holst Thomas (PS-EC/ESE4)
 wrote:
> Hello Adam,
>
> No problem. I am not that good in elisp, but I like to help testing. So I am 
> glad I could help here.
>
> After a git pull the error is gone - but I don't get any entries in the 
> sidebar :-(.

Hi Thomas,

I just pushed some commits that I think will fix the problems.  I
tested with "emacs -q" this time, so it should work on configs other
than my own.  ;)

Please let me know if you have any other problems or comments.  Thank
you very much for your testing, as it's invaluable for rooting out
problems like this!

Thanks,
Adam



[O] ANN: org-make-toc package makes tables of contents

2018-06-08 Thread Adam Porter
Hi friends,

I've posted a new package on MELPA called org-make-toc which allows you
to automatically create customized tables of contents in documents.  You
can have multiple TOCs in a single document, including a master TOC that
shows every heading, TOCs that show only child or sibling headings, etc,
and you can exclude headings from TOCs.

https://github.com/alphapapa/org-make-toc

Any comments or suggestions are welcome.  Hope you find this useful.

Thanks,
Adam




Re: [O] [PATCH] No completion when querying for property value in capture template

2018-06-08 Thread Eric Danan
OK I think I understand why it doesn't work. I'm attaching a simple
patch that hopefully solves the issue. I've put comments in the commit
message. Please let me know if anything is not clear or if you see
issues.

Eric

On Thu, Jun 7, 2018 at 11:18 PM Eric Danan  wrote:
>
> Thanks.
>
>> As far as I know it is not currently possible to get property
>> auto-completion from the property list of the file itself.
>
>
> I don't understand: when I call "org-set-property" directly from the file 
> (C-c C-x p), it does get all the property values in the file and proposes 
> them for completion. I am probably missing your pint, could I ask you to 
> explain?
>
> Only when I use the "%^{prop}p" capture template element are the values not 
> offered. I don't understand why because looking at the code of 
> "org-capture-fill-template", it seems to simply call "org-set-property" for 
> this element.
>
>> but you could still make use of the stock property in the template and 
>> auto-complete
>> from there
>>
>> For instance:
>>
>> ("T" "TEST" entry (file+headline"/tmp/test.org" "drill")
>> "** TEST  \n :PROPERTIES:\n :Effort: 
>> %^{prompt|0:10|0:20|0:30|1:00|2:00|3:00}\n :END: \n %^{PROMPT} " )
>>
>> see the rest of the thread for more details 
>> http://lists.gnu.org/archive/html/emacs-orgmode/2011-10/msg01339.html
>
>
> Yes I've read the rest of the thread, but that's not always feasible. In my 
> use case, the property values are titles of academic journals, I can't list 
> them all inside a "%^{prompt}" template element, I need them to be fetched 
> from the file.
>
> Thanks again.
>
> Eric
From 5dd9c5b54d32af1023eb2ea84d8ad702cae3307e Mon Sep 17 00:00:00 2001
From: Eric Danan 
Date: Fri, 8 Jun 2018 16:26:21 +0200
Subject: [PATCH] org-capture.el: Offer property value completions in capture
 template

* lisp/org-capture.el (org-capture-fill-template): When reading a
  property's value for a `%^{prop}p' template element, offer
  completions on the property's allowed or existing values.

This is done by temporarily prepending to the variable
`org-file-property' and entry `(prop_all . vals)' where vals is either
the local or inherited value of `prop_all' at the target location or,
if that is nil, the set of local values of `prop' in the target
buffer.  A dummy value `:ETC' is added in the latter case so that
matching is not required.

The resulting behavior is (hopefully) the same as when using
`org-set-property' directly.  If there is an entry for `prop' in
`org-property-allowed-value-functions', that will be used in
priority.  If not and there is a local or inherited value for
`prop_all' at point or target location, then this will be used.  In
these two cases, matching is required unless `:ETC' belongs to the
allowed values.  Finally, in the absence of allowed values, the set of
local values for `prop' in the current or target buffer is used, with
matching not required.
---
 lisp/org-capture.el | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index eeddd2ab..b10ba576 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1695,7 +1695,15 @@ (defun org-capture-fill-template ( template initial annotation)
 		first-value)))
 			 (_ (error "Invalid `org-capture--clipboards' value: %S"
    org-capture--clipboards)
-		("p" (org-set-property prompt nil))
+		("p"
+		 (let* ((prop-all (concat prompt "_ALL"))
+			(vals (with-current-buffer buffer
+(or (org-entry-get nil prop-all 'inherit)
+	(concat (mapconcat 'identity (org-property-values prompt) " ")
+		" :ETC"
+			(org-file-properties (cons (cons prop-all vals)
+		   org-file-properties)))
+		   (org-set-property prompt nil)))
 		((or "t" "T" "u" "U")
 		 ;; These are the date/time related ones.
 		 (let* ((upcase? (equal (upcase key) key))
-- 
2.17.0



Re: [O] [PATCH] Add new keyword :coding for #+include directive

2018-06-08 Thread Pierre Téchoueyres


Hello nicolas,
Many thanks for your patience and for applying my patch.
I've seen you didn't apply the part which added an entry in ORG-NEWS
file. Was this deliberate or just an side effect of your refactoring ?
Or is this unneeded ? 
Again thanks for your patience.

Nicolas Goaziou  writes:

> ...
> I applied the first patch in "next" branch, with a slight refactoring.
>
> Thank you.
>
> Regards,



[O] Support flymake with org-lint

2018-06-08 Thread Alex Branham
Here's a patch that adds support for flymake in Emacs 26 and greater. It
uses org-lint.el as the backend. It can be pretty slow if you have a
large buffer open, so I don't think I'd recommend enabling it by
default. It's nice to be able to use e.g. flymake-goto-next-error to
navigate around the buffer though.

Alex

>From b53c4068cb64c152c417014916c7d8c11e4651fb Mon Sep 17 00:00:00 2001
From: Alex Branham 
Date: Wed, 6 Jun 2018 14:44:12 -0500
Subject: [PATCH] Add support for flymake

* lisp/org-flymake.el (org-flymake-org-lint-backend): New function
* lisp/org-flymake.el (org-flymake-setup): New function
---
 etc/ORG-NEWS| 10 +++
 lisp/org-flymake.el | 63 +
 2 files changed, 73 insertions(+)
 create mode 100644 lisp/org-flymake.el

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 2a22be0d5..5bf5a2f71 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -311,7 +311,17 @@ You can set an agenda restriction lock with =C-x C-x <= or 
with =<= at the
 beginning of a headline when using Org speed commands.  Now, if there
 is already a restriction at point, hitting =<= again (or =C-x C-x <=) will
 remove it.
+*** Org now supports flymake in Emacs version 26.1 and greater
+To enable it in all org buffers, add:

+#+begin_src emacs-lisp
+(add-hook 'org-mode-hook #'org-flymake-setup)
+#+end_src
+
+to your Emacs configuration file.  This takes care of setting up the
+flymake backend (using ~org-lint~) and enables ~flymake-mode~ in org
+buffers.  Note that ~org-lint~ can be slow in large org buffers, so
+you may not want to enable this in all buffers by default.
 ** New commands and functions

 *** ~org-insert-structure-template~
diff --git a/lisp/org-flymake.el b/lisp/org-flymake.el
new file mode 100644
index 0..7462d98a6
--- /dev/null
+++ b/lisp/org-flymake.el
@@ -0,0 +1,63 @@
+;;; org-flymake.el --- Org support for flymake.el  -*- lexical-binding: t; -*-
+;;
+;; Copyright (C) 2018 Free Software Foundation, Inc.
+;;
+;; This file is a part of GNU Emcas.
+;;
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see .
+;;
+;;
+;;; Commentary:
+;; This file implements support for flymake.el in org mode buffers.
+;; To enable it permanently in all org buffers, add this to your Emacs
+;; configuration file:
+;;
+;; (add-hook 'org-mode-hook #'org-flymake-setup)
+;;
+;; Flymake supports multiple backends.  Currently we use `org-lint' only.
+
+;;; Code:
+
+(eval-when-compile
+  (require 'cl-lib))
+(require 'org-lint)
+(require 'seq)
+
+(defun org-flymake-org-lint-backend (report-fn  _args)
+  "A Flymake backend for `org-lint'.
+Calls REPORT-FN directly."
+  (let* ((report (org-lint--generate-reports
+ (current-buffer) org-lint--checkers))
+(report (mapcar
+ (lambda (c) (seq-into (nth 0 (cdr c)) 'list))
+ report)))
+(funcall report-fn
+(cl-loop
+ for (line _trust description _checkers) in report
+ for (beg . end) = (flymake-diag-region (current-buffer) 
(string-to-number line))
+ collect
+ (flymake-make-diagnostic (current-buffer) beg end :note 
description)))
+report))
+
+;;;###autoload
+(defun org-flymake-setup ()
+  "Add `org-flymake' to `flymake-diagnostic-functions'."
+  (if (< emacs-major-version 26)
+  (user-error "Org-flymake requires Emacs 26.1 or greater")
+(add-hook 'flymake-diagnostic-functions #'org-flymake-org-lint-backend nil 
t)
+(flymake-mode)))
+
+(provide 'org-flymake)
+
+;;; org-flymake.el ends here
--
2.17.1



>From b53c4068cb64c152c417014916c7d8c11e4651fb Mon Sep 17 00:00:00 2001
From: Alex Branham 
Date: Wed, 6 Jun 2018 14:44:12 -0500
Subject: [PATCH] Add support for flymake

* lisp/org-flymake.el (org-flymake-org-lint-backend): New function
* lisp/org-flymake.el (org-flymake-setup): New function
---
 etc/ORG-NEWS| 10 +++
 lisp/org-flymake.el | 63 +
 2 files changed, 73 insertions(+)
 create mode 100644 lisp/org-flymake.el

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 2a22be0d5..5bf5a2f71 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -311,7 +311,17 @@ You can set an agenda restriction lock with =C-x C-x <= or with =<= at the
 beginning of a headline when using Org speed commands.  Now, if there
 is already a restriction at point, hitting =<= again (or =C-x C-x <=) will
 

Re: [O] Spurious "Non-existent agenda file" message?

2018-06-08 Thread John Kitchin
Sometimes I see this when a buffer is open to a file that has never been
saved. This can happen when I start a new org file and try to do some
agenda thing before I save it, or when some function/process opens an
org-file in a new directory for example, and an agenda thing happens before
it has been saved.

You could check to see if there is a refile.org buffer open (not
necessarily to the existing file, just one named refile.org) but that has
not been saved. I don't know why such a buffer would be open, but if it is,
it might be a cause of that problem.

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, Jun 8, 2018 at 12:38 AM, Loris Bennett 
wrote:

> Hi,
>
> Suddenly, maybe after an update to Org 9.1.13, I get the error
>
>   Non-existent agenda file refile.org.  [R]emove from list or [A]bort?
>
> when generating the agenda.  However, the file exists (and has done for
> years).  If I press 'R', the agenda is built, but the offending file is
> not removed and entries from the file are included in the agenda.
>
> The entry is the 3rd of 3 files.  I added a 4th to check whether it is
> an off-by-one error, but still only the 3rd entries is considered
> non-existent.
>
> If I add a file to 'org-agenda-files' which really is missing, I get the
> error, but when I press 'R' the entry really is removed from the list.
> Even if I remove 'refile.org' from the list, I still get the error that
> 'refile.org' is missing.
>
> Any ideas what I could try next?
>
> Baffled,
>
> Loris
>
> --
> This signature is currently under construction.
>
>
>


[O] Org-babel bash session with non-standard prompt

2018-06-08 Thread Narendra Joshi
Hi,

If the value for PS1 variable is set to something that doesn't end with
a `$` or `#`, org-babel hangs while using a fixed :session.

To overcome this, I can do the following at the start of a sh org-babel
session: 

#+begin_src bash :session s :results verbatim drawer
export PS1='$ '
ls -lah
#+end_src

And this works ^.

I would like to know if I can somehow pass the environment variable
to the shell that org-babel starts for the session. I don't want to add
it to a snippet and do not want to type it every time. 

Any help would be greatly appreciated. 

Thanks,
-- 
Narendra Joshi



Re: [O] Export to LaTeX buffer (solved)

2018-06-08 Thread Hoffmann, Jobst
Answering myself: just installed emacs 26.1 from Fedora 28 and the
problem is gone!

Am Freitag, den 16.03.2018, 18:29 + schrieb Hoffmann, Jobst:
> Am Mittwoch, den 14.03.2018, 14:57 +0100 schrieb Nicolas Goaziou:
> > "Hoffmann, Jobst"  writes:
> > 
> > > make:  Org mode version 9.1.7 (release_9.1.7-516-gbc7b24.dirty =>
> > 
> >^
> > > /usr/share/emacs/site-lisp/org)
> > 
> > Could your local changes interfere with the export process?
> 
> No, these local changes are done to see the call chain. It ended up
> at
> line 6223, where post-process is called. This function is LaTeX-mode,
> which is defined as an alias for latex-mode. latex-mode is defined in
> tex-mode, but I don't have the sources. Anyway, this is the point
> where
> the shit happens.
> 
> I got around by defining a small loaddef file, which provides the
> missing function. This ends up with an error, but the buffer which I
> need is generated and I can do my final steps on it.
> 
> If you find a better solution, please let me know.
> 
> > 
> > > I'm quite desperated, do you have an idea?
> > 
> > Not really.
> > 
> > Regards,
> 
> Best regards
> Jobst
> -- 
> Prof. Dr. Jobst HoffmannTel:   +49 (241) 6009-5 31 59
> Fachhochschule Aachen Abt. Jülich   Fax:   +49 (241) 6009-5 31 89
> Fachbereich 09  email: j.hoffm...@fh-aachen.de
-- 
Prof. Dr. Jobst HoffmannTel:   +49 (241) 6009-5 31 59
Fachhochschule Aachen Abt. Jülich   Fax:   +49 (241) 6009-5 31 89
Fachbereich 09  email: j.hoffm...@fh-aachen.de

Re: [O] autoinsert

2018-06-08 Thread Joseph Vidal-Rosset
Hello,

Here is the  adaptation of the previous  lines of code that  works in my
setup (the web page [[https://www.emacswiki.org/emacs/RegularExpression]] was 
helpful): 

#+BEGIN_SRC 
(require 'autoinsert)
(auto-insert-mode)  ;;; Adds hook to find-files-hook
(setq auto-insert-directory "~/MEGA/org/my_org-templates/") ;;; Or use 
custom, *NOTE* Trailing slash important
(setq auto-insert-query nil) ;;; If you don't want to be prompted before 
insertion
(define-auto-insert "\.beamer-fr.org" "my-beamer-fr.org")
#+END_SRC

Now, supposing that I have to give a talk in French at Aix-en-Provence (very 
nice
city!), when I open in emacs  the new file aix-beamer-fr.org this file
automatically contains  the lines defined in  my-beamer-fr.org that is
in ~/MEGA/org/my_org-templates/ . 

That is  certainly trivial  for a lot  of people in  this list  (and I
apologize), but maybe it will be helpful for others. 


 Best wishes,
-- 
Jo.

Re: [O] Problem with diary entries after upgrading emacs 26.1

2018-06-08 Thread Pascal Quesseveur
  I have found what is causing the errors. I have to use
org-anniversary and org-block instead of diary-anniversary and
org-block (and put he date in ISO).


-- 
Pascal Quesseveur
pques...@gmail.com




[O] Spurious "Non-existent agenda file" message?

2018-06-08 Thread Loris Bennett
Hi,

Suddenly, maybe after an update to Org 9.1.13, I get the error

  Non-existent agenda file refile.org.  [R]emove from list or [A]bort?

when generating the agenda.  However, the file exists (and has done for
years).  If I press 'R', the agenda is built, but the offending file is
not removed and entries from the file are included in the agenda.

The entry is the 3rd of 3 files.  I added a 4th to check whether it is
an off-by-one error, but still only the 3rd entries is considered
non-existent.

If I add a file to 'org-agenda-files' which really is missing, I get the
error, but when I press 'R' the entry really is removed from the list.
Even if I remove 'refile.org' from the list, I still get the error that
'refile.org' is missing.

Any ideas what I could try next?

Baffled,

Loris

--
This signature is currently under construction.




Re: [O] autoinsert

2018-06-08 Thread Joseph Vidal-Rosset
obvious correction:

(auto-insert-mode)  ;;; Adds hook to find-files-hook
(setq auto-insert-directory "~/.mytemplates/") ;;; Or use custom,
*NOTE* Trailing slash important
(setq auto-insert-query nil) ;;; If you don't want to be prompted
before insertion
(define-auto-insert "\.py" "my-python-template.py")
(define-auto-insert "\.php" "my-php-template.php")


the "#+BEGIN_QUOTE " did not belong to the code that I wanted to quote.

2018-06-08 9:32 GMT+02:00 Joseph Vidal-Rosset :

> Hello,
>
> A solution to my problem was indeed given in this web page
> https://www.emacswiki.org/emacs/AutoInsertMode:
>
> #+BEGIN_QUOTE
> (auto-insert-mode)  ;;; Adds hook to find-files-hook
> (setq auto-insert-directory "~/.mytemplates/") ;;; Or use custom, *NOTE* 
> Trailing slash important
> (setq auto-insert-query nil) ;;; If you don't want to be prompted before 
> insertion
> (define-auto-insert "\.py" "my-python-template.py")
> (define-auto-insert "\.php" "my-php-template.php")
>
> It should not be too difficult, even for me, to adapt this code that I
> just tested.
>
> Best wishes,
> –
> Jo.
>


Re: [O] autoinsert

2018-06-08 Thread Joseph Vidal-Rosset
Hello,

A  solution   to  my  problem  was   indeed  given  in  this   web  page
[[https://www.emacswiki.org/emacs/AutoInsertMode]]:


#+BEGIN_SRC 
#+BEGIN_QUOTE
(auto-insert-mode)  ;;; Adds hook to find-files-hook
(setq auto-insert-directory "~/.mytemplates/") ;;; Or use custom, *NOTE* 
Trailing slash important
(setq auto-insert-query nil) ;;; If you don't want to be prompted before 
insertion
(define-auto-insert "\.py" "my-python-template.py")
(define-auto-insert "\.php" "my-php-template.php")
#+END_SRC

It should not be too difficult, even for me, to adapt this code that I
just tested.

 Best wishes,
-- 
Jo.

Re: [O] autoinsert

2018-06-08 Thread Joseph Vidal-Rosset
Le jeu. 07 juin 2018 à 05:06:20 , Nick Dokos  a envoyé
ce message:

#+BEGIN_QUOTE
> Are you producing the beamer presentations, the papers, etc. from org
> files? If so, isn't the org-mode insertion enough? If not, why not?
#+END_QUOTE

Many thanks for your question. Yes, I am now always using org-mode for
my beamer presentations and my  papers. But the org-mode templates for
beamer presentations are of course  different from papers's and I want
to define different skeletons.org to  auto-insert according the fact I
am writing a new file in such or such directory. 

Suppose that, for example, I am writing a new beamer presentation, say
new-beamer-talk.org in /home/joseph/MEGA/org/beamer/, it would be nice
to get  auto-insertion of my  org template for my  beamer presentation
via a beamer-skeleton.org,  and the same thing for  a new-paper.org if
that I  want to register in  /home/joseph/MEGA/org/papers/, getting an
auto-insertion of  paper-skeleton.org for  this new-paper.org,  and so
on. I suppose that  it is possible, and even that it  is quite easy to
get it, but I do not know how to code it. 

At the moment, I am reading [[https://www.emacswiki.org/emacs/AutoInsertMode]]
and [[https://www.emacswiki.org/emacs/SkeletonMode]]
to find the solution. 

Help is always welcome.

 Best wishes,
-- 
Jo.