Re: [O] capture with iceweasel/firefox -- nothing works

2016-06-03 Thread Samuel Wales
hi matt,

thanks for your reply.

On 6/3/16, Matt Lundin  wrote:
> Here is the new style bookmark that works for me:
>
> javascript:location.href='org-protocol://capture?url='+encodeURIComponent(location.href)+'='+encodeURIComponent(document.title)+'='+encodeURIComponent(window.getSelection())
>
> I also placed the following in
> ~/.local/share/applications/emacsclient.desktop:
>
> --8<---cut here---start->8---
> [Desktop Entry]
> Name=Emacs Client
> Exec=emacsclient %u
> Icon=emacs-icon
> Type=Application
> Terminal=false
> MimeType=x-scheme-handler/org-protocol;
> --8<---cut here---end--->8---
>

will try.

> Since you are not using a desktop environment, you might also need to
> make sure that the appropriate xdg tools are installed. On arch linux
> the package is xdg-utils.

debian
xdg-utils:
  Installed: 1.1.0~rc1+git20111210-7.4

>
> I'd recommend copying and pasting the javascript line above into the
> location bar to confirm whether it works. If it does, you can then
> easily add it to your bookmarks.

will try.  this is supposed to imitate clicking on the unicorn or
calling the bookmark?

do i try with selecting and without selecting?

which capture key does it call?

i always run the emacs server in my regular emacs.  i don't
use the daemon.

however, i never found any good instructions on what to do to add js
to bookmarks.
i have a menu bar and a location bar + icons.  i'd like a button or
icon on the latter if possible.  my previous thrashing around caused a
>> symbol which is a drop down menu which contains the bookmarks.
i'll settle for that if nec.  but that is extra clicking i'd rather
avoid, and one of them brings up a page with js on it.

is this knowledge something that everybody except me possesses?  :)

===

the full error is:
Greedy org-protocol handler.  Killing client.
No server buffers remain to edit

>
> Note: There is a bug in the implementation of the new org-protocol url
> processing that can lead to multiple "greedy protocol" warnings. (I
> posted a bug report about this a week or so ago.)
>
> Hope this helps.
> Matt
>

thanks.


samuel



Re: [O] capture with iceweasel/firefox -- nothing works

2016-06-03 Thread Matt Lundin
Xebar Saram  writes:

> Hi 
>
> i will add that im exactly in the same situatuon
> i use a window manager (i3) on arch linux and have tried almost every
> solution out there (with FF, chrome etc) with no working method.
> i really wish org-protocol had a much simpler way of capturing
> links,text tec. im not a programmer but to me it seems so complicated.
> it the past before i was using org i had a simple bash script that
> yanked links/text from dwb (a simple web browser) and added that to a
> text file. something like this
>
> #!/bin/bash
> # dwb: xtm
> task add pro:dl +music $DWB_TITLE $DWB_URI 

> where the current title+URI of the webpage was added to a text file
> (task add) command.
>
> would love something simple like that for orgmode

I think you could put something like this in the script:

emacsclient "org-protocol://capture?url=$DWB_URI=$DWB_TITLE"

If you wanted to add the extra project and tag information (e.g.,
"music"), you could create a custom capture template and then designate
the template shortcut (e.g., "m") in the script:

emacsclient "org-protocol://capture?template=m=$DWB_URI=$DWB_TITLE"

Matt



Re: [O] capture with iceweasel/firefox -- nothing works

2016-06-03 Thread Matt Lundin
Matt Lundin  writes:

> Samuel Wales  writes:
>
>> over many years, i have been trying to get org-protocol (or
>> anything similar) to work, and it is not working reliably.
>>
>> intermittently, it says there is a greedy protocol. the success rate
>> of capturing is around 50% maybe. when it is not working, it never
>> works. i have noticed no correlation with anything that could cause
>> this.

Another thought. Is the emacs server always running (either by starting
emacs as a daemon or by invoking server-start)?

Matt



Re: [O] capture with iceweasel/firefox -- nothing works

2016-06-03 Thread Matt Lundin
Samuel Wales  writes:

> over many years, i have been trying to get org-protocol (or
> anything similar) to work, and it is not working reliably.
>
> intermittently, it says there is a greedy protocol. the success rate
> of capturing is around 50% maybe. when it is not working, it never
> works. i have noticed no correlation with anything that could cause
> this.
>
> sometimes it captures bogus text when i just want the link, but i
> don't care about that. at least it copied the link.
>
> i've tried:
>
>   1) org-capture firefox extension
>   2) a bookmark like this
>  - 
> javascript:location.href%20=%20'org-protocol://capture-html://w/'%20+%20encodeURIComponent(location.href)%20+%20'/'%20+%20encodeURIComponent(document.title)%20+%20'/'%20+%20encodeURIComponent(function%20()%20{var%20html%20=%20"";%20if%20(typeof%20document.getSelection%20!=%20"undefined")%20{var%20sel%20=%20document.getSelection();%20if%20(sel.rangeCount)%20{var%20container%20=%20document.createElement("div");%20for%20(var%20i%20=%200,%20len%20=%20sel.rangeCount;%20i%20<%20len;%20++i)%20{container.appendChild(sel.getRangeAt(i).cloneContents());}%20html%20=%20container.innerHTML;}}%20else%20if%20(typeof%20document.selection%20!=%20"undefined")%20{if%20(document.selection.type%20==%20"Text")%20{html%20=%20document.selection.createRange().htmlText;}}%20var%20relToAbs%20=%20function%20(href)%20{var%20a%20=%20document.createElement("a");%20a.href%20=%20href;%20var%20abs%20=%20a.protocol%20+%20"//"%20+%20a.host%20+%20a.pathname%20+%20a.search%20+%20a.hash;%20a.remove();%20return%20abs;};%20var%20elementTypes%20=%20[['a',%20'href'],%20['img',%20'src']];%20var%20div%20=%20document.createElement('div');%20div.innerHTML%20=%20html;%20elementTypes.map(function(elementType)%20{var%20elements%20=%20div.getElementsByTagName(elementType[0]);%20for%20(var%20i%20=%200;%20i%20<%20elements.length;%20i++)%20{elements[i].setAttribute(elementType[1],%20relToAbs(elements[i].getAttribute(elementType[1])));}});%20return%20div.innerHTML;}());
>   3) a bookmark like this
>  - 
> javascript:location.href='org-protocol://capture://L/'+encodeURIComponent(location.href)+'/'+encodeURIComponent(document.title)+'/'+encodeURIComponent(window.getSelection())
>   4) i know there's a new one that is supposed to capture
>  format better (so you don't end up with a single
>  paragraph when there were several paragraphs).  that
>  sounds wonderful!  however, i am limited in computer
>  use (4 minutes at a time), so i don't know if it is
>  worth my trying or not.  i have to use those 4 minutes responsibly.

Here is the new style bookmark that works for me:

javascript:location.href='org-protocol://capture?url='+encodeURIComponent(location.href)+'='+encodeURIComponent(document.title)+'='+encodeURIComponent(window.getSelection())

I also placed the following in ~/.local/share/applications/emacsclient.desktop:

--8<---cut here---start->8---
[Desktop Entry]
Name=Emacs Client
Exec=emacsclient %u
Icon=emacs-icon
Type=Application
Terminal=false
MimeType=x-scheme-handler/org-protocol;
--8<---cut here---end--->8---

Since you are not using a desktop environment, you might also need to
make sure that the appropriate xdg tools are installed. On arch linux
the package is xdg-utils.

I'd recommend copying and pasting the javascript line above into the
location bar to confirm whether it works. If it does, you can then
easily add it to your bookmarks.

Note: There is a bug in the implementation of the new org-protocol url
processing that can lead to multiple "greedy protocol" warnings. (I
posted a bug report about this a week or so ago.)

Hope this helps.
Matt



[O] Restricting admisible tags depending on header

2016-06-03 Thread Óscar Fuentes
I'll like to offer only certain tags depending on the contents of the
current header. For instance, if the header is

* Status

I want to see only "open" and "closed" on the options shown by
org-fast-tag-selection.

Currently I define quite a lot of tags with #+TAGS:, most of them are
intended to be assigned to a specific header. Having so many tags
displayed by org-fast-tag-selection is confusing, error-prone and breaks
the selection method (org-fast-tag-selection runs out of letters).

I'm thinking on advising org-fast-tag-selection and prune the list of
acceptable tags before calling the real function, but maybe there is a
better method.




Re: [O] capture with iceweasel/firefox -- nothing works

2016-06-03 Thread Xebar Saram
Hi

i will add that im exactly in the same situatuon
i use a window manager (i3) on arch linux and have tried almost every
solution out there (with FF, chrome etc) with no working method.
i really wish org-protocol had a much simpler way of capturing links,text
tec. im not a programmer but to me it seems so complicated. it the past
before i was using org i had a simple bash script that yanked links/text
from dwb (a simple web browser) and added that to a text file. something
like this

#!/bin/bash
# dwb: xtm
task add pro:dl +music $DWB_TITLE $DWB_URI

where the current title+URI of the webpage was added to a text file (task
add) command.

would love something simple like that for orgmode

best

Z




On Sat, Jun 4, 2016 at 4:33 AM, Samuel Wales  wrote:

> please note that i do not use a desktop environment, just a window
> manager.  if this is relevant, please tell me.  i do not understand
> mime or things like that.
>
>


Re: [O] capture with iceweasel/firefox -- nothing works

2016-06-03 Thread Samuel Wales
please note that i do not use a desktop environment, just a window
manager.  if this is relevant, please tell me.  i do not understand
mime or things like that.



Re: [O] capture with iceweasel/firefox -- nothing works

2016-06-03 Thread Samuel Wales
On 6/3/16, Samuel Wales  wrote:
>   4) i know there's a new one that is supposed to capture
>  format better (so you don't end up with a single
>  paragraph when there were several paragraphs).  that
>  sounds wonderful!

https://github.com/alphapapa/org-protocol-capture-html



[O] capture with iceweasel/firefox -- nothing works

2016-06-03 Thread Samuel Wales
over many years, i have been trying to get org-protocol (or
anything similar) to work, and it is not working reliably.

intermittently, it says there is a greedy protocol.  the
success rate of capturing is around 50% maybe.  when it is not
working, it never works.  i have
noticed no correlation with anything that could cause this.

sometimes it captures bogus text when i just want the link,
but i don't care about that.  at least it copied the link.

i've tried:

  1) org-capture firefox extension
  2) a bookmark like this
 - 
javascript:location.href%20=%20'org-protocol://capture-html://w/'%20+%20encodeURIComponent(location.href)%20+%20'/'%20+%20encodeURIComponent(document.title)%20+%20'/'%20+%20encodeURIComponent(function%20()%20{var%20html%20=%20"";%20if%20(typeof%20document.getSelection%20!=%20"undefined")%20{var%20sel%20=%20document.getSelection();%20if%20(sel.rangeCount)%20{var%20container%20=%20document.createElement("div");%20for%20(var%20i%20=%200,%20len%20=%20sel.rangeCount;%20i%20<%20len;%20++i)%20{container.appendChild(sel.getRangeAt(i).cloneContents());}%20html%20=%20container.innerHTML;}}%20else%20if%20(typeof%20document.selection%20!=%20"undefined")%20{if%20(document.selection.type%20==%20"Text")%20{html%20=%20document.selection.createRange().htmlText;}}%20var%20relToAbs%20=%20function%20(href)%20{var%20a%20=%20document.createElement("a");%20a.href%20=%20href;%20var%20abs%20=%20a.protocol%20+%20"//"%20+%20a.host%20+%20a.pathname%20+%20a.search%20+%20a.hash;%20a.remove();%20return%20abs;};%20var%20elementTypes%20=%20[['a',%20'href'],%20['img',%20'src']];%20var%20div%20=%20document.createElement('div');%20div.innerHTML%20=%20html;%20elementTypes.map(function(elementType)%20{var%20elements%20=%20div.getElementsByTagName(elementType[0]);%20for%20(var%20i%20=%200;%20i%20<%20elements.length;%20i++)%20{elements[i].setAttribute(elementType[1],%20relToAbs(elements[i].getAttribute(elementType[1])));}});%20return%20div.innerHTML;}());
  3) a bookmark like this
 - 
javascript:location.href='org-protocol://capture://L/'+encodeURIComponent(location.href)+'/'+encodeURIComponent(document.title)+'/'+encodeURIComponent(window.getSelection())
  4) i know there's a new one that is supposed to capture
 format better (so you don't end up with a single
 paragraph when there were several paragraphs).  that
 sounds wonderful!  however, i am limited in computer
 use (4 minutes at a time), so i don't know if it is
 worth my trying or not.  i have to use those 4 minutes responsibly.
  5) i followed various instructions

i currently using iceweasel 38.8.0 (debian jessie) and
emacs-version "24.4.1".

i understand elisp and org.

however, i don't understand javascript or org-protocol's
internal concepts.  i am limited in concentration ability,
so this could be a problem.  i am also hazy on how to set up
a bookmark, but i somehow managed to do it twice.

===

i am very often physically unable to use a keyboard.  during
these times i am often able to use a pointing device (2
mouses, one for clicking and one for moving).

i am often using firefox (iceweasel) and want to capture
things to org using only the mouse.

that's why i want this feature to work so much.

===

i want to use org-capture extension or similar so that i can
copy snippets of text like this:

  * [[link][descr]]
  text that i selected
  ---

(the --- indicates that it came from iceweasel, and is not something i wrote.)

or just the plain link like this if nothing is selected:

  * [[link][descr]]

i have this working.  it is just unreliable, failing randomly at random times.

(note: i don't want emacs to pop up and there should be no keyboard
interaction.  useful if emacs switches to the buffer it is saved to,
however.  i have all that stuff taken care of in my elisp.  that part
i understand and can fix by myself.)

===

i am stuck on this.

after all that long-windedness, my question is this:

  *what is the most reliable set of instructions or code to
  get iceweasel to work with org?*

i'd be grateful for any useful hints.

thanks.


samuel

===

here are just 2 of the many elisp-side things i tried over
the years to get this to work.  elisp i can handle.

  (setq org-capture-templates
(append
 org-capture-templates
 `(
   ("p" "Protocol" entry (file+headline ,(concat org-directory
"notes.org") "Inbox")
"* %^{Title}\nSource: %u, %c\n
#+BEGIN_QUOTE\n%i\n#+END_QUOTE\n\n\n%?")
   ("L" "Protocol Link" entry (file+headline ,(concat
org-directory "notes.org") "Inbox")
"* %? [[%:link][%:description]] \nCaptured On: %U")
   )))
  ;; --- https://github.com/sprig/org-capture-extension#set-up-handlers-in-emacs

  (cl-loop for key in '("L" "p")
   do
   (add-to-list
'org-capture-templates
`(,key
  ,(format "Protocol %s" key)
  entry
  (file+headline
   ,org-default-notes-file
  

Re: [O] colored code background in org 8.3

2016-06-03 Thread Rasmus
John Kitchin  writes:

> I am finally getting around to switching over to org 8.3... One thing I
> miss already is the colored background in the code blocks. I recall that
> was removed. Has anyone looked into a way to put it back?

I use the attached patch for some "interactive slides" with babel.

(require 'color)
(set-face-attribute 'org-block nil :inherit 'fixed-pitch
:background (color-darken-name
 (face-attribute 'default :background) 3))

You might also set :inherit of org-block-{begin,end}-line.

Rasmus

PS: My apology if I sent this twice now. 

-- 
Not everything that goes around comes back around, you know
>From 86244d84f8846489b893039749d724287c2c5dcd Mon Sep 17 00:00:00 2001
From: Rasmus 
Date: Fri, 3 Jun 2016 15:31:58 +0200
Subject: [PATCH] org-src: src-blocks also inherit org-block face

* lisp/org-src.el (org-src-font-lock-fontify-block): Inherit org-block
  face.
---
 lisp/org-src.el | 24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index f3a0960..9668096 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -494,21 +494,27 @@ as `org-src-fontify-natively' is non-nil."
 (when (fboundp lang-mode)
   (let ((string (buffer-substring-no-properties start end))
 	(modified (buffer-modified-p))
-	(org-buffer (current-buffer)) pos next)
+	(org-buffer (current-buffer)))
 	(remove-text-properties start end '(face nil))
 	(with-current-buffer
 	(get-buffer-create
-	 (concat " org-src-fontification:" (symbol-name lang-mode)))
-	  (delete-region (point-min) (point-max))
+	 (format " *org-src-fontification:%s*" lang-mode))
+	  (erase-buffer)
 	  (insert string " ") ;; so there's a final property change
 	  (unless (eq major-mode lang-mode) (funcall lang-mode))
 	  (org-font-lock-ensure)
-	  (setq pos (point-min))
-	  (while (setq next (next-single-property-change pos 'face))
-	(put-text-property
-	 (+ start (1- pos)) (1- (+ start next)) 'face
-	 (get-text-property pos 'face) org-buffer)
-	(setq pos next)))
+	  (let ((pos (point-min)) next)
+	(while (setq next (next-single-property-change pos 'face))
+	  (let ((new-face (get-text-property pos 'face)))
+		(put-text-property
+		 (+ start (1- pos)) (1- (+ start next)) 'face
+		 (list :inherit (append (and new-face (list new-face))
+	(list 'org-block)))
+		 org-buffer))
+	  (setq pos next))
+	;; Add the face to the remaining part of the font.
+	(put-text-property (1- (+ start pos)) end 'face
+			   '(:inherit org-block) org-buffer)))
 	(add-text-properties
 	 start end
 	 '(font-lock-fontified t fontified t font-lock-multiline t))
-- 
2.8.3



Re: [O] Open Peer-Review Reproducible Publication with Org and GRASS

2016-06-03 Thread Brett Viren
Thanks for your example.

A few ideas:

- When you begin developing your paper, or sometime before submission,
  make a break from your personal ~/.emacs.d/ environment and begin
  processing the .org in an explicitly configured Emacs session.  Submit
  the needed, minimal, paper-specific Emacs setup as part of the
  supplementary material.

- Bundle the document building into a shell script which calls Emacs so
  that you can assure that personal ~/.emacs.d/ is excluded and only the
  paper-specific Emacs setup is used.  It also helps users to rebuild
  the paper, especially if they may not yet be Emacs aficionados.

- Instead of multi-GB VM image, provide a few kB Dockerfile which can be
  used to build a Linux container with base OS and all required
  applications needed to run the Babel code blocks.

- The Dockerfile could go so far as to create a user account, get the
  supplementary material from a repository or the publisher's web page,
  unpack and run the shell script which calls Emacs to build the
  document.  If you go this far then in principle just this Dockerfile
  is enough to reproduce the paper - but this will rely on some binaries
  to remain available (Docker base OS images and OS packages).

The reliance on long-term availability of the Docker base OS image and
binary packages is problematic for long term automated reproducibility.
However, even after those bits disappear from the 'net the Dockerfile
serves as a concise and explicit recipe for future humans to follow.

-Brett.


Ken Mankoff  writes:

> Hi Org and GRASS lists,
>
> I just wanted to let these two lists know that I've just posted a
> paper written in Org and using GRASS (text-mode) and Python for the
> analysis. My goal was to create not just an open access publication,
> but a fully reproducible publication. This is an early announcement,
> and the paper may not pass peer review.
>
> The Supplemental Material is the Org file with all the code to
> generate the document, beginning with downloading the 3rd party data
> that is input to our analysis, the GRASS code to perform the analysis,
> and the Python code to regenerate the figures.
>
> I don't think I did a great job on the reproducible part because I
> have a highly customized .emacs, etc. All the information necessary to
> replicate the work should be in the Supplemental Material, but it
> might not be easy to do so. Anyway, I think it is a step in the right
> direction.
>
> To make it easier to reproduce... including my emacs.org seems
> overkill. Including a Virtual Machine that contains everything,
> including my ~/.emacs.d/ and all the software and data seems like the
> right thing to do, but journals don't want to host a 20 GB VM with the
> publication.
>
> Thanks to people on these two lists who have developed the software and 
> helped me use it.
>
>-k.
>
> http://www.the-cryosphere-discuss.net/tc-2016-113/


signature.asc
Description: PGP signature


[O] Open Peer-Review Reproducible Publication with Org and GRASS

2016-06-03 Thread Ken Mankoff
Hi Org and GRASS lists,

I just wanted to let these two lists know that I've just posted a paper written 
in Org and using GRASS (text-mode) and Python for the analysis. My goal was to 
create not just an open access publication, but a fully reproducible 
publication. This is an early announcement, and the paper may not pass peer 
review.

The Supplemental Material is the Org file with all the code to generate the 
document, beginning with downloading the 3rd party data that is input to our 
analysis, the GRASS code to perform the analysis, and the Python code to 
regenerate the figures.

I don't think I did a great job on the reproducible part because I have a 
highly customized .emacs, etc. All the information necessary to replicate the 
work should be in the Supplemental Material, but it might not be easy to do so. 
Anyway, I think it is a step in the right direction.

To make it easier to reproduce... including my emacs.org seems overkill. 
Including a Virtual Machine that contains everything, including my ~/.emacs.d/ 
and all the software and data seems like the right thing to do, but journals 
don't want to host a 20 GB VM with the publication.

Thanks to people on these two lists who have developed the software and helped 
me use it.

   -k.
   
http://www.the-cryosphere-discuss.net/tc-2016-113/



[O] Should org-get-outline-path strip dedicated targets?

2016-06-03 Thread timor
If I have a document like this:

* some header <>
** some subtree
*** some entry

Then calling org-get-outline-path on the deepest headline returns
("some header <>" "some subtree")

I don't know what exactly org-get-outline-path is used for in org
mode, but for what I want to use it, I will remove the
"<>" part manually.

I was just wondering if maybe this should already be done in
org-get-outline-path itself, since links are also replaced by their
description according to the documentation.

regards,
timor



Re: [O] babel and bibliography

2016-06-03 Thread Joseph Mingrone
John Kitchin  writes:

> This works for me.

> #+TITLE:
> #+AUTHOR:
> #+LaTeX_HEADER: \usepackage{natbib}

> The moon in June is like a big ballon \citep{self1987asymptotic}.

> #+BEGIN_LATEX
> \bibliographystyle{abbrvnat}
> \bibliography{/home/jrm/scm/references.git/refs}
> #+END_LATEX

Ah, of course. Thanks. :)

Joseph


signature.asc
Description: PGP signature


Re: [O] Problem with Including subsection by CUSTOM_ID

2016-06-03 Thread Ilya Filippov
Thanks, Rasmus!

I upgrade org-mode to 8.3 and this is solve the problem.

13.05.2016, 14:49, "Rasmus" :
> Hi,
>
> Ilya Filippov  writes:
>
>>  I try to include subsection from one org-file to another
>>  (http://orgmode.org/manual/Include-files.html) with using CUSTOM_ID.
>>
>>  In first-file.org:
>>
>>  ** Subsection name
>>  :PROPERTIES:
>>  :CUSTOM_ID: subsec_to_include
>>  :END:
>>
>>  bla-bla
>>
>>  In second-file.org I use construction:
>>
>>  * I want include here
>>
>>  #+INCLUDE: "./first-file.org::#funcNT10"
>>
>>  And when I export second file to PDF, org-mode gives an error message:
>>  "Cannot include file /org/first-file.org::#funcNT10"
>
> Maybe you need to use "./first-file.org:#subsec_to_include", or maybe it's
> just a typo in your email. You need Org 8.3.
>
> Hope it helps,
> Rasmus
>
> --
> However beautiful the theory, one should occasionally look at the evidence

- - - - - - - - - - -
Ilya Filippov
Yugra State University (Chekhova str. 16, Khanty-Mansiysk, Tyumen' Region, 
Russian Federation, 628012): 

1. Environmental Dynamics & Global Climate Change Research Centre, Senior 
Engineer
2. Biology Chair, Docent
3. Journal of Environmental Dynamics & Global Climate Change, Editorial Board 
Member

GoogleScholar profile: http://scholar.google.ru/citations?user=Prc5qkMJ

Tel: +79088817605



Re: [O] [PATCH] Make today's deadlines "close" without lead time

2016-06-03 Thread Don March
Nicolas Goaziou  writes:

> Thank you for the patch.

And thank you for your thousands of patches!

> Did you sign FSF papers?

Yes, August 2011, #699456.

> Also, would you mind providing a few tests for this function, in
> "test-org.el"?

Not at all. The new patch---which includes the original changes and the new
tests---is attached. While I was in there, I made a second patch that renames
the function to have a `-p' predicate suffix.

Hopefully I put the tests somewhere close to where they belong.
From 4953e495b938011582fb0c7c7bf9064530ce9294 Mon Sep 17 00:00:00 2001
From: Don March 
Date: Wed, 1 Jun 2016 00:05:12 -0400
Subject: [PATCH 1/2] Make today's deadlines "close" without lead time

* lisp/org.el (org-deadline-close): A timestamp is close if the days
  between now and the timestamp are less then or equal to the days of
  lead time.

* testing/lisp/test-org.el: Add tests for org-deadline-close.
---
 lisp/org.el  |  2 +-
 testing/lisp/test-org.el | 28 
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index e015a77..13883c5 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17480,7 +17480,7 @@ If SECONDS is non-nil, return the difference in seconds."
 (defun org-deadline-close (timestamp-string  ndays)
   "Is the time in TIMESTAMP-STRING close to the current date?"
   (setq ndays (or ndays (org-get-wdays timestamp-string)))
-  (and (< (org-time-stamp-to-now timestamp-string) ndays)
+  (and (<= (org-time-stamp-to-now timestamp-string) ndays)
(not (org-entry-is-done-p
 
 (defun org-get-wdays (ts  delay zero-delay)
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 6884c24..576402a 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -364,6 +364,34 @@
 	  (calendar-gregorian-from-absolute
 	   (org-closest-date "<2012-03-29 +2y>" "<2014-03-04>" 'future)
 
+(ert-deftest test-org/deadline-close ()
+  "Test `org-deadline-close' specifications."
+  ;; Pretend that the current time is 2016-06-03 Fri 01:43
+  (cl-flet ((current-time () '(22353 6425 905205 644000)))
+;; Timestamps are close if they are within `ndays' of lead time.
+(org-test-with-temp-text "* Heading"
+  (should (org-deadline-close "2016-06-03 Fri" 0))
+  (should (org-deadline-close "2016-06-02 Thu" 0))
+  (should-not (org-deadline-close "2016-06-04 Sat" 0))
+  (should (org-deadline-close "2016-06-04 Sat" 1))
+  (should (org-deadline-close "2016-06-03 Fri 12:00" 0)))
+;; Read `ndays' from timestamp if argument not given.
+(org-test-with-temp-text "* H"
+  (should (org-deadline-close "2016-06-04 Sat -1d"))
+  (should-not (org-deadline-close "2016-06-04 Sat -0d"))
+  (should (org-deadline-close "2016-06-10 Fri -1w"))
+  (should-not (org-deadline-close "2016-06-11 Sat -1w")))
+;; Prefer `ndays' argument over lead time in timestamp.
+(org-test-with-temp-text "* H"
+  (should (org-deadline-close "2016-06-04 Sat -0d" 1))
+  (should-not (org-deadline-close "2016-06-04 Sat -0d" 0)))
+;; Completed tasks are never close.
+(let ((org-todo-keywords '(("TODO" "|" "DONE"
+  (org-test-with-temp-text "* TODO Heading"
+	(should (org-deadline-close "2016-06-03")))
+  (org-test-with-temp-text "* DONE Heading"
+	(should-not (org-deadline-close "2016-06-03"))
+
 
 ;;; Drawers
 
-- 
2.8.1

From 143f802073989fff8fe464244f53089e79e92812 Mon Sep 17 00:00:00 2001
From: Don March 
Date: Fri, 3 Jun 2016 02:49:55 -0400
Subject: [PATCH 2/2] Rename org-deadline-is-close to have -p suffix

* lisp/org-agenda.el
  (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item):
* lisp/org.el (org-deadline-close): Rename to...
  (org-deadline-close-p): ...this.

* testing/lisp/test-org.el (test-org/deadline-close): Rename to...
  (test-org/deadline-close-p): ...this.
---
 lisp/org-agenda.el   |  4 ++--
 lisp/org.el  |  4 ++--
 testing/lisp/test-org.el | 30 +++---
 3 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 50f520c..7994187 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -5550,7 +5550,7 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
 	   (cond
 		((memq org-agenda-todo-ignore-deadlines '(t all)) t)
 		((eq org-agenda-todo-ignore-deadlines 'far)
-		 (not (org-deadline-close (match-string 1
+		 (not (org-deadline-close-p (match-string 1
 		((eq org-agenda-todo-ignore-deadlines 'future)
 		 (> (org-time-stamp-to-now
 		 (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0))
@@ -5560,7 +5560,7 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
 		((numberp org-agenda-todo-ignore-deadlines)
 		 (org-agenda-todo-custom-ignore-p
 		  (match-string 1) org-agenda-todo-ignore-deadlines))
-		(t (org-deadline-close 

Re: [O] org-mode command in a bash script?

2016-06-03 Thread Robert Klein
Hi,

On Fri, 03 Jun 2016 06:36:12 +0100
Sharon Kimble  wrote:

> 
> How can I run an org-mode command in a bash script please?
> 
> Specifically 'org-latex-export-to-latex'?
> 
> I'm developing my own modular script to choose between, at present, 3
> tex files which have been pre-exported from org-mode. I'm now
> wondering if its possible to export from the org-mode file as part of
> another module in the script.
> 
> Can it be done, and if so, how please?


I'm using this shell function for exporting certain documents to pdf:


orgexp()
{
emacs  --batch -l ~/.emacs --eval \
   "(progn
 (setq org-latex-image-default-width \".4cm\"
   org-export-allow-bind-keywords t
   org-confirm-babel-evaluate nil)
 (find-file \"$1\")
 (org-latex-export-to-pdf))"
}


You probably don't want to set the variables, so for export to latex
this might work (i.e. I didn't test it):


org2latex()
{
emacs  --batch -l ~/.emacs --eval \
   "(progn
 (find-file \"$1\")
 (org-latex-export-to-latex))"
}


If you put this in your .bashrc you can just use
org2latex myfile.org
to export myfile.org to latex.

Best regards
Robert