[O] [PATCH] org-store-link: Don't roll C-u behavior into C-u C-u behavior

2017-05-20 Thread Kyle Meyer
York Zhao  writes:

[...]

> Seems to be a reasonable solution to me. So would you go ahead and make the
> change, or, would more people need to agreed on this solution?

If there are no objections within a few days, I'll apply the following
patch to maint.

-- >8 --
Subject: [PATCH] org-store-link: Don't roll C-u behavior into C-u C-u behavior

* lisp/org.el (org-store-link): When a double C-u prefix argument is
given, do not reverse the meaning of the org-context-in-file-links
option.
* testing/lisp/test-org.el (test-org/store-link): Add tests.

This allows the user to fall back to the core link storing functions
without also reversing their org-context-in-file-links preference,
because wanting to do the former does not mean a user also wants to do
the latter.

Reported-by: York Zhao 

---
 lisp/org.el  | 13 
 testing/lisp/test-org.el | 77 +++-
 2 files changed, 84 insertions(+), 6 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index c8bab8712..da1420f66 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9921,9 +9921,10 @@ (defun org-store-link (arg)
 This link is added to `org-stored-links' and can later be inserted
 into an Org buffer with `org-insert-link' (`\\[org-insert-link]').
 
-For some link types, a `\\[universal-argument]' prefix ARG is interpreted.
-For links to Usenet articles, ARG negates `org-gnus-prefer-web-links'.
-For file links, ARG negates `org-context-in-file-links'.
+For some link types, a `\\[universal-argument]' prefix ARG is interpreted.  \
+A single
+`\\[universal-argument]' negates `org-context-in-file-links' for file links or
+`org-gnus-prefer-web-links' for links to Usenet articles.
 
 A `\\[universal-argument] \\[universal-argument]' prefix ARG forces \
 skipping storing functions that are not
@@ -10085,7 +10086,8 @@ (defun org-store-link (arg)
(abbreviate-file-name
 (buffer-file-name (buffer-base-buffer)
   ;; Add a context search string
-  (when (org-xor org-context-in-file-links arg)
+  (when (org-xor org-context-in-file-links
+ (equal arg '(4)))
 (let* ((element (org-element-at-point))
(name (org-element-property :name element)))
   (setq txt (cond
@@ -10112,7 +10114,8 @@ (defun org-store-link (arg)
 (abbreviate-file-name
  (buffer-file-name (buffer-base-buffer)
;; Add a context string.
-   (when (org-xor org-context-in-file-links arg)
+   (when (org-xor org-context-in-file-links
+  (equal arg '(4)))
  (setq txt (if (org-region-active-p)
(buffer-substring (region-beginning) (region-end))
  (buffer-substring (point-at-bol) (point-at-eol
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 237d7aae4..ebbea9bb0 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -2399,7 +2399,82 @@ (ert-deftest test-org/store-link ()
  (org-test-with-temp-text-in-file "#+NAME: foo\nParagraph"
(let ((file (buffer-file-name)))
 (equal (format "[[file:%s::foo][foo]]" file)
-   (org-store-link nil)))
+   (org-store-link nil))
+  ;; Store link to Org buffer, with context.
+  (should
+   (let ((org-stored-links nil)
+(org-id-link-to-org-use-id nil)
+(org-context-in-file-links t))
+ (org-test-with-temp-text-in-file "* h1"
+   (let ((file (buffer-file-name)))
+(equal (format "[[file:%s::*h1][h1]]" file)
+   (org-store-link nil))
+  ;; Store link to Org buffer, without context.
+  (should
+   (let ((org-stored-links nil)
+(org-id-link-to-org-use-id nil)
+(org-context-in-file-links nil))
+ (org-test-with-temp-text-in-file "* h1"
+   (let ((file (buffer-file-name)))
+(equal (format "[[file:%s][file:%s]]" file file)
+   (org-store-link nil))
+  ;; C-u prefix reverses `org-context-in-file-links' in Org buffer.
+  (should
+   (let ((org-stored-links nil)
+(org-id-link-to-org-use-id nil)
+(org-context-in-file-links nil))
+ (org-test-with-temp-text-in-file "* h1"
+   (let ((file (buffer-file-name)))
+(equal (format "[[file:%s::*h1][h1]]" file)
+   (org-store-link '(4)))
+  ;; A C-u C-u does *not* reverse `org-context-in-file-links' in Org
+  ;; buffer.
+  (should
+   (let ((org-stored-links nil)
+(org-id-link-to-org-use-id nil)
+(org-context-in-file-links nil))
+ (org-test-with-temp-text-in-file "* h1"
+   (let ((file (buffer-file-name)))
+(equal (format "[[file:%s][file:%s]]" file file)
+   (org-store-link '(16)))
+  ;; Store file link to 

Re: [O] `org-store-link' to skip link storing functions without touching `org-context-in-file-links'

2017-05-20 Thread York Zhao
> Yeah, org-store-link overloads ARG

Exactly!

> I think that, when negating org-context-in-file-links, the function should
> check whether a single C-u was given rather than just checking if ARG is
> non-nil.

Seems to be a reasonable solution to me. So would you go ahead and make the
change, or, would more people need to agreed on this solution?

> If someone uses C-u C-u to fall back to core Org functions, I don't see
any
> reason to assume that they also want to reverse their
> org-context-in-file-links preference.

Maybe!


Thanks,

York


On Sat, May 20, 2017 at 6:55 PM, Kyle Meyer  wrote:

> York Zhao  writes:
>
> > However, the biggest problem I'm having now is that once I loaded
> > org-git-link.el, I'm forced to always store links linking to git
> repository
> > which is not always I want because I also need to be able to store links
> > linking to the files in the working directory instead of in the git
> > repository.
> >
> > I'm aware of the 'C-u C-u' prefix of `org-store-link', however, by the
> > current design, using 'C-u C-u' negates `org-context-in-file-links',
> i.e.,
> > the link would be stored without embedding the text to search for.
>
> Yeah, org-store-link overloads ARG, and there seems to be an undesirable
> interaction here.
>
> > Is it possible to make `org-store-link' able to skip the link storing
> > functions without touching `org-context-in-file-links'?
>
> I think that, when negating org-context-in-file-links, the function
> should check whether a single C-u was given rather than just checking if
> ARG is non-nil.  If someone uses C-u C-u to fall back to core Org
> functions, I don't see any reason to assume that they also want to
> reverse their org-context-in-file-links preference.
>
> --
> Kyle
>


Re: [O] returning propertized strings

2017-05-20 Thread Charles C. Berry

On Sat, 20 May 2017, John Kitchin wrote:


If I run this block I get test as a result, but all its properties have
been stripped.

#+BEGIN_SRC emacs-lisp :results drawer
(propertize "test" 'font-lock-face '(:foreground "red") 'help-echo
"tooltip")
#+END_SRC

#+RESULTS:
:RESULTS:
test
:END:

Does anyone know where this happens and if it can be avoided?


Where?

Not sure, but late enough that `:results pp' will print them or `:post 
...' will receive them in `*this*'.


#+BEGIN_SRC emacs-lisp :results drawer pp
(propertize "test" 'font-lock-face '(:foreground "red") 'help-echo 
"tooltip")

#+END_SRC

#+RESULTS:
: #("test" 0 4
:   (help-echo "tooltip" font-lock-face
:(:foreground "red")))

also `*this*' will contain the propertized version if you use the :post 
header arg.


HTH,

Chuck




[O] returning propertized strings

2017-05-20 Thread John Kitchin
If I run this block I get test as a result, but all its properties have
been stripped.

#+BEGIN_SRC emacs-lisp :results drawer
(propertize "test" 'font-lock-face '(:foreground "red") 'help-echo
"tooltip")
#+END_SRC

#+RESULTS:
:RESULTS:
test
:END:

Does anyone know where this happens and if it can be avoided?

Thanks,
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


Re: [O] `org-store-link' to skip link storing functions without touching `org-context-in-file-links'

2017-05-20 Thread Kyle Meyer
York Zhao  writes:

> However, the biggest problem I'm having now is that once I loaded
> org-git-link.el, I'm forced to always store links linking to git repository
> which is not always I want because I also need to be able to store links
> linking to the files in the working directory instead of in the git
> repository.
>
> I'm aware of the 'C-u C-u' prefix of `org-store-link', however, by the
> current design, using 'C-u C-u' negates `org-context-in-file-links', i.e.,
> the link would be stored without embedding the text to search for.

Yeah, org-store-link overloads ARG, and there seems to be an undesirable
interaction here.

> Is it possible to make `org-store-link' able to skip the link storing
> functions without touching `org-context-in-file-links'?

I think that, when negating org-context-in-file-links, the function
should check whether a single C-u was given rather than just checking if
ARG is non-nil.  If someone uses C-u C-u to fall back to core Org
functions, I don't see any reason to assume that they also want to
reverse their org-context-in-file-links preference.

-- 
Kyle



Re: [O] Bug: right-alignment fails in column view [9.0.7 (release_9.0.7-439-g2906e5 @ /home/tews/src/org-mode/lisp/)]

2017-05-20 Thread Nicolas Goaziou
Hello,

Hendrik Tews  writes:

> in section 7.5.1.2 Column attributes, the manual says
>
> Numbers are right-aligned when a format specifier with an
> explicit width like ā€˜%5dā€™ or ā€˜%5.1fā€™ is used.
>
> However, I see something similar to
>
>5.0 | * a|
> 5.0| ** b   |
>
> when I start column view for
>
> * a
> ** b
>   :PROPERTIES:
>   :XX:   5.0
>   :END:
>
> #+COLUMNS: %6XX{+;%6.1f} %10ITEM

Fixed. Thank you.

Regards,

-- 
Nicolas Goaziou



[O] `org-store-link' to skip link storing functions without touching `org-context-in-file-links'

2017-05-20 Thread York Zhao
Hi org-mode developers,

Recently I found it very useful to being able to store links linking to
source code in git repository. I used org-git-link.el for this purpose and
it works well.

However, the biggest problem I'm having now is that once I loaded
org-git-link.el, I'm forced to always store links linking to git repository
which is not always I want because I also need to be able to store links
linking to the files in the working directory instead of in the git
repository.

I'm aware of the 'C-u C-u' prefix of `org-store-link', however, by the
current design, using 'C-u C-u' negates `org-context-in-file-links', i.e.,
the link would be stored without embedding the text to search for.

Is it possible to make `org-store-link' able to skip the link storing
functions without touching `org-context-in-file-links'?


Thanks in advance,

York


Re: [O] [PATCH] org.el: Fix indentation in lists after blocks with special env

2017-05-20 Thread Tim Stewart
Hi,

Nicolas Goaziou  writes:

> Hello,
>
> Tim Stewart  writes:
>
>> * lisp/org.el (org--get-expected-indentation): Fix indentation within
>>   lists after blocks that support a special editing environment.
>>
>> Testing shows that the indentation within lists is incorrect after
>> `example-block', `export-block', and `source-block'.  The logic falls
>> through and makes a recursive call to `org-get-indentation' which
>> results in an indent to the same level as the last line of the block's
>> contents.
>
> Thank you. Could you provide an ECM, however? I'm not able to reproduce
> it so far.

Huh.  I just tried to minimally reproduce and was unable to do so.  Then
I tried my standard configuration (without this patch) and was still
unable to reproduce!  To keep my sanity, I'm telling myself this may
have been fixed in the meantime.

There were several others at my workplace experiencing the issue--I will
have them remove the patch and retest in their environments.  I
apologize, I should have tried to provide an ECM from the beginning!

Thank you, and I'll let you know what I find,

-TimS

--
Tim Stewart
---
Mail:   t...@stoo.org
Matrix: @tim:stoo.org



Re: [O] Bug: org tags [9.0.7 (9.0.7-elpaplus @ ~/.emacs.d/elpa/org-plus-contrib-20170515/)]

2017-05-20 Thread Nicolas Goaziou
Hello,

"H.M. Pham"  writes:

> I just downloaded org-plus-contrib and my customizde capture stopped
> working. The function org-set-tags-to is different than the org
> package. The let form shows up in the org-plus-contrib.
>
> (when (let ((case-fold-search nil)) < i think this line is wrong
>  (looking-at org-complex-heading-regexp))

Could you explain the bug you're experiencing? An ECM would be great.

Regards,

-- 
Nicolas Goaziou



Re: [O] org-ref + ASME

2017-05-20 Thread John Kitchin


> * How to add ASME?
> I want to know if there is a way to add the ASME database to org-ref.
>
> I found this: https://github.com/jkitchin/org-ref/issues/148 which hints
> me in the right direction, but I don't know how to make it work.
>
> I am trying with this article:
> http://biomechanical.asmedigitalcollection.asme.org/article.aspx?articleid=1427237
>
> What I do is to M-x crossref-add-bibtex-entry, yank the title and do
> RET. I get the right BibTeX entry, but org-ref sends me to:
> http://biomechanical.asmedigitalcollection.asme.org/article.aspx?articleid=1427237.full.pdf

org-ref uses pattern matching to try to retrieve the pdf for you. In
this case, it looks like this url falls through to the generic pattern,
which doesn't actually point to the pdf.

>
> whilst the PDF is actually on
> http://biomechanical.asmedigitalcollection.asme.org/data/journals/jbendy/27048/101013_1.pdf

To fix this, you need a new function that takes the article url and
generates the pdf url somehow. I have added a function to org-ref to try
to do this. It seems to work on this example.

>
> I already have the PDF and the last digits 101013 (without _1) seem to
> be the page number.
>
> * How do I avoid downloading the PDF?

set doi-utils-download-pdf to nil.

> The above leads me to the second question: if I already have the PDF, is
> there a way to prevent downloading it again? The obvious answer is:
> "Duh! just drag the PDF onto Emacs!", but if I do it like that, I get
> another issue (already reported on github).

There probably is not a good way to make this easy. the simplest is just
to rename it according to the bibtex key and put it in the
org-ref-pdf-directory. See my comment on the issue on Github.


> org-ref: Version 1.0.0 (eab601)
> GNU Emacs 24.4.1
>
> Thank you in advance! :)
>
> -
>
> ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the 
> NSA's hands!
> $24.95 ONETIME Lifetime accounts with Privacy Features!
> 15GB disk! No bandwidth quotas!
> Commercial and Bulk Mail Options!


--
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



[O] org-refresh-stats-properties: Stack overflow in regexp matcher

2017-05-20 Thread Kevin Zettler
I suddenly am unable to open my org agenda.  Invoking ~C-a~ and selecting
any agenda command results in

~org-refresh-stats-properties: Stack overflow in regexp matcher~

The debug trace looks like:

#+BEGIN_SRC
Debugger entered--Lisp error: (error "Stack overflow in regexp matcher")
  re-search-forward("^\\*+
.*\\(?:\\[\\([0-9]+\\)%\\|\\([0-9]+\\)/\\([0-9]+\\)\\]\\)" nil t)
  org-refresh-stats-properties()
  org-agenda-prepare-buffers(("/Users/kev/Dropbox (Personal)/org/
2017_resolutions.org" "/Users/kev/Dropbox (Personal)/org/gcal.org"
"/Users/kev/Dropbox (Personal)/org/mobile-inbox.org" "/Users/kev/Dropbox
(Personal)/org/personal.org" "/Users/kev/Dropbox (Personal)/org/plebland.org"
"/Users/kev/Dropbox (Personal)/org/proposal.org" "/Users/kev/Dropbox
(Personal)/org/read.org" "/Users/kev/Dropbox (Personal)/org/recipies.org"
"/Users/kev/Dropbox (Personal)/org/reduxderiveddata.org" "~/Dropbox
(Personal)/org/gcal.org"))
  org-agenda-prepare("Day/Week")
  org-agenda-list(nil)
  funcall-interactively(org-agenda-list nil)
  call-interactively(org-agenda-list)
  org-agenda(nil)
  funcall-interactively(org-agenda nil)
  call-interactively(org-agenda nil nil)
  command-execute(org-agenda)
#+END_SRC

I suspected this was because I create a daily org file and have the dailies
in a wild card for ~org-agenda-files~ I have removed about ~300 files from
~org-agenda-files~ and it did not alleviate the issue.

The stacktrace above is without the daliy files

-- 
Kev Zettler
www.kevzettler.com


[O] Bug: org tags [9.0.7 (9.0.7-elpaplus @ ~/.emacs.d/elpa/org-plus-contrib-20170515/)]

2017-05-20 Thread H.M. Pham
I just downloaded org-plus-contrib and my customizde capture stopped
working. The function org-set-tags-to is different than the org
package. The let form shows up in the org-plus-contrib.

(when (let ((case-fold-search nil)) < i think this line is wrong
 (looking-at org-complex-heading-regexp))

Here is the function in org-plus-contrib
Emacs  : GNU Emacs 25.1.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.18.9)
of 2016-10-29
Package: Org mode version 9.0.7 (9.0.7-elpaplus @
/home/hp/.emacs.d/elpa/org-plus-contrib-20170515/)
(defun org-set-tags-to (data)
  "Set the tags of the current entry to DATA, replacing the current tags.
DATA may be a tags string like :aa:bb:cc:, or a list of tags.
If DATA is nil or the empty string, any tags will be removed."
  (interactive "sTags: ")
  (setq data
(cond
((eq data nil) "")
((equal data "") "")
((stringp data)
 (concat ":" (mapconcat 'identity (org-split-string data ":+") ":")
 ":"))
((listp data)
 (concat ":" (mapconcat 'identity data ":") ":"
  (when data
(save-excursion
  (org-back-to-heading t)
  (when (let ((case-fold-search nil))
 (looking-at org-complex-heading-regexp))
(if (match-end 5)
   (progn
 (goto-char (match-beginning 5))
 (insert data)
 (delete-region (point) (point-at-eol))
 (org-set-tags nil 'align))
 (goto-char (point-at-eol))
 (insert " " data)
 (org-set-tags nil 'align)))
  (beginning-of-line 1)
  (when (looking-at ".*?\\([ \t]+\\)$")
(delete-region (match-beginning 1) (match-end 1))



Here's the function from org:

(defun org-set-tags-to (data)
  "Set the tags of the current entry to DATA, replacing the current tags.
DATA may be a tags string like :aa:bb:cc:, or a list of tags.
If DATA is nil or the empty string, any tags will be removed."
  (interactive "sTags: ")
  (setq data
(cond
((eq data nil) "")
((equal data "") "")
((stringp data)
 (concat ":" (mapconcat 'identity (org-split-string data ":+") ":")
 ":"))
((listp data)
 (concat ":" (mapconcat 'identity data ":") ":"
  (when data
(save-excursion
  (org-back-to-heading t)
  (when (looking-at org-complex-heading-regexp)
(if (match-end 5)
   (progn
 (goto-char (match-beginning 5))
 (insert data)
 (delete-region (point) (point-at-eol))
 (org-set-tags nil 'align))
 (goto-char (point-at-eol))
 (insert " " data)
 (org-set-tags nil 'align)))
  (beginning-of-line 1)
  (if (looking-at ".*?\\([ \t]+\\)$")
 (delete-region (match-beginning 1) (match-end 1))


-- 
Best,
Huy Pham


[O] org-ref + ASME

2017-05-20 Thread edgar

Dear Dr. Kitchin and Org-mode mailing list,

I write to you, because I could not find a mailing list for org-ref. 
Thanks for your time.


I am just starting to use org-ref with the hope that my advisor sees the 
advantages of using Emacs (instead of the proprietary word processors). 
I'm a fan of Emacs, but not really good at Lisp (I just steal code from 
others :P ).


I have two questions.

* How to add ASME?
I want to know if there is a way to add the ASME database to org-ref.

I found this: https://github.com/jkitchin/org-ref/issues/148 which hints 
me in the right direction, but I don't know how to make it work.


I am trying with this article:
http://biomechanical.asmedigitalcollection.asme.org/article.aspx?articleid=1427237

What I do is to M-x crossref-add-bibtex-entry, yank the title and do 
RET. I get the right BibTeX entry, but org-ref sends me to:

http://biomechanical.asmedigitalcollection.asme.org/article.aspx?articleid=1427237.full.pdf

whilst the PDF is actually on
http://biomechanical.asmedigitalcollection.asme.org/data/journals/jbendy/27048/101013_1.pdf

I already have the PDF and the last digits 101013 (without _1) seem to 
be the page number.


* How do I avoid downloading the PDF?
The above leads me to the second question: if I already have the PDF, is 
there a way to prevent downloading it again? The obvious answer is: 
"Duh! just drag the PDF onto Emacs!", but if I do it like that, I get 
another issue (already reported on github).


org-ref: Version 1.0.0 (eab601)
GNU Emacs 24.4.1

Thank you in advance! :)

-

ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the 
NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features!  
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!  



Re: [O] org-refresh-stats-properties: Stack overflow in regexp matcher

2017-05-20 Thread Nicolas Goaziou
Hello,

Kevin Zettler  writes:

> Apologies if this is a duplicate. I first sent when I wasn't registered
> with the mailing list. Looks like org Gmane is down
> http://news.gmane.org/gmane.emacs.orgmode I get a 404.
>
> I suddenly am unable to open my org agenda.  Invoking ~C-a~ and selecting
> any agenda command results in
>
> ~org-refresh-stats-properties: Stack overflow in regexp matcher~
>
> The debug trace looks like:
>
> #+BEGIN_SRC
> Debugger entered--Lisp error: (error "Stack overflow in regexp matcher")
>   re-search-forward("^\\*+
> .*\\(?:\\[\\([0-9]+\\)%\\|\\([0-9]+\\)/\\([0-9]+\\)\\]\\)"
> nil t)

I cannot reproduce it, but I pushed a regexp simplification in maint
branch. Does it solve your issue?

There's also a dubious

  (progn (org-end-of-subtree t t) (point))

in the function, which means that non-top-level headlines are skipped.
I don't know if this is intended. Anyway, that's unrelated to your
issue.

Regards,

-- 
Nicolas Goaziou



Re: [O] [PATCH] org.el: Fix indentation in lists after blocks with special env

2017-05-20 Thread Nicolas Goaziou
Hello,

Tim Stewart  writes:

> * lisp/org.el (org--get-expected-indentation): Fix indentation within
>   lists after blocks that support a special editing environment.
>
> Testing shows that the indentation within lists is incorrect after
> `example-block', `export-block', and `source-block'.  The logic falls
> through and makes a recursive call to `org-get-indentation' which
> results in an indent to the same level as the last line of the block's
> contents.

Thank you. Could you provide an ECM, however? I'm not able to reproduce
it so far.

Regards,

-- 
Nicolas Goaziou



Re: [O] [Patch] Fix handling of variable capture location

2017-05-20 Thread Nicolas Goaziou
Hello,

Yuri Lensky  writes:

> I now understand what you mean by the second call to symbol-value not being
> needed. The previous behavior only chose this "branch" of the cond if
> symbol-value was not nil. To keep this behavior but only have one call to
> symbol-value, why not change to (keep the symbol-value in the cond as
> opposed to the body of the branch):
>
> ((and (symbolp file) (boundp file) (symbol-value file)))
>
> to keep the old behavior of the cond statement?

We don't need to keep the old behaviour. The current one is as good.

Regards,

-- 
Nicolas Goaziou