[O] How to advice around org-insert-link to disable desc part of link?

2018-11-10 Thread stardiviner
I use org-attach to add/download image file from local or web url. Then [C-c 
C-l] (org-insert-link) to insert link from previous added attach image file.

In some places like ox-html, ox-epub, they use inline images without desc to 
display image. If has `[desc]` part, the image will become a link. So I hope 
can add an advice around function `org-insert-link` or somewhere should.

Anybody knows how to do this? Can you show the code? I checked out 
`org-insert-link` source code, don't know how to add advice around it.

-- 
[ stardiviner ]
   I try to make every word tell the meaning what I want to express.

   Blog: https://stardiviner.github.io/
   IRC(freenode): stardiviner, Matrix: stardiviner
   GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
  



Re: [O] [feature] Handle recurrence in <> and [] dates

2018-11-10 Thread Leo Gaspard
Nicolas Goaziou  writes:
> Org didn't handle repeaters in inactive time stamps. This is now fixed
> (in master). Thank you.

Great, thank you!



Re: [O] Bug: Wrong parsed indiced for field range in org-table [9.1.14 (9.1.14-9-g131531-elpa @ /home/xavier/.emacs.d/elpa/org-20181105/)]

2018-11-10 Thread Xavier Raynaud
I tested with a clean emacs configuration (as proposed in orgmode page
https://orgmode.org/manual/Feedback.html#Feedback) and it worked as it
should.

I am sorry for not having done that at once. I'll do it next time.

Thank you for answering my question and I apologize again for not having
followed the recommendations

Best regards,

Xavier

Den lør. 10. nov. 2018 kl. 22:01 skrev Nicolas Goaziou <
m...@nicolasgoaziou.fr>:

> Hello,
>
> Xavier Raynaud  writes:
>
> > In the table below, the number 1 in @1$1 is entered and equal to
> > one. When I calculate the table, only the number 1 in @2$1 is added,
> > while I expect also  @1$1 to be set.
> >
> > |   | 1 |
> > | 1 |   |
> >
> > #+TBLFM: @1$1..@2$1=@1$2
>
> With the table above, using  on the TBLFM line, I get:
>
> | 1 | 1 |
> | 1 |   |
> #+TBLFM: @1$1..@2$1=@1$2
>
> So the bug is probably fixed already in development version.
>
> Regards,
>
> --
> Nicolas Goaziou
>


[O] Links for getting email in Gmail (IMAP) with Gnus ?

2018-11-10 Thread Joseph Vidal-Rosset
Hello,

I know that it is possible to link emails in Todo list, but I meet
difficulties with Gmail IMAP and Gnus when the mail is in the box "All
emails" ("Tous les messages" in French): as soon as the email is in this
Archive, the link is broken and Gnus does not fetch it.

Help and code are welcome.

Best wishes,

Jo.


Re: [O] Bug: Wrong parsed indiced for field range in org-table [9.1.14 (9.1.14-9-g131531-elpa @ /home/xavier/.emacs.d/elpa/org-20181105/)]

2018-11-10 Thread Nicolas Goaziou
Hello,

Xavier Raynaud  writes:

> In the table below, the number 1 in @1$1 is entered and equal to
> one. When I calculate the table, only the number 1 in @2$1 is added,
> while I expect also  @1$1 to be set.
>
> |   | 1 |
> | 1 |   |
>
> #+TBLFM: @1$1..@2$1=@1$2

With the table above, using  on the TBLFM line, I get:

| 1 | 1 |
| 1 |   |
#+TBLFM: @1$1..@2$1=@1$2

So the bug is probably fixed already in development version.

Regards,

-- 
Nicolas Goaziou



[O] Bug: Wrong parsed indiced for field range in org-table [9.1.14 (9.1.14-9-g131531-elpa @ /home/xavier/.emacs.d/elpa/org-20181105/)]

2018-11-10 Thread Xavier Raynaud
Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good
report?  See

 https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.
-
---

In the table below, the number 1 in @1$1 is entered and equal to
one. When I calculate the table, only the number 1 in @2$1 is added,
while I expect also  @1$1 to be set.

|   | 1 |
| 1 |   |
#+TBLFM: @1$1..@2$1=@1$2

I looked at the source. It seems to me that org-table-line-to-dline is
doing something wrong in this case (returns the wrong value for line =
1).

Thank's for your help and all the effort you have put in this code.


Emacs  : GNU Emacs 25.3.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
 of 2017-09-15
Package: Org mode version 9.1.14 (9.1.14-9-g131531-elpa @
/home/xavier/.emacs.d/elpa/org-20181105/)

current state:
==
(setq
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe org-babel-
header-arg-expand)
 org-speed-command-hook '(org-speed-command-activate org-babel-speed-
command-activate)
 org-occur-hook '(org-first-headline-recenter)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-confirm-shell-link-function 'yes-or-no-p
 org-image-actual-width nil
 org-time-stamp-custom-formats '("<%a %d %b %y, week %V>" . "<%m/%d/%y
%a %H:%M>")
 org-display-custom-times t
 org-file-apps '((auto-mode . emacs) ("\\.mm\\'" . default)
("\\.x?html?\\'" . default) ("\\.pdf\\'" . emacs))
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-src-mode-hook '(org-src-babel-configure-edit-buffer org-src-mode-
configure-edit-buffer)
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-babel-pre-tangle-hook '(save-buffer)
 org-mode-hook '(#[0 "\300\301\302\303\304$\207" [add-hook change-
major-mode-hook org-show-block-all append local] 5]
 #[0 "\300\301\302\303\304$\207" [add-hook change-
major-mode-hook org-babel-show-result-all append local] 5]
 org-babel-result-hide-spec org-babel-hide-all-hashes
(lambda nil (define-key org-mode-map [M-iso-lefttab] (quote show-
subtree)))
 (lambda nil (define-key org-mode-map (kbd "C-c C-q")
(quote counsel-org-tag
 org-refile-targets '((nil :maxlevel . 4))
 org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3
"\n\n(fn ENTRY)"]
 org-outline-path-complete-in-steps nil
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-use-speed-commands t
 org-refile-use-outline-path t
 org-directory "/home/xavier/Desktop/org"
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-
drawers org-cycle-show-empty-lines org-optimize-window-after-
visibility-change)
 org-link-mode-hook '((lambda nil (read-only-mode 1) (define-key org-
link-mode-map (kbd "RET") (quote follow-bookmark-link))
   (define-key org-link-mode-map (kbd "q") (quote
kill-this-buffer))
   (define-key org-link-mode-map (kbd "i") (quote
previous-line)) (define-key org-link-mode-map (kbd "k") (quote next-
line))
   (define-key org-link-mode-map (kbd "e") (quote
open-bookmark-buffer-for-editing)))
  )
 org-M-RET-may-split-line '((default . t) (item))
 org-show-context-detail '((agenda . local) (bookmark-jump . lineage)
(isearch . lineage) (default . ancestors) (tags-tree . local))
 org-cycle-include-plain-lists 'integrate
 org-confirm-elisp-link-function 'yes-or-no-p
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-link-parameters '(("id" :follow org-id-open) ("rmail" :follow org-
rmail-open :store org-rmail-store-link)
   ("mhe" :follow org-mhe-open :store org-mhe-
store-link) ("irc" :follow org-irc-visit :store org-irc-store-link)
   ("info" :follow org-info-open :export org-info-
export :store org-info-store-link)
   ("gnus" :follow org-gnus-open :store org-gnus-
store-link)
   ("docview" :follow org-docview-open :export org-
docview-export :store org-docview-store-link)
   ("bibtex" :follow org-bibtex-open :store org-
bibtex-store-link)
   ("bbdb" :follow org-bbdb-open :export org-bbdb-
export :complete org-bbdb-complete-link :store org-bbdb-store-link)
   ("w3m" :store org-w3m-store-link) ("file+sys")
("file+emacs")
   ("pdfview" :follow org-pdfview-open :complete
org-pdfview-complete-link :store org-pdfview-store-link)
   ("ipynb" :follow ein:org-open :help-echo "Open
ipython notebook." :store ein:org-store-link)
   ("doi" :follow org--open-doi-link) ("elisp"
:follow org--open-elisp-link) ("file" :complete org-file-complete-link)
   ("ftp" :follow (lambda (path) (browse-url
(concat "ftp:" path ("help" :follow org--open-help-link)
   ("http" :f

Re: [O] [feature] Handle recurrence in <> and [] dates

2018-11-10 Thread Nicolas Goaziou
Hello,

Leo Gaspard  writes:

> Here is a translated example task from my .org file:
>
> *** TODO Check bank report
> SCHEDULED: <2000-02-10 Thu +1m>
>
> Dated [2000-01-01 Sat +1m]
>
> The point of this “Dated” field being to tell me to which report I
> should be looking, given I sometimes am a month late or so in checking
> my reports, and just put them in the (physical) drawer as I receive
> them.
>
> This “Dated” field is exactly what I would like to see updated when I
> mark the task as done (like the SCHEDULED date), but it looks like it
> doesn't move.

Org didn't handle repeaters in inactive time stamps. This is now fixed
(in master). Thank you.

Regards,

-- 
Nicolas Goaziou



Re: [O] creating new #+KEYWORD: variables

2018-11-10 Thread Nicolas Goaziou
Hello,

John Kitchin  writes:

> You can retrieve keywords in the org-file like this:
>
> (defun get-keyword (key)
>   (org-element-map (org-element-parse-buffer) 'keyword
> (lambda (k)
>   (when (string= key (org-element-property :key k))
> (org-element-property :value k)))
> nil t))

As a minor addendum, 

(org-element-parse-buffer 'element)

is more efficient in this case. 

An even more efficient way to retrieve keywords, assuming buffer is not
already parsed, would be:

(org-with-point-at 1
  (let ((case-fold-search t)
(regexp (format "^[ \t]*#\\+%s:" key))
(result nil))
(while (re-search-forward regexp nil t)
  (let ((element (org-element-at-point)))
(when (eq 'keyword (org-element-type element))
  (push (org-element-property :value element) result
result))

Regards,

-- 
Nicolas Goaziou



Re: [O] creating new #+KEYWORD: variables

2018-11-10 Thread John Kitchin
You can retrieve keywords in the org-file like this:

(defun get-keyword (key)
  (org-element-map (org-element-parse-buffer) 'keyword
(lambda (k)
  (when (string= key (org-element-property :key k))
(org-element-property :value k)))
nil t))

(get-keyword "ORG_LMS_COURSE")


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 Sat, Nov 10, 2018 at 11:17 AM Matt Price  wrote:

>
>
> On Sat, Nov 10, 2018 at 2:22 AM Nicolas Goaziou 
> wrote:
>
>> Hello,
>>
>> Matt Price  writes:
>>
>> > I am writing this interface to my university's learning management
>> system:
>> >
>> https://github.com/titaniumbones/Org-Marking-Mode/tree/use-structured-course-def
>> .
>> > I am only using hte exporting system tangentially and I have not
>> defined a
>> > new exporter. However, I would really like to be able to set some
>> variable
>> > values in the header section of hte document, e.g.:
>> >
>> > #+ORG_LMS_COURSE: becomingmodern
>>
>> You can add keywords specific to a given export back-end in its
>> definition, more precisely in :options-alist value. For example, in
>> "ox-texinfo", there is
>>
>> (org-export-define-backend 'texinfo
>>   '((bold . org-texinfo-bold))
>>   ...
>>   :options-alist
>>   '((:texinfo-filename "TEXINFO_FILENAME" nil nil t)
>> ...))
>>
>> which means `texinfo' back-end should recognize the "#+TEXINFO_FILENAME"
>> keyword, and store its value in the :texinfo-filename property from
>> "info" paramater, which is passed to each function.
>>
>> You can write a derived back-end using this new keyword, along with
>> a template function that actually uses it. Look at the definition of
>> `beamer' back-end for an example.
>>
>> Thank you as always, Nicolas. I have not written a derived backend for
> this, though I guess many of the functions are export-like and in osme ways
> thatwould make a lot of sense. But I also need to use the course id to
> receive data from the courseware server, so for instance, right now I have
> this code:
>
> --
> (defun org-lms-get-students (&optional course)
>   (unless course
> (setq course org-lms-course))
>   (let* ((courseid (plist-get course :id))
>  (result
>  (org-lms-canvas-request (format "courses/%s/users" courseid) "GET"
>  '(("enrollment_type[]" . "student")
>("include[]" . "email")
> (message "RESULTS")
> ;;(with-temp-file "students-canvas.json" (insert result))
> (loop for student in-ref result
>   do
>   (if (string-match "," (plist-get student :sortable_name))
>   (let ((namelist  (split-string (plist-get student
> :sortable_name) ", ")))
> (plist-put student :lastname (car namelist) )
> (plist-put student :firstname (cadr namelist)
> result))
>
> ---
>
> Is there aclever way to extract the value of ~org-lms-course~ from the
> exporter even if what I'm doing really isn't an export? I'm actually
> harvesting JSON data  from the server, rather than producing an export
> file.
>
>
>> HTH,
>>
>> --
>> Nicolas Goaziou
>>
>


Re: [O] typo, sp at C++ Source Code Blocks in Org Mode

2018-11-10 Thread Thomas S. Dye

Aloha Van L,


On Sat, Nov 10, 2018 at 12:17 AM, Van L  wrote:


 AFAIK there is no mechanism to have changes in  one propagate 
changes in the other.


It should be possible to link the two because both are org files.

Worg would need to render to info:worg.


That's an interesting idea.  AFAICT it should be possible.  
Nevertheless, my guess is that it would be a lot of work to mark up the 
Worg sources to get well-formatted info output.


All the best,
Tom


Re: [O] creating new #+KEYWORD: variables

2018-11-10 Thread Matt Price
On Sat, Nov 10, 2018 at 2:22 AM Nicolas Goaziou 
wrote:

> Hello,
>
> Matt Price  writes:
>
> > I am writing this interface to my university's learning management
> system:
> >
> https://github.com/titaniumbones/Org-Marking-Mode/tree/use-structured-course-def
> .
> > I am only using hte exporting system tangentially and I have not defined
> a
> > new exporter. However, I would really like to be able to set some
> variable
> > values in the header section of hte document, e.g.:
> >
> > #+ORG_LMS_COURSE: becomingmodern
>
> You can add keywords specific to a given export back-end in its
> definition, more precisely in :options-alist value. For example, in
> "ox-texinfo", there is
>
> (org-export-define-backend 'texinfo
>   '((bold . org-texinfo-bold))
>   ...
>   :options-alist
>   '((:texinfo-filename "TEXINFO_FILENAME" nil nil t)
> ...))
>
> which means `texinfo' back-end should recognize the "#+TEXINFO_FILENAME"
> keyword, and store its value in the :texinfo-filename property from
> "info" paramater, which is passed to each function.
>
> You can write a derived back-end using this new keyword, along with
> a template function that actually uses it. Look at the definition of
> `beamer' back-end for an example.
>
> Thank you as always, Nicolas. I have not written a derived backend for
this, though I guess many of the functions are export-like and in osme ways
thatwould make a lot of sense. But I also need to use the course id to
receive data from the courseware server, so for instance, right now I have
this code:

--
(defun org-lms-get-students (&optional course)
  (unless course
(setq course org-lms-course))
  (let* ((courseid (plist-get course :id))
 (result
 (org-lms-canvas-request (format "courses/%s/users" courseid) "GET"
 '(("enrollment_type[]" . "student")
   ("include[]" . "email")
(message "RESULTS")
;;(with-temp-file "students-canvas.json" (insert result))
(loop for student in-ref result
  do
  (if (string-match "," (plist-get student :sortable_name))
  (let ((namelist  (split-string (plist-get student
:sortable_name) ", ")))
(plist-put student :lastname (car namelist) )
(plist-put student :firstname (cadr namelist)
result))

---

Is there aclever way to extract the value of ~org-lms-course~ from the
exporter even if what I'm doing really isn't an export? I'm actually
harvesting JSON data  from the server, rather than producing an export
file.


> HTH,
>
> --
> Nicolas Goaziou
>


Re: [O] indentation error in python source block

2018-11-10 Thread Sebastian P . Luque
On Sat, 10 Nov 2018 08:30:50 +0100,
Nicolas Goaziou  wrote:

[...]

> I cannot reproduce your error. You may want to upgrade Org.

I'm already using the latest Org from Elpa (9.1.14), and get the error
with:

$ emacs -q -l emacs_pkg_init.el

╭─ [ emacs_pkg_init.el ]
│ (setq package-archives
│(quote
│ (("gnu" . "http://elpa.gnu.org/packages/";)
│  ("melpa" . "http://melpa.org/packages/";)
│  ("marmalade" . "https://marmalade-repo.org/packages/";)
│  ("org" . "http://orgmode.org/elpa/";
│ (package-initialize)
│ (org-babel-do-load-languages
│  'org-babel-load-languages
│  '((python . t)))
╰─

-- 
Seb




Re: [O] Bug: Capture template insertion fails with #+FOO [9.1.14 (9.1.14-1-g4931fc-elpa @ /home/phil/.emacs.d/elpa/org-9.1.14/)]

2018-11-10 Thread Philip Hudson
On Sat, 10 Nov 2018 at 10:39, Nicolas Goaziou  wrote:
>
> I stand on my ground: capturing an entry should be limited to real
> entries, no exception.

Fine. Thanks for your patience, and sorry I demanded so much of it.

-- 
Phil Hudson  http://hudson-it.ddns.net
Pretty Good Privacy (PGP) ID: 0x4E482F85



Re: [O] Bug: Capture template insertion fails with #+FOO [9.1.14 (9.1.14-1-g4931fc-elpa @ /home/phil/.emacs.d/elpa/org-9.1.14/)]

2018-11-10 Thread Nicolas Goaziou
Hello,

Philip Hudson  writes:

> You have been very clear and categorical about the definition of a
> top-level entry/node/heading as a chunk of text starting with a single
> asterisk (followed by whitespace, arbitrary heading text, optional
> tags and optional further lines of text -- the foundational structure
> all Org users are familiar with).

Not a single asterisk. One or more asterisks.

> You insist that if there is
> Something Else before that asterisk -- "data", in your latest reply --
> then your chunk of text is simply and categorically not an entry. Such
> a chunk of text may or may not /contain/ an entry, but it is
> definitely not itself an entry.

Correct.

> For any preceding Something Else to disqualify a chunk of text as an
> entry, it must first be Something. Lexically speaking, in-buffer
> settings are comments; thus, lexically speaking, they are whitespace;
> thus, lexically speaking, they are Nothing, not Something. That is my
> argument for allowing preceding in-buffer settings within the
> definition of an entry, not just in the context of org-capture but
> throughout Org.

Org has no comment syntax, not in the sense of what you would expect in
a programming language. It has something called a "comment", e.g.,

# This is a comment

but this is meaningful for the exporter only. In an Org document, it is
behaves as a paragraph, e.g.:

1. Item1
# Comment
1. Item2

instead of

1. Item1
# Comment
2. Item2

There is no Nothing in an Org document.

Of course, there syntactical elements in such a document. #+FOO: is one
of them. So are #+BEGIN_CENTER and CLOCK:. But there is no reason to
support capturing them before an entry, and not regular text. This is
just inconsistent.

This is also useless, as I pointed out already, since the location of
keywords in a document doesn't matter. They need not be before the first
heading.

Eventually, it is awkward. Think about capturing an entry with text
before it, in the "Target" node below:


  * Target
  Target contents
  ** Child
  Child contents

It could become:

  * Target
  Target contents
  ** Child
  Child contents
  Captured before
  ** Captured
  Captured contents

i.e., you modify "Child" contents even though you capture into "Target".
It is possible that someone may come up with a use-case for that, but
I would suggest them to implement their own capture mechanism. Org
shouldn't support that.

I stand on my ground: capturing an entry should be limited to real
entries, no exception.

Regards,

-- 
Nicolas Goaziou



Re: [O] typo, sp at C++ Source Code Blocks in Org Mode

2018-11-10 Thread Van L


> AFAIK there is no mechanism to have changes in  one propagate changes in the 
> other.

It should be possible to link the two because both are org files. 

Worg would need to render to info:worg.


Re: [O] message:// links

2018-11-10 Thread Jean-Christophe Helary
Thank you Nicolas.

Jean-Christophe 

> On Nov 10, 2018, at 16:28, Nicolas Goaziou  wrote:
> 
> Hello,
> 
> Jean-Christophe Helary  writes:
> 
>> I'm pasting a message:// link into an org-mode file but it fails to be
>> recognized as a link that should open in a mail client.
>> 
>> What is a simple way to have org-mode recognize such links ?
> 
> One simple way is to define "message:" as an alias for "mailto:";, which
> is the Org syntax for such links.  This is done with
> `org-link-abbrev-alist' variable, or in-buffer "LINK" keyword:
> 
>  (setq org-link-abbrev-alist '(("message" . "mailto")))
> 
> One drawback is that you cannot write plain links with abbreviations. So
> [[message:f...@bar.baz]] works, but message:@f...@bar.baz does not.
> 
> If that is an issue, you can also define a new link with
> `org-link-set-parameters':
> 
>(org-link-set-parameters "message" 
> :follow (lambda (path) (browse-url (concat "mailto:"; path
> 
> HTH,
> 
> Regards,
> 
> -- 
> Nicolas Goaziou

Jean-Christophe Helary
---
http://mac4translators.blogspot.com @brandelune




Re: [O] [BUG][ODT] ODT_STYLES_FILE not read as a list

2018-11-10 Thread Nicolas Goaziou
Hello,

"L.C. Karssen"  writes:

> Taking the risk that the manual is lagging behind the actual code, I see
> the following:
>
> #+ODT_STYLES_FILE:uses quotes
>
> #+INCLUDE:uses quotes
> #+TEXINFO_FILENAME:   doesn't use quotes [1]
>
> #+SETUPFILE:  no example in the manual
> #+HTML_INCLUDE_STYLE: no example in the manual, not sure if this
>
> requires a file or CSS code
>
> Another point to consider: would requiring quoted filenames make life
> easier for people using spaces etc. in their filenames? In that case I'd
> vote for quotes.

Org allows both quoted and unquoted filenames. It is a bug if you spot
a location where it is not the case. I fixed TEXINFO_FILENAME.

HTML_INCLUDE_STYLE keyword doesn't exist anymore.

It doesn't matter which type the manual uses, IMO.

Regards,

-- 
Nicolas Goaziou