Re: [O] message:// links

2018-11-09 Thread Nicolas Goaziou
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



Re: [O] indentation error in python source block

2018-11-09 Thread Nicolas Goaziou
Hello,

Seb  writes:

> I believe I've hit a strange bug. Given this file:
>
> ------
> #+STARTUP: content indent hideblocks
> #+PROPERTY: header-args :tangle yes
> #+PROPERTY: header-args:python :session *Python*
>
> #+NAME: python_init
> #+BEGIN_SRC python :results silent :exports none
> import matplotlib as mpl
> mpl.use("Agg")
> import matplotlib.pyplot as plt
> import numpy as np
> import pandas as pd
> #+END_SRC
>
> #+NAME: test
> #+BEGIN_SRC python :results file :exports results
> beg = ["2017-07-13 15:27:31", "2017-07-13 15:28:24"]
> beg = pd.to_datetime(beg)
> end = ["2017-07-13 15:28:03", "2017-07-13 15:28:57"]
> end = pd.to_datetime(end)
> pos = np.arange(1, 3).tolist()
> experiment = pd.DataFrame(dict(index=np.arange(1, 3),
>beg=beg, end=end, pos=pos))
> # Mid points
> experiment["mid"] = (experiment["beg"] +
>  (experiment["end"] - experiment["beg"]) / 2)
> fig, axs = plt.subplots(3, 1, sharex=True)
> # Shade experiment periods
> for idx, row in experiment.iterrows():
> for ax in axs:
> ax.axvspan(row["beg"], row["end"], facecolor="0.5")
> axs[0].annotate(row["pos"], (row["mid"], 1), ha="center",
> xycoords=("data", "axes fraction"))
> # TEMPORARY: limit to experiment periods
> axs[0].set_xlim(experiment["beg"].iloc[0],
> experiment["end"].iloc[-1])
> fig.tight_layout()
> fig.savefig("junk.png", bbox_inches="tight")
> plt.close()
> "junk.png"
> #+END_SRC
> ------
>
>
> Problem is in the second source block.  With point on the #+BEGIN line,
> hitting C-c to execute the block yields indentation errors in the
> Python process (first one):
>
> ------
 experiment["end"].iloc[-1])
>   File "", line 1
> axs[0].annotate(row["pos"], (row["mid"], 1), ha="center",
> ^
> IndentationError: unexpected indent
> ------

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

Regards,

-- 
Nicolas Goaziou



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

2018-11-09 Thread Nicolas Goaziou
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.

HTH,

-- 
Nicolas Goaziou



[O] Writing Exporter Tests [was: slack syntax exporter/copier]

2018-11-09 Thread Matt Price
OK, I have a minimal working example and would like to add some unit tests
to this project, largely as a way to learn more about testing in emacs/org
so that I can start writing tests for some other projects.

However... I don't really understand how to build tests in org (and in fact
I don't really understand ert much at all). Looks like the worg page is
largely a stub. Does anyone have any hints for getting started? Like,
should i be able to use ~testing/test-ox.el~ to test my exporter?

I would like to start doing a better job of developing in elisp, but I am
having trouble getting started on my own, so, once again, I appreciate any
help you cna give!

Thanks,
Matt



On Mon, Oct 22, 2018 at 9:02 PM Matt Price  wrote:

>
>
> On Mon, Oct 22, 2018 at 5:29 PM Neil Jerram 
> wrote:
>
>> Matt Price  writes:
>>
>> > A while ago I asked about a slack syntax exporter.  I cpy text from org
>> to
>> > slack often enough that I spent an hour or two today writing a simple
>> one,
>> > which I put up in a  gist:
>> > https://gist.github.com/titaniumbones/c0c171e4df8a6ff5f0f564b8a655c079
>>
>> Nice, thank you!
>>
>> > If people are interested, I will be happy to package it up & put on
>> melpa
>> > or whatever (would be the first time for me).
>>
>> Yes, I think it's quite likely that I would use this sometimes, so I'd
>> love if it was conveniently available.
>>
>>
> I've put it up in a repo: https://github.com/titaniumbones/ox-slack
>
> I don't know how to add something to Melpa so that might be a while, I
> think I'm running out of personal time :-)
>
> Best wishes,
>>Neil
>>
>>
>> > I mostly am interested in copy-paste, not in producing permanent files,
>> so
>> > I use it with this simple utility function:
>> >
>> > (defun ora-org-export-to-clipboard-as-slack ()
>> >   "Export region to FMT, and copy to the kill ring for pasting into
>> > other programs."
>> >   (interactive)
>> >   (let* ((org-export-with-toc nil)
>> >  (org-export-with-smart-quotes nil))
>> > (kill-new (org-export-as 'slack) ))
>> >   )
>> > (global-set-key (kbd "C-c W s")
>> 'ora-org-export-to-clipboard-as-slack)
>> >
>> > The "ora" prefix reflects its origins in an old oremacs function that I
>> use
>> > for (much more involved) HTML copy-paste:
>> > - [[
>> >
>> https://github.com/abo-abo/oremacs/commit/6c86696c0a1f66bf690e1a934683f85f04c6f34d#diff-ecff87135600df0cafffb47c303ae9c6][abo-abo's
>> > code from oremacs]]
>> > - [[
>> >
>> http://kitchingroup.cheme.cmu.edu/blog/2016/06/16/Copy-formatted-org-mode-text-from-Emacs-to-other-applications/#comment-2735698988][john's
>> > original post]]
>> >
>> >
>> > SO far it seems OK. There are doubtless still bugs so probably it would
>> be
>> > better to make a repo after all!
>>
>


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

2018-11-09 Thread Matt Price
ah, thank you Diego, I wil ltry it out and report back.

On Fri, Nov 9, 2018 at 4:29 AM Diego Zamboni  wrote:

> Hi Matt,
>
> I found a solution for this, which I am using with my (still in
> development) setup for exporting from org-mode to LeanPub. I found a
> function for extracting document global properties at
> https://emacs.stackexchange.com/a/21715, which you could use to support
> your first example. After defining =org-global-prop-value=, you could call
> it like this:
>
> (org-global-prop-value "ORG_LMS_COURSE")
>
> You can see my setup, including the two functions, here:
> https://github.com/zzamboni/dot-emacs/blob/master/init.org#publishing-to-leanpub
>
> Hope this helps!
>
> --Diego
>
>
>
> On Fri, Nov 9, 2018 at 4:33 AM Matt Price  wrote:
>
>> 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
>>
>> or
>>
>> #+PROPERTY: org-lms-course hackinghistory
>>
>> I thought the latter might work but (org-entry-get-with-inheritance
>> "org-lms-course) and (org-entry-get-with-inheritance "ORG_LMS_COURSE") both
>> return nil.  The former is in any case somewhat cleaner-looking but I am
>> not finding in the manual an instructions on how to add my own keywords.
>> Is it possible to do this? I can of course always set a buffer-local
>> variable in a src block, e.g.:
>> #+begin_src emacs-lisp
>> (setq org-lms-course 'becomingmodern)
>> #+end_src.
>>
>> but I would like to be able to avoid that where possible.
>>
>> Thanks for the help as usual!
>>
>>
>>


[O] message:// links

2018-11-09 Thread Jean-Christophe Helary
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 ?

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





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

2018-11-09 Thread Thomas S. Dye

Aloha Van L,

Thanks for your contribution.

The Org mode manual and Worg are separate documents.  AFAIK there is no 
mechanism to have changes in  one propagate changes in the other.


If you'd like to propose a change to the manual, please submit a patch 
following the instructions here: 
https://orgmode.org/worg/org-contribute.html.


All the best,
Tom


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

2018-11-09 Thread Van L


> Thanks for your interest in Org mode and Worg.

I hope the worg entry will backprob to the info:org page.



Re: [O] map function definitions to org src blocks?

2018-11-09 Thread John Kitchin
It looks like it is possible to get describe-func to point to an org-file.
Suppose I have a file /Users/jkitchin/vc/journal/2018/11/09/2018-11-09.org
that has src blocks that tangle to
/Users/jkitchin/vc/journal/2018/11/09/test.el. When test.el is loaded, it
adds a bunch of stuff to the variable load-history that describe-function
can use to get information. For example:

#+BEGIN_SRC emacs-lisp
(assoc "/Users/jkitchin/vc/journal/2018/11/09/test.el" load-history)
#+END_SRC

#+RESULTS:
: (/Users/jkitchin/vc/journal/2018/11/09/test.el (defun . some-func))

One solution is to just change the file name in load-history like this.

#+BEGIN_SRC emacs-lisp
(setf (car (assoc "/Users/jkitchin/vc/journal/2018/11/09/test.el"
load-history)) "/Users/jkitchin/vc/journal/2018/11/09/2018-11-09.org")
#+END_SRC
John

Something like this could be handled in an :after advice for example.

This is only lightly tested... I don't know if it has other implications.

---
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 Thu, Nov 8, 2018 at 10:22 PM Matt Price  wrote:

> THanks John. I guess I should always just start my search for "something
> cool I saw" in scimax...
>
> Yes, thisis pretty great. I havebeen using ~helpful~ which hasa nice
> interface for some extra functions, but these functions do most of what I
> felt was missing.
>
> On Thu, Nov 8, 2018 at 6:02 PM John Kitchin 
> wrote:
>
>> I wrote something kind of like this at
>>
>> https://github.com/jkitchin/scimax/blob/master/scimax-literate-programming.el
>>
>>
>> It might solve a different problem related to navigating code embedded in
>> org files.
>>
>> I don't think it works on describe-function. That would be an interesting
>> addition perhaps. I guess though that describe-function would go to the
>> elisp code. I never figured out how to get links in the tangled code to
>> jump back to the org file though.
>>
>> On Thu, Nov 8, 2018 at 5:39 PM Matt Price  wrote:
>>
>>> I feel like I saw someone do this but can't find it in my notes. When
>>> tangling code to elisp, is it possible to point ~describe-function~ to the
>>> original org-mode source (or at least the src block) as the "source code"
>>> for the function, rather than the resultant .e file produced by
>>> org-babel-tangle? Seems like this would make a whole lot of things
>>> significantly easier when writing emacs inits, for instnace.
>>>
>> --
>> 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] Tasks performed on a certain day

2018-11-09 Thread Gregor Zattler
Hi Nicolas, org mode users and developers,
* Nicolas Goaziou  [2018-11-08; 18:34]:
> However, I think some users need to have multiple so-called events in
> the same headline, e.g., for irregularly repeating tasks.

Yes, I do this all the time.  For instance there is a heading for
visits at the dentist in my org file which contains plain
timestamps for every day I went there.  This is quite handy as
I'm able to tell when I was there with a glance at this list of
plain stamps.  This may be helpful when dealing with the
insurance company.

If a heading could only hold one event timestamp I would need
much more headings which look somewhat heavy because of the
markup, the way they are shown and most probably would also
feature a drawer each .  OTHT I could then archive all old visits
at the dentist, have a smaller org file but it would be more
difficult to reconstruct past dates with my dentist.  Because
then they would be scattered among other headings in the archive
file and the only way of finding out would be to generate an
agenda from the archive file.


Ciao; Gregor
-- 
 -... --- .-. . -.. ..--.. ...-.-




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

2018-11-09 Thread Diego Zamboni
Hi Matt,

I found a solution for this, which I am using with my (still in
development) setup for exporting from org-mode to LeanPub. I found a
function for extracting document global properties at
https://emacs.stackexchange.com/a/21715, which you could use to support
your first example. After defining =org-global-prop-value=, you could call
it like this:

(org-global-prop-value "ORG_LMS_COURSE")

You can see my setup, including the two functions, here:
https://github.com/zzamboni/dot-emacs/blob/master/init.org#publishing-to-leanpub

Hope this helps!

--Diego



On Fri, Nov 9, 2018 at 4:33 AM Matt Price  wrote:

> 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
>
> or
>
> #+PROPERTY: org-lms-course hackinghistory
>
> I thought the latter might work but (org-entry-get-with-inheritance
> "org-lms-course) and (org-entry-get-with-inheritance "ORG_LMS_COURSE") both
> return nil.  The former is in any case somewhat cleaner-looking but I am
> not finding in the manual an instructions on how to add my own keywords.
> Is it possible to do this? I can of course always set a buffer-local
> variable in a src block, e.g.:
> #+begin_src emacs-lisp
> (setq org-lms-course 'becomingmodern)
> #+end_src.
>
> but I would like to be able to avoid that where possible.
>
> Thanks for the help as usual!
>
>
>