Re: could a :var header argument refer to a data table in another file?

2021-04-29 Thread John Kitchin
I don't know if it is in the manual. It would be great to have it in
https://orgmode.org/manual/Environment-of-a-Code-Block.html.

John

---
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



On Thu, Apr 29, 2021 at 9:42 AM Eric S Fraga  wrote:

> On Thursday, 29 Apr 2021 at 09:17, John Kitchin wrote:
> > This syntax works for me.
> >
> > #+BEGIN_SRC python :var data=data.org:remote-table
>
> Brilliant!  As usual, if I want to do something in org, it can be done.
>
> Did you find this in the manual?  I did look but must have missed it.
>
> thank you,
> eric
>
> --
> : Eric S Fraga via Emacs 28.0.50, Org release_9.4.5-381-g17ef1b.dirty
>


Re: could a :var header argument refer to a data table in another file?

2021-04-29 Thread John Kitchin
This syntax works for me.

#+BEGIN_SRC python :var data=data.org:remote-table
print(data)
#+END_SRC



John

---
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



On Thu, Apr 29, 2021 at 8:36 AM Eric S Fraga  wrote:

> Hello all,
>
> TL;DR: I have the need to reference a table that is in another file to
> pass as data to a src block in the current file.  Is this possible?
> Hints welcome!
>
> Longer version: I am running a series of numerical experiments, each of
> which generates output files (using org syntax!).  I want to process the
> data in those files for inclusion in a paper.  Now, I could write a
> shell script which extracts all these data and collates them etc. but it
> would be ideal if I could simply refer to a table in another file
> directly.  The tables are all named although a given table in each
> output file will have the same name (I hope that makes sense).
>
> One thing that comes to mind is some elisp in the argument to the :var
> header argument.  Is this possible?  I've not tried...
>
> Thank you,
> eric
>
> --
> : Eric S Fraga via Emacs 28.0.50, Org release_9.4.5-381-g17ef1b.dirty
>
>


Re: wip-cite status question and feedback

2021-04-21 Thread John Kitchin
and for completeness from the org-ref point of view, probably all of
them call something like (org-ref-find-bibliography) inside those
functions to get a list of bib sources from a hierarchy of local
definitions in the buffer to env vars, to a default source variable
defined in elisp. I think something similar is done in the
bibtex-completion commands.


Bruce D'Arcus  writes:

> On Wed, Apr 21, 2021 at 3:57 PM John Kitchin  wrote:
>
>> I guess that the actions I use most often when "opening" a citation are,
>> opening the pdf, going to the webpage for it, and then opening the
>> bibtex entry (usually to fix capitalization or something). In org-ref
>> though, there are a whole bunch of other potential actions, like
>> searching for related citations, copying the key or formatted citation
>> to the clipboard, etc. I guess my point is there are a lot of things
>> that opening might mean to different people.
>
> Good point, which I missed.
>
> In bibtex-actions, which uses bibtex-completion as a backend, I have
> the following "open" commands:
>
> - open-pdf
> - open-link (doi or url)
> - open (pdf, or link if not present)
> - open-entry (bibtex, to edit)
> - open-notes (to review, edit)
>
> All of those backend functions take KEYS as input.
>
> Bruce


--
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
Pronouns: he/him/his



Re: wip-cite status question and feedback

2021-04-21 Thread John Kitchin


>>>   - "fontification" is meant to give full access to face selection, what
>>> is really displayed, additional keymaps, all using a single
>>> function.
>>
>>> At the moment, I have no idea about what arguments would be useful.
>>> I think John Kitchin gave ideas about this already on this ML.
>>> I have to re-read his posts on the subject. In any case, feedback
>>> welcome.

For fontification in an org-file, what I currently find helpful in org-ref:

1. the citations have a face that makes them stand out (it is usually a
green color, unless the key is not found in the bibfiles, and then it is
red). I have a way to turn that off though, because it can cause
performance issues in large documents with large bibliographies.

2. There is a tooltip that shows a lightly formatted reference. The
tooltip is fairly crude, and not related to any particular bibliography
style. It would be great if it did, but so far the effort to achieve
that has been too high. With an integrated citation processor it might
be better, but I am skeptical they will ever look quite like they would
in a latex export, especially if you use latex code in your bibtex
files. This tooltip only needs to be good enough in my opinion to tell
what the key is representing at that point.

3. I like having keymaps on the citations. The most common use for me is to
press S-up to sort a sequence of citations by year, followed by S-left
and S-right to transpose citations in a sequence, followed by
M-left/right to navigate across citations.

4. I tend to have my follow function launch a hydra menu, which provides
many action choices. I think this is easier than trying to remember a lot of
different commands that also work at the citation at point. I started
this with helm, then ivy and now hydra. I can't tell if a new generation
of approaches like selectrum, or the package bibtex-actions will
eventually replace these. This isn't quite fontification, but since you
can put keymaps on with fontification, it isn't fully indpendent either.

5. I mostly think the citations should be displayed as plain text, i.e.
not replaced by a numbered overlay, or equivalent. I could see hiding
the [], but also guess that would be more confusing than beneficial.

>>
>> I'm thinking about implementing a "fontification" solution which would
>> use citeproc-el with a standard style to produce nice preview-like
>> representations of the citations in the buffer. This would require
>> basically the same pieces of information as citation export I think,
>> although it might be made strictly  local, working only with the
>> single citation object plus the bibliography information.
>
> OK. Citation object and list of bibliography files as arguments are
> a starting point.
>
>>> A citation processor does not need to provide integration in all these
>>> areas. Users may be able to mix and match processors. This is another
>>> (minor) point which is yet to be designed. How is a user supposed to
>>> select a processor for each integration area? It could be done through
>>> three variables, e.g.,
>>>
>>>   (setq org-cite-display-processor 'org-ref)
>>>   (setq org-cite-export-processor 'citeproc)
>>>   (setq org-cite-follow-processor 'default)
>>>
>>> I think it is unlikely for a user to locally select "display" and
>>> "follow" processors. However, we need a way to use a local export
>>> processor for a given document. I may need to introduce
>>> a #+citation_processor keyword during export. Any other idea?
>>
>> All of these solutions seem to be good starting points.  As for
>> setting the "display" and "follow" processors locally, this leads to a
>> question which probably has to be addressed at a certain point: that
>> of bibliography formats. The Emacs world is currently rather BibTeX
>> centered, but biblatex is an important (and rather different)
>> alternative, and there is CSL as well which I expect to become more
>> and more relevant (it's citeproc-el's native format). Moreover, these
>> formats have some variants, e.g., for BibTeX there is also org-bibtex,
>> for CSL there is CSL-JSON and a CSL-YAML etc. If different "display"
>> and "follow" processors will be able to handle different formats then
>> the users might want to change those settings locally as well, based
>> on the bibliography format, but I'm not sure what kind of
>> infrastructure would be the best way of supporting this. (E.g.,
>> registering format support information about the processors and
>> choosing on this basis?)
>
> I don't have an idea about it e

Re: wip-cite status question and feedback

2021-04-21 Thread John Kitchin
I guess that the actions I use most often when "opening" a citation are,
opening the pdf, going to the webpage for it, and then opening the
bibtex entry (usually to fix capitalization or something). In org-ref
though, there are a whole bunch of other potential actions, like
searching for related citations, copying the key or formatted citation
to the clipboard, etc. I guess my point is there are a lot of things
that opening might mean to different people.

in org-ref, with any of those, the first step is finding where the key
sits in your bib-files, and then getting that entry. It is in a way a
primitive citation processor before the one that is used at export.


Ihor Radchenko  writes:

> Nicolas Goaziou  writes:
>
>> In my mind, "opening" leads to the bibliography reference, not to the
>> original document. IIUC, in this situation, the location does not matter
>> much, does it?
>>
>> In any case, Org has no clue about the "location" of the citation. It
>> can provide the suffix associated to the citation key, but it is up to
>> the citation processor to extract page information out of it. If this is
>> desirable, we need to provide the full citation object instead of the
>> key. I don't know if it is worth the trouble.
>
> From my experience using org-ref for citations, going to the
> bibliography reference is rarely useful. Most of time, I want to jump to
> the document I am citing (or even page in the document).
>
> I think that full citation object should be worth passing to the
> citation backend.
>
> Best,
> Ihor


--
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
Pronouns: he/him/his



Re: Using backticks for the inline code delimeter?

2021-04-21 Thread John Kitchin
> The challenge can be in identifying the most appropriate key bindings.
> This can depend on the platform you use as well. When I was only using
> Linux, I used the 'super' key for this and it was great. However, when I
> also started using a mac, I had to define a new scheme. It can take a
> bit of work to setup initially, but I think it is worth the effort. I
> now have the same bindings in multiple modes, so regardless of whether
> I'm writing markdown, org, html, rich text, etc, I just hit the same key
> bindings to mark content as code, bold, italic, etc.

On a Mac, you might find these useful. I don't use the right command and
option keys, so I redefine them as hyper and super. they are right under
my thumb, and convenient.

(setq mac-right-command-modifier 'hyper)
(setq mac-right-option-modifier 'super)

--
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
Pronouns: he/him/his



Re: Using backticks for the inline code delimeter?

2021-04-20 Thread John Kitchin
I have used an approach like the one here
https://endlessparentheses.com/define-context-aware-keys-in-emacs.html

to make context aware key-bindings.

Matt Price  writes:

> On Wed., Mar. 31, 2021, 3:22 p.m. Timothy,  wrote:
>
>>
>> autofrettage  writes:
>>
>> > Quick and Dirty: Bind key '`' to ~ in Emacs?
>> >
>> > (I guess it is clear I haven't thought about the consequences.)
>>
>> You can add that just to the Org-mode map. That wouldn't be too bad,
>> there's always C-q.
>>
>
> Is it possible to bind a key in org-mode but bind it back to another
> character if you're in a special environment, eg a code block? That would
> probably be my preference. So "`" inserts "~" when you're writing text but
> "`" in an elisp or markdown SRC block, for instance.
>
> I guess just write a function that checks context? Presumably all the
> overloaded keybindings do this already but I guess I don't really know how
> they do so.
>
> I do in general wish it were easier to switch between writing markdown and
> writing org, since I often have to write markdown for work.
>
>>
>> --
>> Timothy
>>
>>


--
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
Pronouns: he/him/his



Re: Font lock in org+elisp confused with ?\[

2021-04-02 Thread John Kitchin
This is related to the issues with <> in src blocks. [ and ] have open and
close syntactical meanings like < and > do in org files. A similar solution
as found in
https://emacs.stackexchange.com/questions/50216/org-mode-code-block-parentheses-mismatch
seems to work to fix it.

John

---
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



On Fri, Apr 2, 2021 at 12:24 AM Tim Cross  wrote:

> I'm forwarding this to the emacs-orgmode list as this is something org
> maintainers probably need to see.
>
> On Thu, 1 Apr 2021 at 15:43, Arthur Miller  wrote:
>
>>
>> Is it me or is it a bug?
>>
>> When in org mode in an elisp block, this seems to confuse syntax
>> checker:
>>
>> #+begin_src emacs-lisp
>> (progn
>>   (if (= (following-char) ?\])
>>   (forward-char -1))
>>   )
>> #+end_src
>>
>> Identation seems to think it is one level extra, and it also shows as
>> error. Same of course when testing for ?\[.
>>
>> It does evaluate correctly. Ordinary elisp buffer does not have problem
>> with this, only when in code blocks in org-mode or elisp mode.I can send
>> in some screenshot with errors if needed.
>>
>>
>>
>
> --
> regards,
>
> Tim
>
> --
> Tim Cross
>
>


Re: References?? (feature idea)

2021-03-14 Thread John Kitchin
You could define a new org link with this behavior. You just need to work
out a syntax for a link to the heading that also includes the property
name. e.g. [[property:file.org::*Heading::property]]

then, define a :follow function that probably opens the heading when you
open it, and an :export function that looks up the property and uses that
value on export.

You would split your path on ::, then you should have a list like (file
heading property-name). For the follow function, just find-file on the
filename, then search for the heading. For the export, wrap that in
save-window-excursion, and use (org-entry-get) on the heading to get the
property value.

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 Sun, Mar 14, 2021 at 7:41 PM David Masterson <
dsmasterson92...@outlook.com> wrote:

> I don't see this capability in Org, but maybe I'm missing it.
>
> My use case is that I setup an Org file as my phonebook.  Each child
> header (ie. no subheaders) is a person in my phonebook.  I can
> categorize them using parent headers.  All information about a person is
> stored in PROPERTY drawers (but, you could have information outside the
> drawer).
>
> What I'd like to do is include a "reference" to a PROPERTY in the
> phonebook entry in other Org files so that phone and address is stored
> in the phonebook, but I want the "reference" to become the value of the
> PROPERTY when the other Org file is exported.  I could do a link to the
> phonebook Org file, but that is a link and not the data.  I'd prefer to
> have (say) an exported PDF be standalone and not have references to the
> other file that I would also have to export.  One reason is that I might
> have "confidential" information in the phonebook.
>
> Does this make sense?  Has it been done?
> --
> David Masterson
>
>


Re: [EXT] Problem with org-ref

2021-03-10 Thread John Kitchin
thanks for the troubleshooting. I pushed a fix that should use the
customizable pdf filename function instead.

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 Wed, Mar 10, 2021 at 10:36 AM Marvin M. Doyley 
wrote:

> HI Kyle,
>
> This solved my problems
>
>  Thanks,
>
> M
>
>
>
>
> On Mar 9, 2021, at 11:49 PM, Kyle Meyer  wrote:
>
> Marvin M. Doyley writes:
>
> Hi there,
>
> When I use crossref-add-bibtex-entry it download the BibTeX entry but
> cannot download the associated pdf.
> I get the following error  (wrong-type-argument stringp
> ("/Users/doyley/Dropbox/Filing_Cabinet/B/refs/pdf/“))
>
> I configured org-ref as follows
>
> (setq org-ref-bibliography-notes
> '("/Users/doyley/Dropbox/Filing_Cabinet/B/refs/ref_notes.org")
>  org-ref-default-bibliography
> '("/Users/doyley/Dropbox/Filing_Cabinet/B/refs/ref.bib")
>  org-ref-pdf-directory
> '("/Users/doyley/Dropbox/Filing_Cabinet/B/refs/pdf/")
>   org-ref-notes-citation-link '("cite")
>  )
>
>
> [ Caveat: I've never used org-ref ]
>
> org-ref's 0383cc2 (support multiple pdf directories, 2016-06-10) updated
> org-ref-pdf-directory to accept a list value, so your value is valid,
> but...
>
> Debugger entered--Lisp error: (wrong-type-argument stringp
> ("/Users/doyley/Dropbox/Filing_Cabinet/B/refs/pdf/"))
>
>  file-name-as-directory(("/Users/doyley/Dropbox/Filing_Cabinet/B/refs/pdf/"))
>  doi-utils-get-bibtex-entry-pdf(nil)
>
>
> ... doi-utils-get-bibtex-entry-pdf wasn't updated for that (+cc the
> author of that commit and John Kitchin).
>
> It looks like org-ref-pdf-directory still supports a string, though, and
> you only have one item, so you should be able to work around the issue
> with
>
>  (setq org-ref-pdf-directory
> "/Users/doyley/Dropbox/Filing_Cabinet/B/refs/pdf/")
>
>
>


Re: contact management in emacs

2021-03-08 Thread John Kitchin
This question is going to go a little off the original topic. I wonder
how far you can push your model of replacing the org-file with a
database. It looks like it would be easy to extend to something like a
shared bibliography.

How far could you push it for something like a shared set of documents,
e.g. a shared notebook on a project? How feasible would it be to access
tables or src blocks in these if they were in a database? or to build an
agenda from entries in the database?



Jean Louis  writes:

> * Russell Adams  [2021-02-28 12:07]:
>> The only reason I don't use BBDB is I want to use Org to allow me to
>> maintain notes about contacts (ie: CRM). Yes, I get that I could have
>> a CRM file and link in BBDB contacts, but that feels like adding
>> layers.
>
> I have replaced using Org file as the central system with the `people`
> database as the central system. This may sound confusing. Instead of
> using exclusively Org file, I am using the database and addint notes
> to people in the database. A note can have any major or minor mode,
> thus it could be text or Org file or markdown file, enriched mode or
> restructured text, asciidoc, or similar.
>
> My workflow is to find the person first, then press N to see notes, or
> M-n to create a new note. Concepts I am explaining may serve some
> people to create their own workflows.
>
> Using database for that allows easily collaboration in real time with
> other team members and inclusion or insertion of new contacts during
> marketing activities without interruption. Org files are not suitable
> for such collaborative updates.
>
>> The stumbling point for me has been exporting to my mobile phone. I'm
>> fine with a one way sync from my BBDB/Org solution to the phone, but
>> I feel like I never found a good option.
>
> bbdb-vcard package is here:
> https://melpa.org/packages/bbdb-vcard-20201016.1902.tar
>
> Jean


--
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: state of the art in org-mode tables e.g. join, etc

2021-02-25 Thread John Kitchin
That is remarkably slim code to get those results!

Cook, Malcolm  writes:

> John,
>
> Checkout what R sqldf package makes easy:
>
> ** aggregation example
>
> Examples from https://github.com/tbanel/orgaggregate
>
>
> #+NAME: original
> | Day   | Color | Level | Quantity |
> |---+---+---+--|
> | Monday| Red   |30 |   11 |
> | Monday| Blue  |25 |3 |
> | Tuesday   | Red   |51 |   12 |
> | Tuesday   | Red   |45 |   15 |
> | Tuesday   | Blue  |33 |   18 |
> | Wednesday | Red   |27 |   23 |
> | Wednesday | Blue  |12 |   16 |
> | Wednesday | Blue  |15 |   15 |
> | Thursday  | Red   |39 |   24 |
> | Thursday  | Red   |41 |   29 |
> | Thursday  | Red   |49 |   30 |
> | Friday| Blue  | 7 |5 |
> | Friday| Blue  | 6 |8 |
> | Friday| Blue  |11 |9 |
>
> #+PROPERTY: header-args:R  :session *R*
>
> #+begin_src R :results none
> library(sqldf)
> #+end_src
>
>
> #+begin_src R :var original=original :colnames yes
> sqldf('select Color, count(*) from original group by Color;')
> #+end_src
>
> #+RESULTS:
> | Color | count(*) |
> |---+--|
> | Blue  |7 |
> | Red   |7 |
>
>
>
> ** join example
>
> Example from https://github.com/tbanel/orgtbljoin
>
> #+name: nutrition
> | type | Fiber | Sugar | Protein | Carb |
> |--+---+---+-+--|
> | eggplant |   2.5 |   3.2 | 0.8 |  8.6 |
> | tomatoe  |   0.6 |   2.1 | 0.8 |  3.4 |
> | onion|   1.3 |   4.4 | 1.3 |  9.0 |
> | egg  | 0 |  18.3 |31.9 | 18.3 |
> | rice |   0.2 | 0 | 1.5 | 16.0 |
> | bread|   0.7 |   0.7 | 3.3 | 16.0 |
> | orange   |   3.1 |  11.9 | 1.3 | 17.6 |
> | banana   |   2.1 |   9.9 | 0.9 | 18.5 |
> | tofu |   0.7 |   0.5 | 6.6 |  1.4 |
> | nut  |   2.6 |   1.3 | 4.9 |  7.2 |
> | corn |   4.7 |   1.8 | 2.8 | 21.3 |
>
>
> #+name: recipe
> | type | quty |
> |--+--|
> | onion|   70 |
> | tomatoe  |  120 |
> | eggplant |  300 |
> | tofu |  100 |
>
>
> #+begin_src R :var recipe=recipe :var nutrition=nutrition :colnames yes
> sqldf('select * from recipe, nutrition where recipe.type=nutrition.type')
> #+end_src
>
> #+RESULTS:
> | type | quty | type | Fiber | Sugar | Protein | Carb |
> |--+--+--+---+---+-+--|
> | onion|   70 | onion|   1.3 |   4.4 | 1.3 |9 |
> | tomatoe  |  120 | tomatoe  |   0.6 |   2.1 | 0.8 |  3.4 |
> | eggplant |  300 | eggplant |   2.5 |   3.2 | 0.8 |  8.6 |
> | tofu |  100 | tofu |   0.7 |   0.5 | 6.6 |  1.4 |
>
>
>
> This should also be possible but I cannot get it to work now:
>
> #+begin_src R :var recipe=recipe :var nutrition=nutrition :colnames yes 
> :prologue sqldf(' :epilogue ')
> select * from recipe, nutrition where recipe.type=nutrition.type
> #+end_src
>
>
>
>
>
> From: Emacs-orgmode  On Behalf 
> Of John Kitchin
> Sent: Sunday, February 21, 2021 10:24
> To: Tim Cross 
> Cc: org-mode-email 
> Subject: Re: state of the art in org-mode tables e.g. join, etc
>
> ATTENTION: This email came from an external source. Do not open attachments 
> or click on links from unknown senders or unexpected emails.
>
> For fun, here is the sqlite equivalent of the Pandas example using the same 
> tables as before
>
>
> ** aggregation example
>
> Examples from https://github.com/tbanel/orgaggregate
>
>
> #+NAME: original
> | Day   | Color | Level | Quantity |
> |---+---+---+--|
> | Monday| Red   |30 |   11 |
> | Monday| Blue  |25 |3 |
> | Tuesday   | Red   |51 |   12 |
> | Tuesday   | Red   |45 |   15 |
> | Tuesday   | Blue  |33 |   18 |
> | Wednesday | Red   |27 |   23 |
> | Wednesday | Blue  |12 |   16 |
> | Wednesday | Blue  |15 |   15 |
> | Thursday  | Red   |39 |   24 |
> | Thursday  | Red   |41 |   29 |
> | Thursday  | Red   |49 |   30 |
> | Friday| Blue  | 7 |5 |
> | Friday| Blue  | 6 |8 |
> | Friday| Blue  |11 |9 |
>
>
> #+begin_src sqlite :db ":memory:" :var orgtable=original :colnames yes
> drop table if exists testtable;
> create table testtable(Day str, Color str, Level int, Quantity int);
> .mode csv testtable
> .import $orgtable testtable
> select Color, count(*) from testtable group by Color;
> #+end_src
>
> #+RESULT

Re: state of the art in org-mode tables e.g. join, etc

2021-02-24 Thread John Kitchin
Thanks for the link! It looks like some useful functions there. It would
be nice to integrate some of those with the rich output of a Jupyter
kernel so you could get native org tables automatically in org-mode.

Derek Feichtinger  writes:

> Hi John,
>
> I invested time some years ago in preparing babel examples, and a lot of
> the description went into using tables. The most detailed documents I
> had for elisp and python.
>
> In order to be productive, e.g. for producing all kinds of scientific
> graphs, but also for doing the finances and planning for our scientific
> computing section I ended up the same as you with mostly going to python
> and leveraging Pandas. I think all of us end up using ":colnames no" as
> the most convenient solution.
>
> https://github.com/dfeich/org-babel-examples/blob/master/python3/python3-babel.org
>
> (especially look at the Pandas section 10)
>
> In that file I also tangle a python library "orgbabelhelper" that is
> available in Conda and PyPi. I mainly use that to work with my tables.
>
> Best regards
> Derek


--
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: Citations with page numbers using helm-bibtex and org-ref

2021-02-21 Thread John Kitchin
It seems like some ideas are getting mixed up in your description. A cite
link in org-ref is related to a bibtex entry in a bibtex file, not to an
org heading in an org-file. In other words in your example, I would expecta
bibtex entry with the key bradley1973es to exist in one of the default
bibliography files you use (or in the one you define in a bibliography
link). The notes are just for your purposes.

the headings/links in your notes file will not show up in any completion
backend in org-ref for citation selection, as only the bibtex entries are
used to construct those.

 If you are looking for a way to select one of those headings from your
notes, and then insert the appropriate link, you would have to use
something different than org-ref. there is not presently a way to map an
annotated cite link to the specific note. I am not even sure you can write
a function that does that, as the functions only take a key for looking up
the note file, and not the description too. It certainly is possible to
write a new function that would work on the link at point to do that, and
to call it interactively, or add it as an action though. You would still
get the key to open the note file, and then use the link description if it
exists to somehow search forward for the relevant heading or text, failing
gracefully if you, for example, make a cite to a page you did not make a
note on.

When it comes time to authoring a paper, I think the workflow is you would
have to open the notes you made, find the section you want to use in your
paper, and copy the link you put in your notes to your new document. There
are some variations you might consider, but none of them would really be
integrated into the org-ref completion mechanisms that are generated from
the bibtex entries.

For example you  might store the link or parts in a property like this:

* The Accelerator-Multiplier Model
  :PROPERTIES:
  :key:  bradley1973es
  :page: p200
  :cite: [[cite:bradley1973es][p200]]
  :END:


and then write a small function you use interactively to copy it, e.g.

#+BEGIN_SRC emacs-lisp
(defun get-link ()
  (interactive)
  (kill-new (org-entry-get (point) "cite")))
#+END_SRC

and you might bind that to a key if you use it a lot. Alternatively you
might put the key in file-level property, and only store the page, and use
property inheritance, to build the link. There are a lot of options to
choose from. But, simply copying and pasting a link might also be the
simplest.

It might be possible to use the org-store/insert-link machinery for this
too, but I have found that to be trickier than I thought it should be in
the past.

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 Sun, Feb 21, 2021 at 12:13 PM Adam Sneller  wrote:

> Hi Bruce/John,
>
> Thanks for getting back to me. So I guess your notes file would look
> something like this?
>
>
> #+TITLE: Bradley, J. (1973): Essential Mathematics For Economists
>
> * Dynamic models: the consumption function
> [[cite:bradley1973es][p164]]
>
> * Changes in Capital Stock
> [[cite:bradley1973es][p188]]
>
> * The Accelerator-Multiplier Model
> [[cite:bradley1973es][p200]]
>
>
> So when when it comes time to author your paper, if you run org-store-link
> on any of these, the description gets stripped off the link, so that only
> cite:bradley1973es is stored (which obviously defeats the purpose). And if
> you copy the link over by hand, it maps back to the document
> bradley197es.org (not the actual note).
>
> Am I missing anything?
>
> Adam
>
> On 21 Feb 2021, at 12:21, Bruce D'Arcus  wrote:
>
> On Sat, Feb 20, 2021 at 10:31 PM Adam Sneller 
> wrote:
>
> I currently use org-ref and helm-bibtex to manage my database of academic
> sources, with one notes file per source. A lot of my sources are books. So
> note typically grow over time, as I add multiple headers (each pertaining
> to a chapter or topic/note taken from that source).
>
> But now I want to produce a citation that references the page numbers
> where I captured that note...
>
> What is the recommended way to handle this? Are you breaking notes into
> individual files, each with their own @inbook citation?
>
>
> Generally speaking, referencing page numbers and sections of a cited
> source is not handled by dedicated citations, but rather by
> annotations on the containing citation (book etc.).
>
> So in the pandoc syntax, for example, [@book, p23].
>
> I do the same with notes, and just included the specific citation with
> the note if I need to maintain the specific source page.
>
> Bruce
>
>
>


Re: state of the art in org-mode tables e.g. join, etc

2021-02-21 Thread John Kitchin
For fun, here is the sqlite equivalent of the Pandas example using the same
tables as before


** aggregation example

Examples from https://github.com/tbanel/orgaggregate


#+NAME: original
| Day   | Color | Level | Quantity |
|---+---+---+--|
| Monday| Red   |30 |   11 |
| Monday| Blue  |25 |3 |
| Tuesday   | Red   |51 |   12 |
| Tuesday   | Red   |45 |   15 |
| Tuesday   | Blue  |33 |   18 |
| Wednesday | Red   |27 |   23 |
| Wednesday | Blue  |12 |   16 |
| Wednesday | Blue  |15 |   15 |
| Thursday  | Red   |39 |   24 |
| Thursday  | Red   |41 |   29 |
| Thursday  | Red   |49 |   30 |
| Friday| Blue  | 7 |5 |
| Friday| Blue  | 6 |8 |
| Friday| Blue  |11 |9 |


#+begin_src sqlite :db ":memory:" :var orgtable=original :colnames yes
drop table if exists testtable;
create table testtable(Day str, Color str, Level int, Quantity int);
.mode csv testtable
.import $orgtable testtable
select Color, count(*) from testtable group by Color;
#+end_src

#+RESULTS:
| Color | count(*) |
|---+--|
| Blue  |7 |
| Red   |7 |

** join example

Example from https://github.com/tbanel/orgtbljoin

#+name: nutrition
| type | Fiber | Sugar | Protein | Carb |
|--+---+---+-+--|
| eggplant |   2.5 |   3.2 | 0.8 |  8.6 |
| tomatoe  |   0.6 |   2.1 | 0.8 |  3.4 |
| onion|   1.3 |   4.4 | 1.3 |  9.0 |
| egg  | 0 |  18.3 |31.9 | 18.3 |
| rice |   0.2 | 0 | 1.5 | 16.0 |
| bread|   0.7 |   0.7 | 3.3 | 16.0 |
| orange   |   3.1 |  11.9 | 1.3 | 17.6 |
| banana   |   2.1 |   9.9 | 0.9 | 18.5 |
| tofu |   0.7 |   0.5 | 6.6 |  1.4 |
| nut  |   2.6 |   1.3 | 4.9 |  7.2 |
| corn |   4.7 |   1.8 | 2.8 | 21.3 |


#+name: recipe
| type | quty |
|--+--|
| onion|   70 |
| tomatoe  |  120 |
| eggplant |  300 |
| tofu |  100 |


#+begin_src sqlite :db ":memory:" :var nut=nutrition rec=recipe :colnames
yes
drop table if exists nutrition;
drop table if exists recipe;
create table nutrition(type str, Fiber float, Sugar float, Protein float,
Carb float);
create table recipe(type str, quty int);

.mode csv nutrition
.import $nut nutrition

.mode csv recipe
.import $rec recipe

select * from recipe, nutrition where recipe.type=nutrition.type;
#+end_src

#+RESULTS:
| type | quty | type | Fiber | Sugar | Protein | Carb |
|--+--+--+---+---+-+--|
| onion|   70 | onion|   1.3 |   4.4 | 1.3 |  9.0 |
| tomatoe  |  120 | tomatoe  |   0.6 |   2.1 | 0.8 |  3.4 |
| eggplant |  300 | eggplant |   2.5 |   3.2 | 0.8 |  8.6 |
| tofu |  100 | tofu |   0.7 |   0.5 | 6.6 |  1.4 |


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 Sun, Feb 21, 2021 at 10:03 AM John Kitchin 
wrote:

> Thanks Tim and Greg. I had mostly come to the same conclusions that it is
> probably best to outsource this. I worked out some examples from
> the orgtbljoin and orgaggregate packages with Pandas below, in case anyone
> is interested in seeing how it works. A key point is using the ":colnames
> no" header args to get the column names for Pandas. It seems like a pretty
> good approach.
>
> * org-mode tables with Pandas
> ** Aggregating from a table
>
> Examples from https://github.com/tbanel/orgaggregate
>
>
> #+NAME: original
> | Day   | Color | Level | Quantity |
> |---+---+---+--|
> | Monday| Red   |30 |   11 |
> | Monday| Blue  |25 |3 |
> | Tuesday   | Red   |51 |   12 |
> | Tuesday   | Red   |45 |   15 |
> | Tuesday   | Blue  |33 |   18 |
> | Wednesday | Red   |27 |   23 |
> | Wednesday | Blue  |12 |   16 |
> | Wednesday | Blue  |15 |   15 |
> | Thursday  | Red   |39 |   24 |
> | Thursday  | Red   |41 |   29 |
> | Thursday  | Red   |49 |   30 |
> | Friday| Blue  | 7 |5 |
> | Friday| Blue  | 6 |8 |
> | Friday| Blue  |11 |9 |
>
>
> #+BEGIN_SRC ipython :var data=original :colnames no
> import pandas as pd
>
> pd.DataFrame(data[1:], columns=data[0]).groupby('Color').size()
> #+END_SRC
>
> #+RESULTS:
> :results:
> # Out [1]:
> # text/plain
> : Color
> : Blue7
> : Red 7
> : dtype: int64
> :end:
>
> The categorical stuff here is just to get the days sorted the same way as
> the example. It is otherwise not needed. I feel there should be a more

Re: state of the art in org-mode tables e.g. join, etc

2021-02-21 Thread John Kitchin
Thanks Tim and Greg. I had mostly come to the same conclusions that it is
probably best to outsource this. I worked out some examples from
the orgtbljoin and orgaggregate packages with Pandas below, in case anyone
is interested in seeing how it works. A key point is using the ":colnames
no" header args to get the column names for Pandas. It seems like a pretty
good approach.

* org-mode tables with Pandas
** Aggregating from a table

Examples from https://github.com/tbanel/orgaggregate


#+NAME: original
| Day   | Color | Level | Quantity |
|---+---+---+--|
| Monday| Red   |30 |   11 |
| Monday| Blue  |25 |3 |
| Tuesday   | Red   |51 |   12 |
| Tuesday   | Red   |45 |   15 |
| Tuesday   | Blue  |33 |   18 |
| Wednesday | Red   |27 |   23 |
| Wednesday | Blue  |12 |   16 |
| Wednesday | Blue  |15 |   15 |
| Thursday  | Red   |39 |   24 |
| Thursday  | Red   |41 |   29 |
| Thursday  | Red   |49 |   30 |
| Friday| Blue  | 7 |5 |
| Friday| Blue  | 6 |8 |
| Friday| Blue  |11 |9 |


#+BEGIN_SRC ipython :var data=original :colnames no
import pandas as pd

pd.DataFrame(data[1:], columns=data[0]).groupby('Color').size()
#+END_SRC

#+RESULTS:
:results:
# Out [1]:
# text/plain
: Color
: Blue7
: Red 7
: dtype: int64
:end:

The categorical stuff here is just to get the days sorted the same way as
the example. It is otherwise not needed. I feel there should be a more
clever way to do this, but didn't think of it.

#+BEGIN_SRC ipython :var data=original :colnames no
df = pd.DataFrame(data[1:], columns=data[0])
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday',
'Sunday']
df['Day'] = pd.Categorical(df['Day'], categories=days, ordered=True)

(df
 .groupby('Day')
 .agg({'Level': 'mean',
   'Quantity': 'sum'})
 .sort_values('Day'))
#+END_SRC

#+RESULTS:
:results:
# Out [2]:
# text/plain
:Level  Quantity
: Day
: Monday  27.514
: Tuesday 43.045
: Wednesday   18.054
: Thursday43.083
: Friday   8.022
: Saturday NaN 0
: Sunday   NaN 0

[[file:/var/folders/3q/ht_2mtk52hl7ydxrcr87z2grgn/T/ob-ipython-htmlMnDA9a.html]]
:end:

** Joining tables

Example from https://github.com/tbanel/orgtbljoin

#+name: nutrition
| type | Fiber | Sugar | Protein | Carb |
|--+---+---+-+--|
| eggplant |   2.5 |   3.2 | 0.8 |  8.6 |
| tomatoe  |   0.6 |   2.1 | 0.8 |  3.4 |
| onion|   1.3 |   4.4 | 1.3 |  9.0 |
| egg  | 0 |  18.3 |31.9 | 18.3 |
| rice |   0.2 | 0 | 1.5 | 16.0 |
| bread|   0.7 |   0.7 | 3.3 | 16.0 |
| orange   |   3.1 |  11.9 | 1.3 | 17.6 |
| banana   |   2.1 |   9.9 | 0.9 | 18.5 |
| tofu |   0.7 |   0.5 | 6.6 |  1.4 |
| nut  |   2.6 |   1.3 | 4.9 |  7.2 |
| corn |   4.7 |   1.8 | 2.8 | 21.3 |


#+name: recipe
| type | quty |
|--+--|
| onion|   70 |
| tomatoe  |  120 |
| eggplant |  300 |
| tofu |  100 |


#+BEGIN_SRC ipython :var nut=nutrition recipe=recipe :colnames no
nutrition = pd.DataFrame(nut[1:], columns=nut[0])
rec = pd.DataFrame(recipe[1:], columns=recipe[0])

pd.merge(rec, nutrition, on='type')
#+END_SRC

#+RESULTS:
:results:
# Out [4]:
# text/plain
:type  quty  Fiber  Sugar  Protein  Carb
: 0 onion701.34.4  1.3   9.0
: 1   tomatoe   1200.62.1  0.8   3.4
: 2  eggplant   3002.53.2  0.8   8.6
: 3  tofu   1000.70.5  6.6   1.4
:end:


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 Sun, Feb 21, 2021 at 1:54 AM Tim Cross  wrote:

>
> Greg Minshall  writes:
>
> > John,
> >
> >> Is there a state of the art in using org-tables as little databases
> >> with joins and stuff?
> >
> > i have to admit i do all that with an R code source block.  (the dplyr
> > package has the relevant joins, e.g. dplyr::inner_join().)  and, in R,
> > ":colnames yes" as a header argument gives you header lines on results.
> > (maybe that's ?now? for "all" languages?)
> >
>
> For really complex joins and ad hoc queries, I would do similar or put
> the data into sqlite. For more simple ones, I just define a table which
> uses table formulas to extract the values from the other tables - the
> downside being the tables need to have the same data ordering or the
> formulas need to be somewhat complex. Provided the tables have the same
> number of records in the same order, table formulas are usually fairly
> easy.
>
> I did think about writin

Re: Citations with page numbers using helm-bibtex and org-ref

2021-02-21 Thread John Kitchin
In org-ref you also handle this by annotations of the cite links, e.g.
[[cite:book-key][p23]] and then bibtex or biblatex does the formatting.

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 Sun, Feb 21, 2021 at 7:22 AM Bruce D'Arcus  wrote:

> On Sat, Feb 20, 2021 at 10:31 PM Adam Sneller 
> wrote:
>
> > I currently use org-ref and helm-bibtex to manage my database of
> academic sources, with one notes file per source. A lot of my sources are
> books. So note typically grow over time, as I add multiple headers (each
> pertaining to a chapter or topic/note taken from that source).
> >
> > But now I want to produce a citation that references the page numbers
> where I captured that note...
> >
> > What is the recommended way to handle this? Are you breaking notes into
> individual files, each with their own @inbook citation?
>
> Generally speaking, referencing page numbers and sections of a cited
> source is not handled by dedicated citations, but rather by
> annotations on the containing citation (book etc.).
>
> So in the pandoc syntax, for example, [@book, p23].
>
> I do the same with notes, and just included the specific citation with
> the note if I need to maintain the specific source page.
>
> Bruce
>
>


state of the art in org-mode tables e.g. join, etc

2021-02-20 Thread John Kitchin
Is there a state of the art in using org-tables as little databases with
joins and stuff?

This package https://github.com/tbanel/orgtbljoin

seems close, but not quite what I had in mind. I don't want to modify
tables in place, or create dynamic tables. I do want to combine tables in
memory though for subsequent calculations.

I was thinking more like given the tables from that page:

#+name: quantities
| type-1   | quty |
|--+--|
| onion|   70 |
| tomatoe  |  120 |
| eggplant |  300 |
| tofu |  100 |

#+name: nutrition
| type-2   | Fiber | Sugar | Protein | Carb |
|--+---+---+-+--|
| eggplant |   2.5 |   3.2 | 0.8 |  8.6 |
| tomatoe  |   0.6 |   2.1 | 0.8 |  3.4 |
| onion|   1.3 |   4.4 | 1.3 |  9.0 |
| egg  | 0 |  18.3 |31.9 | 18.3 |
| rice |   0.2 | 0 | 1.5 | 16.0 |
| bread|   0.7 |   0.7 | 3.3 | 16.0 |
| orange   |   3.1 |  11.9 | 1.3 | 17.6 |
| banana   |   2.1 |   9.9 | 0.9 | 18.5 |
| tofu |   0.7 |   0.5 | 6.6 |  1.4 |
| nut  |   2.6 |   1.3 | 4.9 |  7.2 |
| corn |   4.7 |   1.8 | 2.8 | 21.3 |

you would be able to do something like this:

#+BEGIN_SRC emacs-lisp
(join "quantities" "type-1" "nutrition" "type-2")
#+END_SRC

#+RESULTS:
| type-1   | quty | Fiber | Sugar | Protein | Carb |
|--+--+---+---+-+--|
| onion|   70 |   1.3 |   4.4 | 1.3 |  9.0 |
| tomatoe  |  120 |   0.6 |   2.1 | 0.8 |  3.4 |
| eggplant |  300 |   2.5 |   3.2 | 0.8 |  8.6 |
| tofu |  100 |   0.7 |   0.5 | 6.6 |  1.4 |

or, to sum the Fiber column:

#+BEGIN_SRC emacs-lisp :var data=(join "quantities" "type-1" "nutrition"
"type-2")
(cl-loop for row in data sum (nth 2 row)))
#+END_SRC

#+RESULTS:
: 5.1005

I have spent a lot of time with Pandas in Python lately,  and trying to
think through what some analogues with org-tables would be. I would be very
happy not to reinvent the wheel here!


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: How to associate a code block to another one so that it is executed beforehand?

2021-02-15 Thread John Kitchin
Here is one way to do it.  You use a :var to "run" the other block.

#+NAME: create-file
#+begin_src bash :results silent
cat << EOF > main.txt
foo
bar
EOF
#+end_src

#+BEGIN_SRC python :var run=create-file
with open('main.txt') as f:
print(f.read())
#+END_SRC

#+RESULTS:
: foo
: bar
:

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 Mon, Feb 15, 2021 at 4:01 PM Rodrigo Morales <
moralesrodrigo1...@gmail.com> wrote:

>
> Is it possible to associate a code block (A) to another code block (B)
> so that when (A) is executed (B) is executed beforehand? I'm asking this
> because I have a bash code block (B) that creates a file that is then
> processed by a python code block (A) so before executing (A) block, the
> file needs to be created by (B).
>
> I managed to accomplish this only with shell code blocks by creating a
> function that gets a code block as an string but now that code blocks
> have different languages (bash and python) I can't use this same
> approach. Recall that ":prologue" inserts an string at the beginning of
> the code block (see minimal working example of this idea below.)
>
> #+NAME: create-file
> #+begin_src bash :results silent
> cat << EOF > main.txt
> foo
> bar
> EOF
> #+end_src
>
> #+HEADER: :prologue (org-babel-get-block-as-string "create-file")
> #+begin_src bash
> cat main.txt
> #+end_src
>
> #+RESULTS:
> #+begin_example
> foo
> bar
> #+end_example
>
> --
> Rodrigo Morales.
> IRC: rdrg109 (freenode)
>
>


Re: programatically generate an agenda

2021-02-14 Thread John Kitchin
If it is possible to set up what you want in an entry in
org-agenda-custom-commands, then you can call it in a program like


#+BEGIN_SRC emacs-lisp
(org-agenda nil "w" nil)
#+END_SRC

In that snippet, I have the key in an org-agenda-custom-commands set to
"w".

that generates an agenda buffer for me, which I assume you can then use
the org-agenda-write command on.


Alan Schmitt  writes:

> Hello,
>
> In my quest/endeavor/struggle to generate an org file for what I want to
> do during the day, I’m trying to leverage the power of org-agenda (that
> does a lot of what I want to do) to create an org file. I learned of
> org-agenda-write, which I could use to write to file what I want then
> include it in my org file, but for that I need to create the correct
> org-agenda buffer. What is the elisp way of doing it?
>
> I tried using org-agenda-list, but it only seems to restore the current
> agenda view. For instance, (org-agenda-list nil nil 1) generates an
> agenda for the week (which is my default), even though I pass a SPAN
> argument of 1. I also don’t know how to set the org-agenda-skip steps
> before calling that function…
>
> Thanks a lot for any suggestion on how to do this.
>
> Best,
>
> Alan


--
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: Auto-activate new <<>>

2021-02-08 Thread John Kitchin
I guess the place to do it is with an advice on org-activate-links. Maybe a
simple after advice would do.

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 Sun, Feb 7, 2021 at 8:48 PM Kyle Meyer  wrote:

> Adam Sneller writes:
>
> > I want to call org-update-radio-target-regexp as soon as org-mode
> > recognises a new <<>> has been created (which seems to
> > happen as soon as the third ">" is typed).
> >
> > What hook can I use to get this done?
>
> I'm not spotting any hook that could be used for this.  The <<>>
> fontification happens through a simple 'regular expression => face'
> mapping in org-font-lock-keywords.
>
> You're probably aware of this and it's just not as automatic as you'd
> like, but just in case: pressing `C-c C-c' with point on <<>
> will call org-update-radio-target-regexp.
>
>


Re: Get =#+RESULTS= without re-evaluating source code block?

2021-02-01 Thread John Kitchin
I discovered that it matters a lot which block you cache. You have to
cache the long running block. I had put cache on the block with noweb
expansion, and then the long running block still runs every time. That
was a surprise to me, since nothing was changing in that block, so I
thought it would just use the cached result.


Greg Minshall  writes:

> John,
>
>> I tried this but it did not work for me.
>
> to be clear, caching means that the *first* time you execute, your
> reference will have to wait for the long-running computation to
> complete, but not during subsequent executions (unless the source block
> that performs the execution changes, in which case the reference will
> again have to wait).
>
> also, caching means that, after the first execution (ditto caveat) the
> source block *will no longer run*.  so, if there were any (other) side
> effects of running that source block, they will not happen.  (you could
> possibly split the side effect-producing code out of that block.)
>
> i'm not sure if this explains what did not work for you.
>
> cheers, Greg
>
>>
>>
>> On Wed, Jan 27, 2021 at 5:38 PM  wrote:
>>
>> > On Wed, Jan 27, 2021 at 05:14:43PM -0500, doltes wrote:
>> > > Get =#+RESULTS= without re-evaluating source code block?
>> > >
>> > > Let's suppose I have a code block which requires a long time to finish
>> > >
>> > > #+NAME: big-computation
>> > > #+begin_src bash
>> > > sleep 5 # Some computation which requires a long time to complete.
>> > > echo a
>> > > #+end_src
>> > >
>> > > #+RESULTS: big-computation
>> > > #+begin_example
>> > > a
>> > > #+end_example
>> > >
>> > > I want to use the results of that code block in other code blocks so I
>> > > use a =noweb= reference (see below.)
>> > >
>> > > #+begin_src bash :noweb yes
>> > > printf "%s\n" <>
>> > > #+end_src
>> > >
>> > > #+RESULTS:
>> > > #+begin_example
>> > > a
>> > >
>> > > #+end_example
>> > >
>> > > However, doing this (i.e. using a =noweb= reference) would make the
>> > > command to be evaluated whenever getting its results. I don't want
>> > > this, I want the =:noweb= reference to actually use the already
>> > > computed results.
>> > >
>> > > So, my question is: Is it possible to use the actual =#+RESULTS= code
>> > > block instead of always evaluating it when referencing the results
>> > > through a =:noweb= reference?
>> >
>> > Perhaps "Cache results of evaluation" (15.5 Evaluating Code Blocks,
>> > in the Interwebs here [1] is for you.
>> >
>> > In short, add a header argument :cache yes to your code block.
>> >
>> > Cheers
>> >
>> > [1] https://orgmode.org/org.html#Evaluating-Code-Blocks
>> >
>> >  - t
>> >
>> --
>> 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


--
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: Get =#+RESULTS= without re-evaluating source code block?

2021-01-27 Thread John Kitchin
I tried this but it did not work for me.


On Wed, Jan 27, 2021 at 5:38 PM  wrote:

> On Wed, Jan 27, 2021 at 05:14:43PM -0500, doltes wrote:
> > Get =#+RESULTS= without re-evaluating source code block?
> >
> > Let's suppose I have a code block which requires a long time to finish
> >
> > #+NAME: big-computation
> > #+begin_src bash
> > sleep 5 # Some computation which requires a long time to complete.
> > echo a
> > #+end_src
> >
> > #+RESULTS: big-computation
> > #+begin_example
> > a
> > #+end_example
> >
> > I want to use the results of that code block in other code blocks so I
> > use a =noweb= reference (see below.)
> >
> > #+begin_src bash :noweb yes
> > printf "%s\n" <>
> > #+end_src
> >
> > #+RESULTS:
> > #+begin_example
> > a
> >
> > #+end_example
> >
> > However, doing this (i.e. using a =noweb= reference) would make the
> > command to be evaluated whenever getting its results. I don't want
> > this, I want the =:noweb= reference to actually use the already
> > computed results.
> >
> > So, my question is: Is it possible to use the actual =#+RESULTS= code
> > block instead of always evaluating it when referencing the results
> > through a =:noweb= reference?
>
> Perhaps "Cache results of evaluation" (15.5 Evaluating Code Blocks,
> in the Interwebs here [1] is for you.
>
> In short, add a header argument :cache yes to your code block.
>
> Cheers
>
> [1] https://orgmode.org/org.html#Evaluating-Code-Blocks
>
>  - t
>
-- 
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: self-referencing babel shell code blocks

2021-01-17 Thread John Kitchin
see
https://stackoverflow.com/questions/3139970/open-a-file-at-line-with-filenameline-syntax

there are also ways to make fancier org-links, but I think you will find
what you need in that link.

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 Sun, Jan 17, 2021 at 7:33 PM HJ  wrote:

>
> Dear Mr Kitchin,
>
>you are a genius !!
>
> A BIG THANK YOU!!!
>
>Wow. I couldn't imagine someone might be able to do this so quickly
> and perfectly. Wow.
>
> thank you so much
>
>  HJ
>
> PS: Now I'm off to figure out how to invoke emacs to tell it to open up
> the window and show this file at the place where this-block block
> appears ...
>
>
> On 1/18/21 1:12 AM, John Kitchin wrote:
> > I guess this is what you mean:
> >
> >
> > * heading L1_12
> > ** heading L2_37
> >
> > #+name: this-block
> > #+header: :var VAR1=(getenv "HOSTNAME")
> > #+header: :var VAR2=(message user-login-name)
> > #+header: :var VAR3=(buffer-file-name)
> > #+header: :var VAR4=(org-element-property :name (org-element-context))
> > #+header: :var VAR5=(org-no-properties (org-display-outline-path nil t))
> > #+header: :var VAR5a=(line-number-at-pos (org-element-property :begin
> > (org-element-context)))
> > #+header: :var VAR6=(s-trim (shell-command-to-string "git rev-parse
> > HEAD"))
> > #+header: :var VAR7=(s-trim (shell-command-to-string "git branch
> > --show-current"))
> > #+BEGIN_SRC sh :results raw
> > echo Run by $VAR2 from $VAR3
> > echo In a src-block named $VAR4 in $VAR5 at line $VAR5a
> > echo on commit $VAR6 in git branch $VAR7
> > #+END_SRC
> >
> > #+RESULTS: this-block
> > Run by jkitchin from
> > /Users/jkitchin/Dropbox/emacs/journal/2021/01/17/2021-01-17.org
> > <http://2021-01-17.org>
> > In a src-block named this-block in heading L1_12/heading L2_37 at line
> 140
> > on commit a07475addc3fdf557fb46a72b1100cf1c9c0805a in git branch master
> >
> >
> >
> > 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 <http://kitchingroup.cheme.cmu.edu>
> >
> >
> >
> > On Sun, Jan 17, 2021 at 4:42 PM HJ  > <mailto:hj-orgmod...@hj.proberto.com>> wrote:
> >
> >
> >   hi,
> >
> >I'm  trying to figure out how to write a block , header,
> > PROPERTY or
> > whatever is necessary so the output of a command in babel source
> > block
> > identifies it own position - the line (or block or something) in
> > buffer
> > (or at least the file) in which it is written. ( Plus the checked out
> > git revision / branch. )
> >
> >
> >   I've been experimenting with the following, so far without much
> > luck ...
> >
> >   Which of these pieces of information (see the "echo" line below)
> > is it
> > possible to get? Which is easy? (variables VAR[0345] are most
> > critical)
> > How would one write a snippet which provides (some of) this
> > information?
> >
> >   Is it much harder with command 1 being SSH to a remote machine?
> > Would
> > ":dir user@remotemachine:/some/dir" work better? Or at all?
> >
> >   Perhaps I would know how to find out VAR6 and VAR7 by running first
> > some `git cmd1` and `git cmd2` locally in a " command 0 " - but is
> > there
> > a way to get that info from magit somehow?
> >
> >   But what I am most desperate for is how to cause orgmode block
> > to set
> > VAR0, VAR3, VAR4 and VAR5, and - also fairly important - how to
> > use the
> > combination of VAR[0345] do open / recall the file onto the screen
> >
> >   Thanks a million for helping me out here ...
> >
> > HJ
> >
> >
> > This is the sample file :
> >
> >
> > * heading L1_12
> >Hello and welcome, this is a file with self-referencing shell
> > babel source code blocks
> >...
> > ** heading L2_37
> >...
> > #+NAME: block220
> > #+BEG

Re: self-referencing babel shell code blocks

2021-01-17 Thread John Kitchin
I guess this is what you mean:


* heading L1_12
** heading L2_37

#+name: this-block
#+header: :var VAR1=(getenv "HOSTNAME")
#+header: :var VAR2=(message user-login-name)
#+header: :var VAR3=(buffer-file-name)
#+header: :var VAR4=(org-element-property :name (org-element-context))
#+header: :var VAR5=(org-no-properties (org-display-outline-path nil t))
#+header: :var VAR5a=(line-number-at-pos (org-element-property :begin
(org-element-context)))
#+header: :var VAR6=(s-trim (shell-command-to-string "git rev-parse HEAD"))
#+header: :var VAR7=(s-trim (shell-command-to-string "git branch
--show-current"))
#+BEGIN_SRC sh :results raw
echo Run by $VAR2 from $VAR3
echo In a src-block named $VAR4 in $VAR5 at line $VAR5a
echo on commit $VAR6 in git branch $VAR7
#+END_SRC

#+RESULTS: this-block
Run by jkitchin from /Users/jkitchin/Dropbox/emacs/journal/2021/01/17/
2021-01-17.org
In a src-block named this-block in heading L1_12/heading L2_37 at line 140
on commit a07475addc3fdf557fb46a72b1100cf1c9c0805a in git branch master



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 Sun, Jan 17, 2021 at 4:42 PM HJ  wrote:

>
>   hi,
>
>I'm  trying to figure out how to write a block , header, PROPERTY or
> whatever is necessary so the output of a command in babel source block
> identifies it own position - the line (or block or something) in buffer
> (or at least the file) in which it is written. ( Plus the checked out
> git revision / branch. )
>
>
>   I've been experimenting with the following, so far without much luck ...
>
>   Which of these pieces of information (see the "echo" line below) is it
> possible to get? Which is easy? (variables VAR[0345] are most critical)
> How would one write a snippet which provides (some of) this information?
>
>   Is it much harder with command 1 being SSH to a remote machine? Would
> ":dir user@remotemachine:/some/dir" work better? Or at all?
>
>   Perhaps I would know how to find out VAR6 and VAR7 by running first
> some `git cmd1` and `git cmd2` locally in a " command 0 " - but is there
> a way to get that info from magit somehow?
>
>   But what I am most desperate for is how to cause orgmode block to set
> VAR0, VAR3, VAR4 and VAR5, and - also fairly important - how to use the
> combination of VAR[0345] do open / recall the file onto the screen
>
>   Thanks a million for helping me out here ...
>
> HJ
>
>
> This is the sample file :
>
>
> * heading L1_12
>Hello and welcome, this is a file with self-referencing shell babel
> source code blocks
>...
> ** heading L2_37
>...
> #+NAME: block220
> #+BEGIN_SRC  bash  :session sess9
>: command 0 ;  cd _how-do-I-find-the-dir-of-currently-edited-file_ ;
> VAR6=`git cmd1` ; VAR7=`git cmd2`
>: command 1 ;  ssh -o "SetEnv VAR1=machine VAR2=user VAR3=..."
> targetUser@targetMachine
> #+END_SRC
>
>
> ...
>
> #+NAME: block225
> #+BEGIN_SRC  bash  :session sess9
>: command 2 ; : do some computation on targetMachine
>: command 3 ; echo This code has been launched from emacs process
> VAR0:_EMACS_SESSION_ID_ \
>  on computer $VAR1:_SRC_HOSTNAME_ \
>  run by user $VAR2:_USER_ \
>  from file $VAR3:_FILENAME_ \
>  code block named $VAR4:block225 \
>  in this file positioned under headings: $VAR5:heading L1_12/heading
> L2_37/ \
>  which is checked out from $VAR6:_GIT_COMMIT_ID_ \
>  on branch $VAR7:_GIT_BRANCH_
>: command 3 continues ; echo To display the buffer which launched this
> code on the screen of the running emacs session, run the following command
> :emacs  _What_the_heck_do_I_put_here?_  '&'
> #+END_SRC
>
>
>
>
>
>
>
>


Re: xclip/pbcopy/clipboard 'target' for export backends?

2021-01-05 Thread John Kitchin
I guess you are looking for something like
https://github.com/jkitchin/ox-clip.

It doesn't support all the backends you want, but might be a start for
you.  you can also install it from MELPA.

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 Tue, Jan 5, 2021 at 9:03 AM Tim Visher  wrote:

> Hi Everyone,
>
> I'm interested in adding something to the export dispatcher that would
> automatically put the exported text (or perhaps even file?) onto my
> clipboard.
>
> Preferably I'd like to define this once and have it available to each
> backend. So maybe I want markdown this time but rather than to a buffer or
> file I want it to go straight to my clipboard. Next time I want HTML or
> Plain Text but the same thing.
>
> Can anyone give me some hints on where to start looking for that? Or maybe
> it's already been done?
>
> Thanks in advance!
>
> --
>
> In Christ,
>
> Timmy V.
>
> https://blog.twonegatives.com
> http://five.sentenc.es
>


Re: what do do when multiple functions store a link

2021-01-02 Thread John Kitchin
Here is a very grungy solution:

(defun scimax-store-link-advice (orig-fun  args)
  (cl-letf (((symbol-function 'symbol-name)
 (lambda (_)
   "")))
(apply orig-fun args)))

(advice-add 'org-store-link :around 'scimax-store-link-advice)

It works by temporarily redefining symbol-name to return an empty string.
It's only redeeming qualities are 1) it works, 2) you don't have to modify
the org src code!

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, Jan 2, 2021 at 9:37 AM Daniele Nicolodi  wrote:

> On 02/01/2021 14:49, John Kitchin wrote:
> > Recently I have had an issue where multiple functions may store a link,
> > e.g. to a bibtex entry.
> >
> > In this case, org-mode seems to prompt me to ask which function to store
> > the link with, with an initial input of the first function, which masks
> > all the options that are available. This happens
> > inside |org-store-link| in ol.el at line 1495 for me. in
> >
> > (apply #'org-link-store-props
> > (cdr (assoc-string
> >   (completing-read
> > "Which function for creating the link? "
> > (mapcar #'car results-alist)
> > nil t (symbol-name name))
> >   results-alist)))
> >
> > because of the (symbol-name name).
> >
> > Is there an easy way to avoid this, or to modify the order of the
> > functions used? I want to see all the options for storing, or better, to
> > just store them all and let me choose later when I use org-insert-link.
>
> I have the exact same problem. I think it comes from having org-bibtex
> and org-ref loaded at the same time. I haven't investigated a possible
> solution.
>
> Cheers,
> Dan
>


what do do when multiple functions store a link

2021-01-02 Thread John Kitchin
Recently I have had an issue where multiple functions may store a link,
e.g. to a bibtex entry.

In this case, org-mode seems to prompt me to ask which function to store
the link with, with an initial input of the first function, which masks all
the options that are available. This happens inside org-store-link in ol.el
at line 1495 for me. in

(apply #'org-link-store-props
(cdr (assoc-string
  (completing-read
"Which function for creating the link? "
(mapcar #'car results-alist)
nil t (symbol-name name))
  results-alist)))

because of the (symbol-name name).

Is there an easy way to avoid this, or to modify the order of the functions
used? I want to see all the options for storing, or better, to just store
them all and let me choose later when I use org-insert-link.

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: [tip] Export subfigures to LaTeX (and HTML)

2020-12-28 Thread John Kitchin
This is an interesting use of links, in particular extending the
information in the description.

You might look at this
http://kitchingroup.cheme.cmu.edu/blog/2015/02/05/Extending-the-org-mode-link-syntax-with-attributes/
for another way to do that.

Check out this alternative approach all together that also uses a
special block.

http://kitchingroup.cheme.cmu.edu/blog/2016/01/17/Side-by-side-figures-in-org-mode-for-different-export-outputs/

I don't use either of these today, and they are old so who knows if they
still work, but they have some fun ideas in them.

Juan Manuel Macías  writes:

> Hi,
>
> I have come up with a way to export subfigures to LaTeX (with the subfigure 
> package) by
> defining a new link type. The 'subcaption' of the subfigure would be the 
> description of
> the link. If we want to add parameters such as width, scale, etc., we can put 
> them next
> between the marks '>( ... )'
>
> The code:
>
> #+begin_src emacs-lisp
>   (org-link-set-parameters
>"subfig"
>:follow (lambda (file) (find-file file))
>:face '(:foreground "chocolate" :weight bold :underline t)
>:display 'full
>:export (lambda (file desc backend)
>(when (eq backend 'latex)
>  (if (string-match ">(\\(.+\\))" desc)
>  (concat "\\subfigure[" (replace-regexp-in-string "\s+>(.+)" 
> "" desc) "]"
>  "{\\includegraphics"
>  "["
>  (match-string 1 desc)
>  "]"
>  "{"
>  file
>  "}}")
>(format "\\subfigure[%s]{\\includegraphics{%s}}" desc file)
> #+end_src
>
> Example:
>
> #+begin_src org
>   ,#+CAPTION: Lorem impsum dolor
>   ,#+ATTR_LaTeX: :options \centering
>   ,#+begin_figure
>   [[subfig:img1.jpg][Caption of img1 >(width=.3\textwidth)]]
>
>   [[subfig:img2.jpg][Caption of img2 >(width=.3\textwidth)]]
>
>   [[subfig:img3.jpg][Caption of img3 >(width=.6\textwidth)]]
>   ,#+end_figure
> #+end_src
>
> Results:
>
> #+begin_src latex
>   \begin{figure}\centering
> \subfigure[Caption of 
> img1]{\includegraphics[width=.3\textwidth]{img1.jpg}}
>
> \subfigure[Caption of 
> img2]{\includegraphics[width=.3\textwidth]{img2.jpg}}
>
> \subfigure[Caption of 
> img3]{\includegraphics[width=.6\textwidth]{img3.jpg}}
> \caption{Lorem impsum dolor}
>   \end{figure}
> #+end_src
>
> If we want to export to HTML it would be something more tricky. In this case, 
> the export
> function could be like this (a width parameter would be enclosed between >{ 
> ... }):
>
> #+begin_src emacs-lisp
>   (lambda (file desc backend)
> (cond
>  ((eq backend 'latex)
>   (if (string-match ">(\\(.+\\))" desc)
> (concat "\\subfigure[" (replace-regexp-in-string "\s*>.+" "" desc) 
> "]" "{\\includegraphics" "[" (match-string 1 desc) "]" "{"  file "}}")
>   (format "\\subfigure[%s]{\\includegraphics{%s}}" 
> (replace-regexp-in-string "\s*>.+" "" desc) file)))
>  ((eq backend 'html)
>   (if (string-match "{\\(.+\\)}" desc)
> (concat " (match-string 1 desc)
> "\""
> "/>"
> (replace-regexp-in-string "\s*.+" "" desc)
> "")
>   (format "%s"
>   file file
>   (replace-regexp-in-string "\s*.+" "" desc))
> #+end_src
>
> Example:
>
> #+begin_src org
>   ,#+CAPTION: Lorem impsum dolor
>   ,#+ATTR_LaTeX: :options \centering
>   ,#+begin_figure
>   @@html: style="margin-left:auto;margin-right:auto;">@@
>
>   [[subfig:img1.jpg][Caption of img1 >(width=.3\textwidth) >{300px}]]
>
>   [[subfig:img2.jpg][Caption of img2 >(width=.3\textwidth) >{300px}]]
>
>   @@html:  style="margin-left:auto;margin-right:auto;">@@
>
>   [[subfig:img3.jpg][Caption of img3 >(width=.6\textwidth) >{600px}]]
>
>   @@html:Lorem ipsum dolor@@
>   ,#+end_figure
> #+end_src
>
> As you can see, it is not the panacea, and you have to apply some direct 
> format...
>
> Happy holidays
>
> Juan Manuel


--
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: difficulty extracting email address from property field containing gmail link

2020-11-30 Thread John Kitchin
I think code like this would also work:

#+BEGIN_SRC emacs-lisp
(let* ((url "
https://mail.google.com/mail?view=cm=1=duncan...@indeedemail.com;)
   (struct (url-generic-parse-url url))
   (filename (url-filename struct)))

  (cadr (assoc "to" (url-parse-query-string filename
#+END_SRC


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 Mon, Nov 30, 2020 at 7:51 AM Ian Garmaise  wrote:

> Thanks Kyle, got it to work this way:
>
> #+BEGIN: propview :cols ((car (s-split " " ITEM))  (s-chop-prefix "gmail:"
> (my/extract-email-from-link EMAIL_ADDRESS)))  :id "candidates" :match
> "testthis" :wrap example
> | (car (s-split " " ITEM)) | (s-chop-prefix "gmail:"
> (my/extract-email-from-link EMAIL_ADDRESS)) |
>
> |--+-|
> | "Ciara"  | "ciarax...@gmail.com"
>|
> | "Duncan" | "duncanx...@indeedemail.com"
>  |
>
> Thanks a million!
>
> Ian
>
>
> On Sun, Nov 29, 2020 at 10:39 PM Kyle Meyer  wrote:
>
>> Ian Garmaise writes:
>>
>> > This is working well, except for the property used for the email
>> address.
>> > Unfortunately, I stored this as a gmail link.  This makes it difficult
>> to
>> > extract the actual email address using org-collector as follows:
>> >
>> > #+BEGIN: propview :cols ((car (s-split " " ITEM))  EMAIL_ADDRESS)  :id
>> > "candidates" :match "testthis" :wrap example
>> >
>> > the result produced looks like this:
>> >
>> > | (car (s-split " " ITEM)) | EMAIL_ADDRESS
>>  |
>> >
>> |--+-|
>> > | "Ciara"  | [[
>> https://mail.google.com/mail/?view=cm=1=ciaraxyz@gmail\.com]]
>>|
>> > | "Duncan" | [[
>> https://mail.google.com/mail/?view=cm=1=duncanxyz@indeedemail\.com]]
>> |
>> >
>> > I have looked at several methods that I found on the web to extract the
>> > email address from the link in the property, but haven't yet found a
>> > solution that I could get to work.  Still building up my elisp skillset,
>> > would appreciate suggestions.
>>
>> I've never used org-collector, but quickly trying to wire up a function
>> to extract the email part of the text you show, I suspect some of the
>> trouble you're having is that the value comes in as a vector because
>> org-propview-collect processes it with org-babel-read.  So perhaps
>> something like this would get you on the right track:
>>
>>   (require 'subr-x)
>>
>>   (defun my/extract-email-from-link (value)
>> (setq value (format "%S" value))
>> (when-let ((link (and (string-match org-link-bracket-re value)
>>   (org-link-unescape
>>(match-string-no-properties 1 value)
>>   (thread-last
>>   link
>> (replace-regexp-in-string
>>  (rx string-start (one-or-more not-newline) "to="
>>  (group (one-or-more not-newline)) string-end)
>>  "\\1")
>> (replace-regexp-in-string (rx "\\.") "."
>>
>>
>> --8<---cut here---start->8---
>> #+BEGIN: propview :cols ((car (s-split " " ITEM))
>> (my/extract-email-from-link EMAIL_ADDRESS)) :id global
>> | (car (s-split " " ITEM)) | (my/extract-email-from-link EMAIL_ADDRESS) |
>> |--+|
>> | "Ciara"  | "ciara...@gmail.com"   |
>> | "Duncan" | "duncan...@indeedemail.com"|
>> |--+|
>> |  ||
>> #+END:
>>
>> * Ciara
>> :PROPERTIES:
>> :EMAIL_ADDRESS: [[
>> https://mail.google.com/mail/?view=cm=1=ciaraxyz@gmail\.com]]
>> :END:
>>
>> * Duncan
>> :PROPERTIES:
>> :EMAIL_ADDRESS: [[
>> https://mail.google.com/mail/?view=cm=1=duncanxyz@indeedemail\.com
>> ]]
>> :END:
>> --8<---cut here---end--->8---
>>
>
>
> --
> =
> Ian Garmaise
> Consultant
> Phorix Solutions Group
> ia...@phorixsol.com
> Toronto cell: 416.432.2251
> NYC: 917.512.9535
>
> https://www.linkedin.com/in/igarmaise/
>
> http://www.PhorixSol.com
>


Re: How to get a block’s contents by name

2020-11-28 Thread John Kitchin
I would do this:

#+BEGIN_SRC emacs-lisp
(defun org-get-named-block-contents (name)
  (save-excursion
(goto-char (point-min))
(let ((regexp (org-babel-named-src-block-regexp-for-name name)))
  (or (and (looking-at regexp)
  (progn (goto-char (match-beginning 1))
 (line-beginning-position)))
 (ignore-errors (org-next-block 1 nil regexp)))
  (org-babel-expand-src-block
#+END_SRC

This is basically what org-babel-find-named-block does, with the
(org-babel-expand-src-block) return instead of the position. It avoids the
double save-excursion.

This is probably faster than any alternative that involves parsing the
buffer, especially for large buffers.
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, Nov 27, 2020 at 10:47 PM George Mauer  wrote:

> Well that pains me on a software-engineer-aip-design level but that works!
> Thanks a lot.
>
> On Fri, Nov 27, 2020 at 8:22 PM Kyle Meyer  wrote:
>
>> George Mauer writes:
>>
>> > I'm trying to figure out how I could fetch the contents of another
>> block by
>> > name from an elisp script
>> >
>> > I've seen `org-sbe` but I just want to get the block contents, (ideally
>> > with noweb and vars filled in - just as it would be tangled if we were
>> to
>> > tangle it)
>> >
>> > How do I do that?
>>
>> How about something like this?
>>
>>   (save-excursion
>> (goto-char (org-babel-find-named-block "b"))
>> (org-babel-expand-src-block))
>>
>


Re: Differentiate source blocks in export?

2020-11-24 Thread John Kitchin
Nice! Here is a little more compact way to do that I think:

@@html:@@
#+BEGIN_SRC python
print(5)
#+END_SRC
@@html:@@


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 Tue, Nov 24, 2020 at 11:08 AM Marvin ‘quintus’ Gülker <
post+orgmod...@guelker.eu> wrote:

> Hi!
>
> Am Dienstag, dem 24. November 2020 schrieb Joost Kremers:
> > I was wondering if there's a way to distinguish between different kind
> of source
> > code blocks when exporting to HTML.
> >
> > Specifically, I would like a way to mark certain code blocks in my Org
> file so
> > that those code blocks get a specific class in the HTML export.
>
> You can use the BEGIN_EXPORT/END_EXPORT pair to include a literal HTML
> DIV tag around your target code block. Try this:
>
> Wrapped code block in a div with a custom class:
>
> #+BEGIN_EXPORT html
> 
> #+END_EXPORT
>
> #+BEGIN_SRC c
> #include 
> int main(int argc, char* argv[])
> {
> printf("This is wrapped in the div\n");
> return 0;
> }
> #+END_SRC
>
> #+BEGIN_EXPORT html
> 
> #+END_EXPORT
>
> Normal codeblock without:
>
> #+BEGIN_SRC c
> #include 
> int main(int argc, char* argv[])
> {
> printf("This is not wrapped in anything unusual\n");
> return 0;
> }
> #+END_SRC
>
> Note how one of the EXPORT blocks wraps the opening tag of the DIV and
> the other one wraps the closing tag.
>
>   -quintus
>
> --
> Dipl.-Jur. M. Gülker | https://mg.guelker.eu |For security:
> Passau, Germany  | kont...@guelker.eu| () Avoid HTML e-mail
> European Union   | PGP: see homepage | /\ http://asciiribbon.org
>
>


Re: Differentiate source blocks in export?

2020-11-24 Thread John Kitchin
I think you would have to use some kind of filter to look either for an
#+attr_html or src-header argument, and modify the html output for that.

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 Tue, Nov 24, 2020 at 7:16 AM Joost Kremers 
wrote:

> Hi all,
>
> I was wondering if there's a way to distinguish between different kind of
> source
> code blocks when exporting to HTML.
>
> Specifically, I would like a way to mark certain code blocks in my Org
> file so
> that those code blocks get a specific class in the HTML export. I can then
> style
> them with some CSS to make them stand out visually. I know I can use
> special
> blocks to get divs with a custom class, but I don't want to lose all the
> benefits of code blocks...
>
> I tried Google and the Org manual but I haven't been able to find anything
> on
> this.
>
> TIA
>
> --
> Joost Kremers
> Life has its moments
>
>


Re: ob-python: import local package into a session

2020-11-23 Thread John Kitchin
I usually do that by either having the py file in the working directory of
the session, in which case you simply import it.

Alternatively something like this in python:

import sys
sys.path.insert(0, '/path/to/dir/with/myfile.py')
import myfile

you could also append to sys.path if that matters.

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 Mon, Nov 23, 2020 at 10:49 AM Joost Kremers 
wrote:

> Hi all,
>
> If I have an Org file with Python source blocks, I can run them in a
> session
> with the `:session` header arg. That way, I can include packages installed
> in
> `site-packages` and have them available in all code blocks. But is there a
> way
> to import my own packages into a session? In particular, packages I haven't
> installed system-wide?
>
> What I'm trying to do is to import a Python file with a bunch of utility
> functions into the ob-python session. I thought this might be possible if
> I'd
> structure my code as a regular Python package, because that works if I
> want to
> import my utility functions into another Python file. But it doesn't seem
> to
> work for the ob-python session.
>
> Is there a way to achieve this? I don't *have* to structure my utility
> functions
> as a Python package, so if there's another way of doing this, I'd be
> interested
> as well.
>
> TIA
>
> Joost
>
>
> --
> Joost Kremers
> Life has its moments
>
>


Re: S-RET

2020-11-16 Thread John Kitchin


Juri Linkov  writes:

>> you can find a lot of functions like the ones in jupyter at
>> https://github.com/jkitchin/scimax/blob/master/scimax-ob.el. I setup my
>> ipython like this:
>> https://github.com/jkitchin/scimax/blob/master/scimax-org-babel-ipython-upstream.el#L89
>>
>> although I will note there are several setups in that file, e.g. this
>> hydra:
>> https://github.com/jkitchin/scimax/blob/master/scimax-org-babel-ipython-upstream.el#L271
>> …
>> I don't use them all, but leave them to remind me sometimes.
>
> Thanks, the number of supported features is impressive!
>
> I see that the file name contains the word 'upstream'.  This implies a set
> of patches to upstream modules.  Are there any plans to submit upstream
> at least some of the most often used commands that correspond to
> basic Jupyter shortcuts?

The upstream refers to org-babel-ipython. These libraries build on and
extend that. I don't have any plans to push them upstream, I think the
future will be with emacs-jupyter instead, but I haven't had time to
transition to it.

>
> For example, it would make sense to bring scimax-execute-and-next-block
> under the org-babel namespace as e.g. 
> org-babel-execute-src-block-and-next-block
> in the upstream ob-core.el.  Then S-RET will be available to other ob backends
> (such as ob-ruby.el that I use often too.)

I alot of these make sense for general babel use I think. My time for
development work has mostly vanished now, and it is not clear when it
will come back. If anyone wants to push these into ob-core.el, I have no
objections.



--
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: S-RET

2020-11-14 Thread John Kitchin
you can find a lot of functions like the ones in jupyter at
https://github.com/jkitchin/scimax/blob/master/scimax-ob.el. I setup my
ipython like this:
https://github.com/jkitchin/scimax/blob/master/scimax-org-babel-ipython-upstream.el#L89

although I will note there are several setups in that file, e.g. this hydra:
https://github.com/jkitchin/scimax/blob/master/scimax-org-babel-ipython-upstream.el#L271

and these:
edit:
https://github.com/jkitchin/scimax/blob/master/scimax-org-babel-ipython-upstream.el#L271
command:
https://github.com/jkitchin/scimax/blob/master/scimax-org-babel-ipython-upstream.el#L526

I don't use them all, but leave them to remind me sometimes.

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 14, 2020 at 3:20 PM Juri Linkov  wrote:

> I've switched to Org Babel as a replacement of Jupyter Notebook since I
> already
> tired copying Julia program texts back and forth between Jupyter pages
> in web browsers and Emacs.  Fortunately, Org Babel can do everything that
> Jupyter Notebook does.  Except that there is a small usability feature
> that I miss in Org Babel.  Typing 'C-RET' in Jupyter evaluates the current
> code block.  In Org Babel 'C-RET' inserts a new heading at the end of
> the current subtree.  To evaluate the code block there is 'C-c C-c'
> (org-ctrl-c-ctrl-c).  Thus the equivalent of 'C-RET' is 'C-c C-c'.
> So far, so good.
>
> What I miss in Org Babel is an equivalent of 'S-RET' that in Jupyter
> creates a new code block relative to the current code block.
>
> Actually, in Org Babel such a command already exists and is bound to
> the needed key 'S-RET', but currently it works only on tables:
> the command is 'org-table-copy-down' and it copies the current field
> down to the next row and moves point along with it.  This is exactly
> what is needed also in context of code blocks.
>
> Maybe like there is already the command named 'org-ctrl-c-ctrl-c',
> a new general command bound to e.g. 'org-s-ret' could do this
> depending on context.
>
> PS: another similarity is how typing RET in shell buffers
> inserts a new prompt where the user can type a new command.
> 'S-RET' in code blocks could work the same way: type 'S-RET'
> and write code in the next code block, and type 'S-RET' again.
>
>


Re: Org mode fontification error in # in python and ipython source blocks

2020-11-03 Thread John Kitchin
Does anyone see anything wrong with that snippet? All it should do is
improve font-lock on Python f-strings, and it used to work fine, but now it
doesn't. It isn't real critical for me, so I don't mind commenting it out,
but I neither understand why it stopped working!

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 Tue, Nov 3, 2020 at 4:55 AM Sebastian Gimeno 
wrote:

> Dear Stardiviner,
>
> I used the "scimax" configuration. Scimax's maintainer, John Kitchin,
> helped me out to find the root cause of the problem, i.e. the following
> addition to " python-font-lock-keywords":
>
> (setq python-font-lock-keywords
>   (append python-font-lock-keywords
>  '(;; this is the full string.
> ;; group 1 is the quote type and a closing quote is matched
> ;; group 2 is the string part
> (
> ;; "f\\(['\"]\\{1,3\\}\\)\\([^\\1]+?\\)\\1"
> "f\\(['\"]\\{1,3\\}\\)\\(.+?\\)\\1"
> ;; these are the {keywords}
> ("{[^}]*?}"
>  ;; Pre-match form
>  (progn (goto-char (match-beginning 0)) (match-end 0))
>  ;; Post-match form
>  (goto-char (match-end 0))
>  ;; face for this match
>  (0 font-lock-variable-name-face t))
>
> Commenting out this code snippet, the fontfying / HTML-export problem goes
> away.
>
> Cheers,
> sebastian
>
>
>
>
> On Tue, Nov 3, 2020 at 6:50 AM stardiviner  wrote:
>
>> I have same problem sometimes in different babel languages.
>> I would like to know what caused this problem too.
>> Can you send me a message after you solved problem? Thanks in advance. :)
>> smile
>>
>> [stardiviner] GPG key ID: 47C32433
>> IRC(freeenode): stardiviner Twitter:  @numbchild
>> Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
>> Blog: http://stardiviner.github.io/
>>
>>
>> On Mon, Nov 2, 2020 at 2:26 AM Sebastian Gimeno 
>> wrote:
>>
>>> Hi,
>>>
>>> I am using emacs 27.1 and org-plus-contrib 20201026.
>>>
>>> I am having problems with the fontification of python and ipython
>>> source blocks when the code contains curly brackets "{}" (other course
>>> blocks are ok). For instance, the following snippet
>>>
>>> #+BEGIN_SRC python :results drawer
>>> import matplotlib.pyplot as plt
>>> plt.plot([1,2,3])
>>> plt.show()
>>> a=1
>>> print("a={}".format{a})
>>> #+END_SRC
>>>
>>> does not fontify correctly in either python or ipython source blocks.
>>>
>>> As a consequence, when exporting the org file to HTML (C-c C-e h h), it
>>> fails with the following message:
>>>
>>> font-lock-fontify-keywords-region: Invalid function: #
>>>
>>> If changing the code snippet to:
>>>
>>> #+BEGIN_SRC python :results drawer
>>> import matplotlib.pyplot as plt
>>> plt.plot([1,2,3])
>>> plt.show()
>>> a=1
>>> print("a=%s" % a)
>>> #+END_SRC
>>>
>>> the block fontifies and the file is exported to HTML correctly.
>>>
>>> Can you reproduce this behaviour?
>>>
>>> Many thanks in advance!
>>>
>>


Re: Two tables with same data but different sorting

2020-10-02 Thread John Kitchin
I don't know of something built in, but dash provides a few things sort
of like that:

#+BEGIN_SRC emacs-lisp :results raw
(-last-item '(a b c))
#+END_SRC

#+RESULTS:
c



#+BEGIN_SRC emacs-lisp :results raw
(-slice '(a b c) -1)
#+END_SRC

#+RESULTS:
(c)

#+BEGIN_SRC emacs-lisp :results raw
(-take-last 1 '(a b c))
#+END_SRC

#+RESULTS:
(c)

surprisingly, it does not seem to support negative indices, but I guess
it would not be hard to make a wrapper that does that.

Axel Kielhorn  writes:

>> Am 01.10.2020 um 17:47 schrieb John Kitchin :
>>
>> Glad it was helpful. You might also try (seventh row1) or (nth 6 row1). I 
>> think it is the same thing, but more obvious to read!
>
> I agree that „first second …“ would be easier for an english speaker.
> Having the ordinal number 1 based but the nth number 0 based is irritating 
> (and sadly there is no „last“ or „penultimate“).
>
> Actually I was looking for something like last element or the element before 
> the last element.
>
> (nth -1 row1) for the last row would be fine, but I guess that is the Python 
> whispering in my ear.
>
> Combined with the right :exports I now get what I want.
>
> Thanks again for this additional information.
>
> Greetings Axel


--
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: Two tables with same data but different sorting

2020-10-01 Thread John Kitchin
Glad it was helpful. You might also try (seventh row1) or (nth 6 row1). I
think it is the same thing, but more obvious to read!

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 Thu, Oct 1, 2020 at 10:37 AM Axel Kielhorn 
wrote:

>
>
> > Am 01.10.2020 um 14:21 schrieb John Kitchin :
> >
> > You could do something like this:
> >
> >
> > * Table 1
> >
> > #+name: table1
> > | Manufacturer| Name| Price |
> > |-+-+---|
> > | ACME| super cheep | 25 $  |
> > | Roadrunner Inc. | Kaboom  | 27 $  |
> > | ACME| cheep   | 30 $  |
> >
> > #+RESULTS: resorted
> > | Manufacturer| Name| Price |
> > |-+-+---|
> > | ACME| super cheep | 25 $  |
> > | ACME| cheep   | 30 $  |
> > | Roadrunner Inc. | Kaboom  | 27 $  |
> >
> > ** Code for resorting
> >
> > #+name: resorted
> > #+BEGIN_SRC emacs-lisp :var data=table1 :colnames t
> > (sort data (lambda (row1 row2) (string< (first row1) (first row2
> > #+END_SRC
> >
> > John
> >
>
> Thanks John, this is really powerful.
>
> I changed =first row1= to =elt row1 6= since my real table is more complex.
>
> (Again I learned a little bit more about elisp.)
>
> Greetings
> Axel
>
>
>


Re: Two tables with same data but different sorting

2020-10-01 Thread John Kitchin
You could do something like this:


* Table 1

#+name: table1
| Manufacturer| Name| Price |
|-+-+---|
| ACME| super cheep | 25 $  |
| Roadrunner Inc. | Kaboom  | 27 $  |
| ACME| cheep   | 30 $  |

#+RESULTS: resorted
| Manufacturer| Name| Price |
|-+-+---|
| ACME| super cheep | 25 $  |
| ACME| cheep   | 30 $  |
| Roadrunner Inc. | Kaboom  | 27 $  |

** Code for resorting

#+name: resorted
#+BEGIN_SRC emacs-lisp :var data=table1 :colnames t
(sort data (lambda (row1 row2) (string< (first row1) (first row2
#+END_SRC

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 Thu, Oct 1, 2020 at 4:57 AM Axel Kielhorn 
wrote:

> Hello!
>
> I have a table that I want to show with two different sorting orders but I
> don’t want to maintain the data twice.
>
>
> * Table 1
>
> | Manufacturer| Name| Price |
> |-+-+---|
> | ACME| super cheep | 25 $  |
> | Roadrunner Inc. | Kaboom  | 27 $  |
> | ACME| cheep   | 30 $  |
>
> *  Table 2
>
> | Manufacturer| Name| Price |
> |-+-+---|
> | ACME| cheep   | 30 $  |
> | ACME| super cheep | 25 $  |
> | Roadrunner Inc. | Kaboom  | 27 $  |
>
> Is there a way to do this in org?
> Right now I copy the table and apply an =C-c ^ a= on the first column.
>
> Greetings
> Axel
>


Re: Slow to open certain file

2020-09-22 Thread John Kitchin
on emacs 27.1 on a Mac, this seems to take under a second to open for me.

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 Tue, Sep 22, 2020 at 8:36 AM Peter Bienstman 
wrote:

> Opening this file takes more than 10 seconds:
>
>
> https://www.dropbox.com/s/tg7pr6tetlh7jwb/toc%2020200922%2007.00.01.org?dl=0
>
> I also attach the profile.
>
> I have org files which are much bigger, and they open almost instantly.
>
> This is on Windows 10, emacs 26.3, all packages updated to the latest
> version.
>
> Is there anything I can do to speed this up?
>
> Thanks!
>


Re: How to refer to remote table, in another file, as a source block variable?

2020-09-14 Thread John Kitchin
I think you are looking for (Assuming your table is in an org file called
test.org):

#+BEGIN_SRC ipython :var data=test.org:test_table
for row in data:
print(row)
#+END_SRC

#+RESULTS:
:results:
# Out [2]:
# output
['two', 'yes']
['three', 'yes']
['four', 'no']

:end:
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 Mon, Sep 14, 2020 at 5:58 PM William Denton  wrote:

> My apologies for sending this around a second time, but I still haven't
> got it
> so I thought I'd try again.  If it's possible to refer to a remote table
> in
> another file, I've love to know how.
>
>
> Bill
>
>
> On 7 August 2020, William Denton wrote:
>
> > I can't figure this one out.  Let's say I have a table in an Org file,
> like
> > so:
> >
> > # -
> >
> > * Primes
> >
> > #+NAME: test_table
> > | number | prime |
> > |+---|
> > | two| yes   |
> > | three  | yes   |
> > | four   | no|
> >
> > # -
> >
> > In another file, I want to bring this table into a source block as a
> > variable. If it was the same file, I'd say ":var t=test_table" and
> that's
> > that.  But what's the syntax for a different file?  I can't figure it
> out
> > from the docs [1] and none of my attempts with quotes, file:, etc. work.
> > It's something like this, isn't it?  But what?
> >
> > #+begin_src R :var t=(remote(table.org::*Primes))
> > t
> > #+end_src
> >
> > Thanks,
> >
> > Bill
> >
> > [1] https://orgmode.org/manual/References.html#References
> > --
> > William Denton :: Toronto, Canada   ---   Listening to Art:
> > https://listeningtoart.org/
> > https://www.miskatonic.org/ ---   GHG.EARTH: https://ghg.earth/
> > Caveat lector.  ---   STAPLR: https://staplr.org/
> >
>
> --
> William Denton :: Toronto, Canada   ---   Listening to Art:
> https://listeningtoart.org/
> https://www.miskatonic.org/ ---   GHG.EARTH: https://ghg.earth/
> Caveat lector.  ---   STAPLR: https://staplr.org/
>
>


Re: Strange problem loading org features in Emacs 27.1

2020-08-16 Thread John Kitchin
I think they are all org link related files, hence the change to the
ol-prefix.

On Sun, Aug 16, 2020 at 7:27 AM Carlo Tambuatco 
wrote:

>
>
>
>
> > On Aug 16, 2020, at 2:00 AM, Axel Kielhorn 
> wrote:
>
> >
>
> > Hello Carlo,
>
> >
>
> >> Am 16.08.2020 um 05:31 schrieb Carlo Tambuatco :
>
> >>
>
> >> I have org-20200803 package installed in my elpa folder.
>
> >>
>
> >> Here’s the message emacs gives me after loading my org-init.el file
> initializing org mode in
>
> >> emacs 27.1:
>
> >>
>
> >> Problems while trying to load feature ‘org-bbdb’
>
> >> ...
>
> >> Problems while trying to load feature ‘org-rmail’
>
> >>
>
> >> The offending line of code in the org-init.el file is:
>
> >>
>
> >> ;;;Customize org modules
>
> >> (setq org-modules '(org-bbdb
>
> >> org-gnus
>
> >> org-habit
>
> >> org-irc
>
> >> org-mouse
>
> >> org-crypt
>
> >> org-protocol
>
> >> org-w3m
>
> >> org-bibtex
>
> >> org-docview
>
> >> org-info
>
> >> org-mhe
>
> >> org-rmail))
>
> >>
>
> >> (eval-after-load 'org
>
> >> '(org-load-modules-maybe t))
>
> >>
>
> >> I don’t know enough about how org mode is organized to know what is
> going on here, but I just
>
> >> noticed this happening after upgrading to emacs-27.
>
> >>
>
> >> What do I do about this problem? Emacs isn’t giving me enough
> information to give me an idea
>
> >> of what is going on here.
>
> >
>
> > These files have been renamed in March 2019.
>
> >
>
> > With Emacs 26 the file from a previous org version supplied with Emacs
> have been used.
>
> > Emacs 27.1 has a more recent version of org-mode.
>
> >
>
> > The easiest way to fix this is to rename the files in your org-init.el
> file.
>
> >
>
> > Of course you can use the customize interface as well.
>
> >
>
> > Greetings
>
> > Axel
>
> >
>
> >
>
> >
>
>
>
>
>
> Thanks.
>
>
>
> What was the reason for the name change?
>
>
>
>
>
>
>
> --
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: Document containing different text colours?

2020-08-06 Thread John Kitchin
ns.org.uk
> TGmeds = http://www.tgmeds.org.uk
> DrugFacts = https://www.drugfacts.org.uk
> Debian 10.2, fluxbox 1.3.7, emacs 27.1, org 9.3.7
> -BEGIN PGP SIGNATURE-
>
> iQJOBAEBCgA5FiEELSc/6QwVBIYugJDbNoGAGQr4g1sFAl8r7N0bHGJvdWRpY2Nh
> c0Bza2ltYmxlLnBsdXMuY29tAAoJEDaBgBkK+INbjvoP+PDQef4JGrdKVAP+DOHy
> C47ndjTK21CJUxVtkdoZneSQmqh4jXoX4j0grJ1cGk8nsGxXW9wMhtDTfHoR8+IR
> MbDOglB/i9jzDGMP9R4Z3cmOblfytHOraVeyp7gZLUPbqCfFtjNrT1AG0alZHid8
> 53iXEIF8t6b/c3ZXfMf6xNBbpnFNfPS6UsO3GIMgiW1q5dBrJA5aNxWfAzzvWGQG
> a/+beOf+q+DP/bJc0u4h9yLlsDQ08akDZdrj9Y+nzTnbmfNbm0RvfmI04zUankc+
> 3CO0GK+nnaCKtM9Oy1UNi3Vc+1vd8XyeDWiuE5aRE42Nz3tmwA5soAHQjToovmaB
> hqQg1tu2DdsCNs8DvlI4cYVRjnw629RCbgJBm9y73wTS2h+9rH+c+L9vePt8TgEx
> IToqu8nGTvsHD6cG5JyUOpfCySv+NMvl3owXCEDZ5SdInR6TOw2qf4n39XUDT/dd
> niwAjJmeM3S7VQQCtc90mQEIoIkbahk7g5DAcpkta2/g8KoP+3ESc+GT9L6UNHLh
> uXdNEJ8oSXkI4nC4nCdAp6fKuYiWeEBZXCtuodBehg97PEwEJ45YERz5nD2iuAra
> vBfoyvNUIYjXCcKvSx9UZlPfWVYPWA/vSsZ+ys2+s5T+xXCymGumjoUvmfgQdIR1
> 9hHGxHm1fofbVjbdtigkgXc=
> =GIRg
> -END PGP SIGNATURE-


--
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: problem with org-ref

2020-07-20 Thread John Kitchin
This means the biblio package is not installed for some reason.

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 Mon, Jul 20, 2020 at 9:10 AM Johannes Brauer 
wrote:

> Hi!
> After having upgraded my packages I can activate org-ref anymore.
> (require 'org-ref) results in the error message:
> File error: Cannot open load file, No such file or directory, biblio
>
> Any hints what is going wrong?
>
> I am using
> org-ref-20200710.1516
> Aquamacs 3.5  GNU Emacs 25.3.50.1 (x86_64-apple-darwin16.7.0
> macOs 10.15.6
>
> Johannes
>
>
>


Re: Anyone doing any fancy customizations of source blocks?

2020-06-02 Thread John Kitchin
Here is one approach:

https://pank.eu/blog/pretty-babel-src-blocks.html

I feel like I have seen some work that used ruby and python icons as
displays over #+begin_src, but I can't find it now.

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 Tue, Jun 2, 2020 at 2:54 PM William Denton  wrote:

> Is anyone doing any fancy formatting of source blocks, such as putting a
> line
> in the left fringe, or a box around them, or having some interesting
> background?
>
> I ask because I recently changed the theme I use to get the dark Solarized
> look
> I like,[1] and all of a sudden my #+begin_src lines were underlined and
> #+end_src had a line above it.  These come from org-block-begin-line and
> org-block-end-line, and are shown here, but I'd never noticed them in
> documentation or had them on my screen before:
>
>
> https://orgmode.org/worg/org-contrib/babel/examples/fontify-src-code-blocks.html
>
> Aside from fontifying the source blocks I've never done anything special
> about
> them (except wonder how I ever did anything without them), but seeing this
> made
> me wonder if anyone here has really customized them so they look like
> medieval
> manuscripts or something from a futuristic video game.  (If any of that is
> possible---but in Emacs, anything is possible ...)
>
> Bill
>
> [1] Now I'm using https://github.com/bbatsov/solarized-emacs, with
> variable
> pitch turned off and Org headline resizing turned off.
>
> --
> William Denton :: Toronto, Canada   ---   Listening to Art:
> https://listeningtoart.org/
> https://www.miskatonic.org/ ---   GHG.EARTH: https://ghg.earth/
> Caveat lector.  ---   STAPLR: https://staplr.org/
>
>


Re: Splitting large org file into smaller ones

2020-05-31 Thread John Kitchin
This seems like an important thing to get right, so I would hesitate to
do this very automatically.

I would write a function that does what you want, maybe like this:

#+BEGIN_SRC emacs-lisp
(defun subtree-to-file ()
  (interactive)
  (org-narrow-to-subtree)
  (goto-char (point-min))
  (let* ((heading (fifth (org-heading-components)))
 (fname (concat (mapconcat 'downcase (split-string heading) "-") 
".org")))
(when
(y-or-n-p (format "Write subtree to %s" fname))
  (org-cut-subtree)
  (with-temp-file fname
(org-yank
  (widen)
  (when (not (org-at-heading-p))
(org-next-visible-heading 1)))
#+END_SRC

This will generate filenames based on the heading name, and move the
content to that file if you agree with the filename. It does not check
if the fname exists, which may be a good idea. It does not do anything
fancy like promote the heading, it just moves it.

It is a good idea to do this on a copy of the original file, so that you
have an un-altered version in case it does not go as planned.


Marvin M. Doyley  writes:

> Hi there,
>
> Is there an efficient way to split a large org file into smaller ones?
>
> Lets say I have a master file with the following
>
>
> * Notes
> **  Candidate A
>  - Strong technical background
>  - High H-factor
>  - good funding
> - More established investigator
> - Huge startup need $$
>
> **  Candidate B
> - lower startup need
> - signal processing
> - young investigator
>
>
> How do I export the subtree to separate org files, say
>
> - Candidate-a.org <http://candidate-a.org/>
> - Candidate-b.org <http://candidate-b.org/>
>
>
> Thanks
>
> M


--
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: (Feature Request) have org-edit-special work inside non-environment LaTeX blocks, i.e. \( \) and \[ \]

2020-05-26 Thread John Kitchin


Timothy  writes:

> Nicolas Goaziou  writes:
>
>> Thank you. It looks fine, I will only be nitpicking.
>
> Nitpick away :D
>
>>> +(defun org-edit-latex-fragment ()
>>> +  "Edit LaTeX fragment at point."
>>> +  (interactive)
>>> +  (let* ((context (org-element-context))
>>> +(_ (unless (and (eq (org-element-type context) 'latex-fragment)
>>> +(org-src--on-datum-p context))
>>> + (user-error "Not on a LaTeX fragment")))

Is this a case for the if-let* macro? Or is that too new a feature for
org to use still?

>>
>> This is a fancy way to use a let-binding. I suggest to mimic what is
>> done elsewhere, i.e., first bind `context', then check if we're at
>> a LaTeX fragment, then bind the rest.
>
> I had a look at that, to me this was cleaner than using multiple let
> bindings, like so
>
> (let ((context ...))
>   (unless  ... user error)
>   (let* ((contents ...)
>  (delim-length ...))
>...
>
> vs.
>
> (let* ((context ...)
>(_ (unless ... user error))
>(contents ...)
>(delim-length ...))
>  ...
>
> Personally I find the second one nicer. Thoughts?
>
>>> +;; Grab the LaTeX fragment for propertization
>>
>> Missing full stop at the end of the comment.
>
> Fixed!
>
>>
>>> +(contents (buffer-substring-no-properties
>>> +   (org-element-property :begin context)
>>> +   (- (org-element-property :end context)
>>> +  (org-element-property :post-blank context
>>> +(delim-length (if (string-match "\\$[^$]" (substring contents 0 2))
>>
>> Use
>>
>>(string-match "\\`\\$[^$]" contents)
>>
>> instead.
>>
>> or, arguably better,
>>
>>(string-match (rx (seq string-start "$" (not (any "$"
>>  contents)
>>
>>> +  1 2)))
>>> +;; make the LaTeX deliminators read-only
>
> I've changed to (string-match-p "\\`\\$[^$]" contents), as this seems
> like the idiomatic form, let me know if you're happy with this.
>
> I'm not actually sure what's going on with your second suggested form,
> or why that may be better. If you'd mind explaining, that would be
> appriciated :)
>
>> Missing initial capital and final full stop.
>
> Fixed!
>
>> You could factor out (length contents) so it is only called once.
>
> I'm not sure if this a big deal, but I shoved it in the let* for now,
> let me know if that suffices.
>
>>> +(org-src--edit-element
>>> + context
>>> + (org-src--construct-edit-buffer-name (buffer-name) "LaTeX fragment")
>>> + (org-src-get-lang-mode "latex")
>>> + (lambda ()
>>> +   ;; Blank lines break things, replace with a single newline
>>
>> See above.
>
> I'm not quite sure what I should see? I don't notice anything to factor
> out here.
>
>>
>>> +   (while (re-search-forward "\n[ \t]*\n" nil t) (replace-match "\n"))
>>> +   ;; If within a table a newline would disrupt the structure,
>>
>> This comment is truncated.
>
> Added ", so remove newlines"
>
>> Don't leave parenthesis alone.
>
> Fixed!
>
>> Also, make sure your indentation is right, e.g., using M-q on the
>> definition.
>
> I've applied auto-indent to `org-edit-latex-fragment'
>
>> You also need to add a proper commit message and use `git format-patch',
>> and an entry in ORG-NEWS (probably in Miscellaneous part).
>
> I recall being asked to list modified/added functions, what else do I need?
>
>> Bonus points if you can add some tests in
>> "testing/lisp/test-org-src.el".
>
> I'll have a look at that, but I'm not quite sure what to do.
>
>> Could you remind me if you signed the FSF papers already?
>
> They're done and dusted :)
>
> Regards,
>
> Timothy.


--
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: [bug] Should #+attr_latex affect image display within the org buffer itself?

2020-05-26 Thread John Kitchin
I think another way to do it is to have an #+attr_org: :width as the
first attribute.


Vladimir Nikishkin  writes:

> At the moment, I'm working around this by setting the width in "TeX points":
>
> #+attr_latex: :width 224pt
>
> The exported image becomes 224 points wide (roughly 8 cm), and the
> embedded image is 224 pixels wide, which is okay.
>
>
> 2020-05-26 12:01 GMT+08:00, Vladimir Nikishkin :
>> Hello, everyone
>>
>> My problem is the following:
>>
>> Compare the following three pieces of  org code:
>>
>> #+attr_latex: :width 80px
>> [[file:figure-1-1-dot.png]]
>>
>> #+attr_latex: :width 8cm
>> [[file:figure-1-1-dot.png]]
>>
>> #+attr_latex: :width 80mm
>> [[file:figure-1-1-dot.png]]
>>
>> They get exported into LaTeX as expected.
>> But if you org-redisplay-inline-images, you will see that the first
>> one is rendered 80 pixels wide,
>> the second one ise rendered 8 pixels wide, and the third one is
>> rendered 80 (again) pixels wide.
>>
>> So it seems that org is using #+attr_latex as a guide in setting the
>> width of the images in the org-buffer.
>>
>> This seems wrong.
>>
>> --
>> Yours sincerely, Vladimir Nikishkin
>>


--
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: [QUESTION] What's the ":desk" link parameter?

2020-05-23 Thread John Kitchin
Where did you find that code?  I recall this was some kind of prototype
code, and maybe it never got fully developed. I think desk was shorthand
for description.

On Sat, May 23, 2020 at 8:24 AM stardiviner  wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
>
> I found some examples setting org-link-parameters with ":desk", like this:
>
> #+begin_src emacs-lisp
> (defun org-id-link-desk (link desk)
>   "Description function for id: link."
>   (let ((id (cadr (split-string link ":"
> (org-with-point-at (org-id-find id 'marker)
>   (s-join "/" (org-get-outline-path 'with-self)
>
> (org-link-set-parameters "id" :desk #'org-id-link-desk)
> #+end_src
>
> But I have not found any mention in help of variable
> ~org-link-parameters~. Also I
> checked org mode source code by search, no matching of ":desk" found. Did
> I miss
> something?
>
> - --
> [ stardiviner ]
>I try to make every word tell the meaning that I want to express.
>
>Blog: https://stardiviner.github.io/
>IRC(freenode): stardiviner, Matrix: stardiviner
>GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
>
> -BEGIN PGP SIGNATURE-
>
> iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl7JFckUHG51bWJjaGls
> ZEBnbWFpbC5jb20ACgkQG13xyVromsONBggAy0z465LkTx1EYBo4GWZdObWXct8O
> Fjz24HGzin/ffISIhytm0r4w5GE2Rb2/m+BwAsfHEDDvLu1mwU3HvLugXmIk0OUA
> u9qRLHJ4Po1/Y1CRR0o/OHHnbTjhA/7ppljRcN0klwd6J0PDrSE3K/XOhV94xyfK
> k0fUBhtQeTdW/uzx49hs14QlNQ5i6+HJWd1g/viXI+v0EIYJDV3PLwS6CFJWnvo3
> Yi210RM87uKi8vWFcFP7fEW2dYDV5MRsKmQ8v9AKLcCW9+T6Zq3tI7Srxn7ZwFsQ
> mFxZdLFyDlQq0M4VG0WL/epwr0f4B2SUZ3BcOEYrwv7N+7sfMN2cCWI8jQ==
> =8aOD
> -END PGP SIGNATURE-
>
> --
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: emacs + org-mode in virtual machine/docker/...

2020-05-21 Thread John Kitchin
What do you do with this image? I would be happy to continue this off-list
if it seems better.

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 Thu, May 21, 2020 at 11:29 AM Jens Lechtenboerger <
lech...@wi.uni-muenster.de> wrote:

> On 2020-05-21, John Kitchin wrote:
>
> > Has anyone had any success in creating or using any kind of virtual
> machine
> > that can work across platforms to run emacs+org-mode?
>
> I maintain Docker images, emacs-reveal includes org-ref.  It is
> large, though:
> https://gitlab.com/oer/emacs-reveal/container_registry
>
> Best wishes
> Jens
>


Re: emacs + org-mode in virtual machine/docker/...

2020-05-21 Thread John Kitchin
yes it is interactive use I am most interested in. I am exploring this as a
potential option for students to use in a class. So "opening" it should
look like a regular GUI emacs. Any org-files that are created would have to
be persistent, and accessible so students could turn them in somehow. I
don't know if this is something that can be done yet.

Thanks for the links!

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 Thu, May 21, 2020 at 10:21 AM Diego Zamboni  wrote:

> I have not used any personally, but using Docker or Vagrant it
> shouldn't be too hard. Quick searches on Vagrant's and Docker's public
> repositories reveals there are a few emacs-based images already,
> although I could not find any specific mentions to Org:
>
>
> https://app.vagrantup.com/boxes/search?utf8=%E2%9C%93=downloads==emacs
> https://hub.docker.com/search?q=org-mode=image
>
> Do you have interactive use in mind, or for automation?
>
> --Diego
>
> On Thu, May 21, 2020 at 3:27 PM John Kitchin 
> wrote:
> >
> > Has anyone had any success in creating or using any kind of virtual
> machine that can work across platforms to run emacs+org-mode?
> >
> >
> > 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: How to defint functions for other org link parameters like :face :display etc?

2020-05-21 Thread John Kitchin
Here is a real minimal example:

#+BEGIN_SRC emacs-lisp
(defun a-func (start end path bracketp)
  (let ((d (concat "@" path)))
(set-text-properties start end `(display ,d


(org-link-set-parameters "alink"
 :activate-func 'a-func)
#+END_SRC

it has some problems, and you might need to add additional cursor-sensor
type functions to remove the properties for editing, for example. That will
be tricky to get just right.

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 Tue, May 19, 2020 at 6:53 PM stardiviner  wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
>
> John Kitchin  writes:
>
> > I don't know if :display is for that, I think it is mostly related to
> > should a link with description only show the description, or should it be
> > full and show link and description.
> >
> > You probably want the :activate option, where you could use something
> like
> > an overlay on the link. I don't have time to make an example for that
> right
> > now. the gist is you make an activate function, and you can add a
> > text-property or overlay  display on the link. You probably need to check
> > that the property isn't there already to avoid adding overlays on
> > every fontification.
> >
> >
> >
> https://kitchingroup.cheme.cmu.edu/blog/2016/11/04/New-link-features-in-org-9/#org069cbfa
> > John
>
> I see, let me take a try on ~:active-func~ parameter. Thanks a lot, John.
>
> Regards
>
> >
> > ---
> > 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 Tue, May 19, 2020 at 9:21 AM stardiviner  wrote:
> >
> >> -BEGIN PGP SIGNED MESSAGE-
> >> Hash: SHA256
> >>
> >>
> >> John Kitchin  writes:
> >>
> >> > My go to reference is
> >> >
> >>
> https://kitchingroup.cheme.cmu.edu/blog/2016/11/04/New-link-features-in-org-9/
> >>
> >> Really thanks, John. I have read your blog article. Found most of link
> >> parameters examples. But still confused me, I'm wandering how to define
> a
> >> function for link parameter ":display" to append an all-the-icons
> unicode
> >> icon
> >> on link. I only found one ~:display 'full~ example in your article.
> >>
> >> an you show an example using a function for ~:display~? Thanks in
> advanced.
> >>
> >> >
> >> > On Tue, May 19, 2020 at 6:56 AM stardiviner 
> wrote:
> >> >
> >> >> -BEGIN PGP SIGNED MESSAGE-
> >> >> Hash: SHA256
> >> >>
> >> >>
> >> >> I'm write an extension to beautify org link with colors and unicode
> >> icons
> >> >> for
> >> >> better intuitive looks. But I don't know how to write those
> functions.
> >> >>
> >> >> I checked out this info page ([[info:org#Adding Hyperlink
> >> >> Types][info:org#Adding Hyperlink Types]]) of org mode.
> >> >>
> >> >> But have not found ~org-link-set-parameters~ other parameters code
> >> >> examples. I
> >> >> hope some examples can be added for the all other parameters.
> >> >>
> >> >> - --
> >> >> [ stardiviner ]
> >> >>I try to make every word tell the meaning that I want to
> express.
> >> >>
> >> >>Blog: https://stardiviner.github.io/
> >> >>IRC(freenode): stardiviner, Matrix: stardiviner
> >> >>GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
> >> >>
> >> >> -BEGIN PGP SIGNATURE-
> >> >>
> >> >> iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl7DuYkUHG51bWJjaGls
> >> >> ZEBnbWFpbC5jb20ACgkQG13xyVromsMMRAf/dkXg9kxbgTeCdjfcl2koeJkBmfNj
> >> >> xFGkuM0MlAc1oCIvGAeZ23GZ/B9cgtbfarGdZy1FJl9r7ehFx10Qg9w5keSIptA6
> >> >> mplEeCeKNgTwzyHIMQhI4xS+a80YliJNc8MgFi2o9tImKqavVV2eqwHPZDNE8HXt
> >> >> NEN+tfi8k2Sg7J7XhkdQD1YiNPTnKD8OXfzaR6162l5qSo3YuwoAegGmuULie2Ti
> >> >> fci2pFO56g46xLp1tWvI6z+Zxabyff/IjKkS

emacs + org-mode in virtual machine/docker/...

2020-05-21 Thread John Kitchin
Has anyone had any success in creating or using any kind of virtual machine
that can work across platforms to run emacs+org-mode?


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: [Question] why my org-link-set-parameters :face function does not work?

2020-05-20 Thread John Kitchin
On Tue, May 19, 2020 at 6:51 PM stardiviner  wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
>
> John Kitchin  writes:
>
> > The face function only takes the link path, which is a string. you cannot
> > use org-element-property on it.
> >
> > Maybe you want something like this:
> >
> > #+begin_src emacs-lisp
> > (defun org-link-beautify-face (path)
> >   "Set link face colors."
> >   (message "beautifying")
> >   (if (and (not (file-remote-p path))
> >   (file-exists-p (expand-file-name path)))
> >   'org-link
> > 'org-warning))
> >
> > ;;; DEBUG
> > (org-link-set-parameters
> >  "file"
> >  :face #'org-link-beautify-face)
> > #+end_src
>
> I actually borrowed code from your code example, Because I want to do the
> following:
>

Where did you find code that uses org-element-property on a link like this?
This won’t work with org-link-set-parameters because the face function does
not get an org-element, it gets only the path part of it.


> #+begin_src emacs-lisp
> (defun org-link-beautify-face (link)
>   "Set link face colors."
>   (let ((raw-link (org-element-property :raw-link link))
> (type (org-element-property :type link))
> (path (org-element-property :path link)))
> (pcase type
>   ;; ("https" )
>   ;; ("http" )
>   ("file"
>(if (and (not (file-remote-p path))
> (file-exists-p (expand-file-name path)))
>'org-link 'org-warning)
>
> (dolist (link-type (mapcar 'car org-link-parameters))
>   (org-link-set-parameters link-type
>:face #'org-link-beautify-face))
> #+end_src
>
> In this way, I can put my code in a union function.
>
> I guess the issue is on the let-binding which invoked
> ~org-element-property~. But
> I can't edebug this function. When I =C-u C-M-x= set edebug on the
> function, and
> toggle ~font-lock-mode~ on Org Mode buffer, this function is not entering
> edebug.
> Don't know how to make Emacs enter this function edebug status.
>

I don’t think you can use edebug in font lock functions. I always use the
old fashioned (message “%s” thing-i-want-to-see) approach.

Maybe there is some fancy way to do it, e.g. font-lock-studio, but I don’t
do it often enough to be fluent in fancy things!


> >
> > 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 Tue, May 19, 2020 at 9:12 AM stardiviner  wrote:
> >
> >> -BEGIN PGP SIGNED MESSAGE-
> >> Hash: SHA256
> >>
> >>
> >> Bellowing is my source code, it does not work. I'm wondering why?
> >>
> >> #+begin_src emacs-lisp
> >> (defun org-link-beautify-face (link)
> >>   "Set link face colors."
> >>   (let ((raw-link (org-element-property :raw-link link))
> >> (type (org-element-property :type link))
> >> (path (org-element-property :path link)))
> >> (pcase type
> >>   ;; ("https" )
> >>   ;; ("http" )
> >>   ("file"
> >>(if (and (not (file-remote-p path))
> >> (file-exists-p (expand-file-name path)))
> >>'org-link 'org-warning)
> >>
> >> ;;; DEBUG
> >> (org-link-set-parameters
> >>  "file"
> >>  :face #'org-link-beautify-face)
> >> #+end_src
> >>
> >> - --
> >> [ stardiviner ]
> >>I try to make every word tell the meaning that I want to express.
> >>
> >>Blog: https://stardiviner.github.io/
> >>IRC(freenode): stardiviner, Matrix: stardiviner
> >>GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
> >>
> >> -BEGIN PGP SIGNATURE-
> >>
> >> iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl7D2xkUHG51bWJjaGls
> >> ZEBnbWFpbC5jb20ACgkQG13xyVromsMfHAgAjnoQlzdHlcKL/rBVBLlkmMITh7f5
> >> 6SxRw9sS1BagIma+APiuy+A4O4fSDLyzUMDg+Sg/C+vNu3QC2BM7ipBYNXtWcX1M
> >> oPZj8loMrnISTIK51j2+9Pg0iOP1aZSvZqwA0p1mK2aZURBXWl7qDkVxD2oWji5P
> >> qCBVr9ZFUloGSl7PtZTlOtsCgTCGHvnfvnk7vqxY4beuavQgaRSWUCsVDDO0c/M6
> >> 5CSzxobElB3Y68fQ2awuQwRGCzfEvRkGShHp3Raug+EJ5Ew+MYEi6wI

Re: How to defint functions for other org link parameters like :face :display etc?

2020-05-19 Thread John Kitchin
I don't know if :display is for that, I think it is mostly related to
should a link with description only show the description, or should it be
full and show link and description.

You probably want the :activate option, where you could use something like
an overlay on the link. I don't have time to make an example for that right
now. the gist is you make an activate function, and you can add a
text-property or overlay  display on the link. You probably need to check
that the property isn't there already to avoid adding overlays on
every fontification.


https://kitchingroup.cheme.cmu.edu/blog/2016/11/04/New-link-features-in-org-9/#org069cbfa
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 Tue, May 19, 2020 at 9:21 AM stardiviner  wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
>
> John Kitchin  writes:
>
> > My go to reference is
> >
> https://kitchingroup.cheme.cmu.edu/blog/2016/11/04/New-link-features-in-org-9/
>
> Really thanks, John. I have read your blog article. Found most of link
> parameters examples. But still confused me, I'm wandering how to define a
> function for link parameter ":display" to append an all-the-icons unicode
> icon
> on link. I only found one ~:display 'full~ example in your article.
>
> an you show an example using a function for ~:display~? Thanks in advanced.
>
> >
> > On Tue, May 19, 2020 at 6:56 AM stardiviner  wrote:
> >
> >> -BEGIN PGP SIGNED MESSAGE-
> >> Hash: SHA256
> >>
> >>
> >> I'm write an extension to beautify org link with colors and unicode
> icons
> >> for
> >> better intuitive looks. But I don't know how to write those functions.
> >>
> >> I checked out this info page ([[info:org#Adding Hyperlink
> >> Types][info:org#Adding Hyperlink Types]]) of org mode.
> >>
> >> But have not found ~org-link-set-parameters~ other parameters code
> >> examples. I
> >> hope some examples can be added for the all other parameters.
> >>
> >> - --
> >> [ stardiviner ]
> >>I try to make every word tell the meaning that I want to express.
> >>
> >>Blog: https://stardiviner.github.io/
> >>IRC(freenode): stardiviner, Matrix: stardiviner
> >>GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
> >>
> >> -BEGIN PGP SIGNATURE-
> >>
> >> iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl7DuYkUHG51bWJjaGls
> >> ZEBnbWFpbC5jb20ACgkQG13xyVromsMMRAf/dkXg9kxbgTeCdjfcl2koeJkBmfNj
> >> xFGkuM0MlAc1oCIvGAeZ23GZ/B9cgtbfarGdZy1FJl9r7ehFx10Qg9w5keSIptA6
> >> mplEeCeKNgTwzyHIMQhI4xS+a80YliJNc8MgFi2o9tImKqavVV2eqwHPZDNE8HXt
> >> NEN+tfi8k2Sg7J7XhkdQD1YiNPTnKD8OXfzaR6162l5qSo3YuwoAegGmuULie2Ti
> >> fci2pFO56g46xLp1tWvI6z+Zxabyff/IjKkSWSNTHuQ5lhvYsmuFKF1JDfS/DHJV
> >> zy3Rr6sXK+MY1YWMMh2uLvmigL/BYl5HvjzC/Sq6wXcqVi0FuryeEfDWzg==
> >> =HMJr
> >> -END PGP SIGNATURE-
> >>
> >> --
> > 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
>
>
> - --
> [ stardiviner ]
>I try to make every word tell the meaning that I want to express.
>
>Blog: https://stardiviner.github.io/
>IRC(freenode): stardiviner, Matrix: stardiviner
>GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
>
> -BEGIN PGP SIGNATURE-
>
> iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl7D3TMUHG51bWJjaGls
> ZEBnbWFpbC5jb20ACgkQG13xyVromsPoCQf/TrUtyBtPUYGtNiJeXWk0oQNbwggf
> 6FHX3wsvBS3O9A2VpKuzWTdnKSFR7dVUF8NkBwHbvU+599LqT5XxGtF2iDX+jgiz
> t0G2207sczHtiwsE/KLGAxXmEI4tGESLv+4Jui3kjp8JJJCusDcjzTIXQ6O9sb91
> PmSbQhj4dbUz/3zk+utLb3YBMUPDnsr4H+eon+ko+EQOxTL48O4x7xvjj07XrnX3
> DawQG0qs9SnenkMsK2HzQBRDqCf0DfrVPmajWYUQJ62j2ocah8oXij6WH5/rgCpA
> xtt2sXJrQd2TFpCxcGWn5PsyEUMWjxAx1dia8pcMkBLvnb2SQkM6204jWQ==
> =SVJD
> -END PGP SIGNATURE-
>
>


Re: [Question] why my org-link-set-parameters :face function does not work?

2020-05-19 Thread John Kitchin
The face function only takes the link path, which is a string. you cannot
use org-element-property on it.

Maybe you want something like this:

#+begin_src emacs-lisp
(defun org-link-beautify-face (path)
  "Set link face colors."
  (message "beautifying")
  (if (and (not (file-remote-p path))
  (file-exists-p (expand-file-name path)))
  'org-link
'org-warning))

;;; DEBUG
(org-link-set-parameters
 "file"
 :face #'org-link-beautify-face)
#+end_src

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 Tue, May 19, 2020 at 9:12 AM stardiviner  wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
>
> Bellowing is my source code, it does not work. I'm wondering why?
>
> #+begin_src emacs-lisp
> (defun org-link-beautify-face (link)
>   "Set link face colors."
>   (let ((raw-link (org-element-property :raw-link link))
> (type (org-element-property :type link))
> (path (org-element-property :path link)))
> (pcase type
>   ;; ("https" )
>   ;; ("http" )
>   ("file"
>(if (and (not (file-remote-p path))
> (file-exists-p (expand-file-name path)))
>'org-link 'org-warning)
>
> ;;; DEBUG
> (org-link-set-parameters
>  "file"
>  :face #'org-link-beautify-face)
> #+end_src
>
> - --
> [ stardiviner ]
>I try to make every word tell the meaning that I want to express.
>
>Blog: https://stardiviner.github.io/
>IRC(freenode): stardiviner, Matrix: stardiviner
>GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
>
> -BEGIN PGP SIGNATURE-
>
> iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl7D2xkUHG51bWJjaGls
> ZEBnbWFpbC5jb20ACgkQG13xyVromsMfHAgAjnoQlzdHlcKL/rBVBLlkmMITh7f5
> 6SxRw9sS1BagIma+APiuy+A4O4fSDLyzUMDg+Sg/C+vNu3QC2BM7ipBYNXtWcX1M
> oPZj8loMrnISTIK51j2+9Pg0iOP1aZSvZqwA0p1mK2aZURBXWl7qDkVxD2oWji5P
> qCBVr9ZFUloGSl7PtZTlOtsCgTCGHvnfvnk7vqxY4beuavQgaRSWUCsVDDO0c/M6
> 5CSzxobElB3Y68fQ2awuQwRGCzfEvRkGShHp3Raug+EJ5Ew+MYEi6wILfPxYF2WR
> VJjuxAxseBuiIjYjF91xzbR7mSZQsvB1gNttLYb3uQ/jrgj0HOQDo5Jmtg==
> =4fE9
> -END PGP SIGNATURE-
>
>


Re: How to defint functions for other org link parameters like :face :display etc?

2020-05-19 Thread John Kitchin
My go to reference is
https://kitchingroup.cheme.cmu.edu/blog/2016/11/04/New-link-features-in-org-9/

J

On Tue, May 19, 2020 at 6:56 AM stardiviner  wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
>
> I'm write an extension to beautify org link with colors and unicode icons
> for
> better intuitive looks. But I don't know how to write those functions.
>
> I checked out this info page ([[info:org#Adding Hyperlink
> Types][info:org#Adding Hyperlink Types]]) of org mode.
>
> But have not found ~org-link-set-parameters~ other parameters code
> examples. I
> hope some examples can be added for the all other parameters.
>
> - --
> [ stardiviner ]
>I try to make every word tell the meaning that I want to express.
>
>Blog: https://stardiviner.github.io/
>IRC(freenode): stardiviner, Matrix: stardiviner
>GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
>
> -BEGIN PGP SIGNATURE-
>
> iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl7DuYkUHG51bWJjaGls
> ZEBnbWFpbC5jb20ACgkQG13xyVromsMMRAf/dkXg9kxbgTeCdjfcl2koeJkBmfNj
> xFGkuM0MlAc1oCIvGAeZ23GZ/B9cgtbfarGdZy1FJl9r7ehFx10Qg9w5keSIptA6
> mplEeCeKNgTwzyHIMQhI4xS+a80YliJNc8MgFi2o9tImKqavVV2eqwHPZDNE8HXt
> NEN+tfi8k2Sg7J7XhkdQD1YiNPTnKD8OXfzaR6162l5qSo3YuwoAegGmuULie2Ti
> fci2pFO56g46xLp1tWvI6z+Zxabyff/IjKkSWSNTHuQ5lhvYsmuFKF1JDfS/DHJV
> zy3Rr6sXK+MY1YWMMh2uLvmigL/BYl5HvjzC/Sq6wXcqVi0FuryeEfDWzg==
> =HMJr
> -END PGP SIGNATURE-
>
> --
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: get the body of a heading up to the next subheading

2020-05-13 Thread John Kitchin
good point, thanks!

Here is a new version that might fail some other way!

(defun canvas-org-get-heading-body ()
  "Return the body of the current heading up to the next heading."
  (interactive)
  (save-excursion
(unless (org-at-heading-p)
  (org-previous-visible-heading 1))
(org-end-of-meta-data)
(buffer-substring (point)
 (progn (org-next-visible-heading 1) (point)



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 Wed, May 13, 2020 at 10:42 AM Ihor Radchenko  wrote:

> > Thanks! Here is what I am currently using:
>
> Note that your code may fail if there is an inline task in the body.
>
> Best,
> Ihor
>
> John Kitchin  writes:
>
> > Thanks! Here is what I am currently using:
> >
> > (defun canvas-org-get-heading-body ()
> >   "Return the body of the current heading up to the next heading."
> >   (interactive)
> >   (save-excursion
> > (unless (org-at-heading-p)
> >   (org-previous-visible-heading 1))
> > (org-end-of-meta-data)
> > (buffer-substring (point)
> > (progn (re-search-forward org-heading-regexp nil 'mv)
> >(line-beginning-position)
> >
> > So far it gets what I want. I am pretty sure I have reinvented this,
> > maybe even from code I wrote before... I couldn't find my answer on SO
> > or my blog though.
> >
> > Ihor Radchenko  writes:
> >
> >> You may use something similar to org-quick-peek--get-entry-text from
> >> org-quick-peek package (https://github.com/alphapapa/org-quick-peek):
> >>
> >> (cl-defun org-quick-peek--get-entry-text (marker  keep-drawers
> keep-planning)
> >>   "Return Org entry text from node at MARKER.
> >> If KEEP-DRAWERS is non-nil, drawers will be kept, otherwise
> >> removed."
> >>   ;; Modeled after `org-agenda-get-some-entry-text'
> >>   (let (text)
> >> (with-current-buffer (marker-buffer marker)
> >>   ;; Get raw entry text
> >>   (org-with-wide-buffer
> >>(goto-char marker)
> >>;; Skip heading
> >>(end-of-line 1)
> >>;; Get entry text
> >>(setq text (buffer-substring
> >>(point)
> >>(or (save-excursion (outline-next-heading) (point))
> >>(point-max))
> >> (with-temp-buffer
> >>   (org-mode)
> >>   (insert text)
> >>   (unless keep-drawers
> >> (goto-char (point-min))
> >> (while (re-search-forward org-drawer-regexp nil t)
> >>   ;; Remove drawers
> >>   (delete-region (match-beginning 0)
> >>  (progn (re-search-forward
> >>  "^[ \t]*:END:.*\n?" nil 'move)
> >>     (point)
> >>   (unless keep-planning
> >> (goto-char (point-min))
> >> (while (re-search-forward org-planning-line-re nil t)
> >>   ;; Remove planning line
> >>   (kill-whole-line)))
> >>   (setq text (buffer-substring (point-min) (point-max
> >> (-reduce-r #'funcall (reverse (cons text (cons #'identity
> org-quick-peek-filter-functions))
> >>
> >> Best,
> >> Ihor
> >>
> >> John Kitchin  writes:
> >>
> >>> Hi everyone,
> >>>
> >>> I am trying to get the body of a heading up to the next subheading. For
> >>> example with this org file,
> >>>
> >>> * quiz one
> >>>
> >>> This is the description.
> >>> Use emacs for this.
> >>>
> >>> ** question 1
> >>> what is 40 + 2
> >>>
> >>> If the point is in the first heading, I want to run a function that
> would
> >>> return the string "This is the description.\nUse emacs for this."
> >>>
> >>> I thought there was a simple way to do that, but so far it has eluded
> my
> >>> google fu. Any hints?
> >>>
> >>> 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
> >
> >
> > --
> > 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
>
> --
> Ihor Radchenko,
> PhD,
> Center for Advancing Materials Performance from the Nanoscale (CAMP-nano)
> State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong
> University, Xi'an, China
> Email: yanta...@gmail.com, ihor_radche...@alumni.sutd.edu.sg
>


Re: get the body of a heading up to the next subheading

2020-05-13 Thread John Kitchin
Thanks! Here is what I am currently using:

(defun canvas-org-get-heading-body ()
  "Return the body of the current heading up to the next heading."
  (interactive)
  (save-excursion
(unless (org-at-heading-p)
  (org-previous-visible-heading 1))
(org-end-of-meta-data)
(buffer-substring (point)
  (progn (re-search-forward org-heading-regexp nil 'mv)
 (line-beginning-position)

So far it gets what I want. I am pretty sure I have reinvented this,
maybe even from code I wrote before... I couldn't find my answer on SO
or my blog though.

Ihor Radchenko  writes:

> You may use something similar to org-quick-peek--get-entry-text from
> org-quick-peek package (https://github.com/alphapapa/org-quick-peek):
>
> (cl-defun org-quick-peek--get-entry-text (marker  keep-drawers 
> keep-planning)
>   "Return Org entry text from node at MARKER.
> If KEEP-DRAWERS is non-nil, drawers will be kept, otherwise
> removed."
>   ;; Modeled after `org-agenda-get-some-entry-text'
>   (let (text)
> (with-current-buffer (marker-buffer marker)
>   ;; Get raw entry text
>   (org-with-wide-buffer
>(goto-char marker)
>;; Skip heading
>(end-of-line 1)
>;; Get entry text
>(setq text (buffer-substring
>(point)
>(or (save-excursion (outline-next-heading) (point))
>(point-max))
> (with-temp-buffer
>   (org-mode)
>   (insert text)
>   (unless keep-drawers
> (goto-char (point-min))
> (while (re-search-forward org-drawer-regexp nil t)
>   ;; Remove drawers
>   (delete-region (match-beginning 0)
>  (progn (re-search-forward
>  "^[ \t]*:END:.*\n?" nil 'move)
> (point)
>   (unless keep-planning
> (goto-char (point-min))
> (while (re-search-forward org-planning-line-re nil t)
>   ;; Remove planning line
>   (kill-whole-line)))
>   (setq text (buffer-substring (point-min) (point-max
> (-reduce-r #'funcall (reverse (cons text (cons #'identity 
> org-quick-peek-filter-functions))
>
> Best,
> Ihor
>
> John Kitchin  writes:
>
>> Hi everyone,
>>
>> I am trying to get the body of a heading up to the next subheading. For
>> example with this org file,
>>
>> * quiz one
>>
>> This is the description.
>> Use emacs for this.
>>
>> ** question 1
>> what is 40 + 2
>>
>> If the point is in the first heading, I want to run a function that would
>> return the string "This is the description.\nUse emacs for this."
>>
>> I thought there was a simple way to do that, but so far it has eluded my
>> google fu. Any hints?
>>
>> 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


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



get the body of a heading up to the next subheading

2020-05-11 Thread John Kitchin
Hi everyone,

I am trying to get the body of a heading up to the next subheading. For
example with this org file,

* quiz one

This is the description.
Use emacs for this.

** question 1
what is 40 + 2

If the point is in the first heading, I want to run a function that would
return the string "This is the description.\nUse emacs for this."

I thought there was a simple way to do that, but so far it has eluded my
google fu. Any hints?

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: Display in minibuffer link under point

2020-05-11 Thread John Kitchin
org-ref doesn't do anything fancy here, it just runs an idle timer:

https://github.com/jkitchin/org-ref/blob/master/org-ref-core.el#L597

that runs a function defined at
https://github.com/jkitchin/org-ref/blob/master/org-ref-core.el#L3633

that function is kind of long because it computes the message, and only
in specific contexts.

Garjola Dindi  writes:

> Hi,
>
> Thanks both of you for your answers.
>
> What would be the way to automatically trigger =display-local-help= when the 
> point is on the link? Org-ref does that beautifully ;)
>
> Thanks again.
>
> Garjola
>
> On Fri 08-May-2020 at 22:48:37 +02, John Kitchin  
> wrote:
>> It looks like that variable is obsolete now since Emacs 24.1, and 
>> (tooltip-mode -1) is probably the way to get the same thing now.
>>
>> 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, May 8, 2020 at 1:18 PM briangpowell .  
>> wrote:
>>
>>  I use this variable to toggle my Gnu Emacs Org-Mode buffer into an audio 
>> desktop:
>>
>>  (setq tooltip-use-echo-area (not tooltip-use-echo-area))
>>
>>  Of course I had to do some programming to do that but the above should get 
>> you started
>>
>>  And we can leave that programming as an exercise for the class--right Dr. 
>> Kitchin?
>>
>>  ;-)
>>
>>  On Fri, May 8, 2020 at 9:19 AM John Kitchin  wrote:
>>
>>  M-x display-local-help might do it.
>>
>>  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, May 8, 2020 at 9:15 AM Garjola Dindi  wrote:
>>
>>  Hi,
>>
>>  Is there a way to display in the minibuffer the URL of the link under
>>  the point in the same way as when the mouse pointer is over the link?
>>
>>  Thanks!
>>
>>  Garjola
>>  --


--
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: Display in minibuffer link under point

2020-05-08 Thread John Kitchin
It looks like that variable is obsolete now since Emacs 24.1, and
(tooltip-mode -1) is probably the way to get the same thing now.

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, May 8, 2020 at 1:18 PM briangpowell . 
wrote:

> I use this variable to toggle my Gnu Emacs Org-Mode buffer into an audio
> desktop:
>
> (setq tooltip-use-echo-area (not tooltip-use-echo-area))
>
> Of course I had to do some programming to do that but the above should get
> you started
>
> And we can leave that programming as an exercise for the class--right Dr.
> Kitchin?
>
> ;-)
>
>
>
>
>
>
>
>
> On Fri, May 8, 2020 at 9:19 AM John Kitchin 
> wrote:
>
>> M-x display-local-help might do it.
>>
>> 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, May 8, 2020 at 9:15 AM Garjola Dindi  wrote:
>>
>>> Hi,
>>>
>>> Is there a way to display in the minibuffer the URL of the link under
>>> the point in the same way as when the mouse pointer is over the link?
>>>
>>> Thanks!
>>>
>>> Garjola
>>> --
>>>
>>>
>>>


Re: Display in minibuffer link under point

2020-05-08 Thread John Kitchin
M-x display-local-help might do it.

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, May 8, 2020 at 9:15 AM Garjola Dindi  wrote:

> Hi,
>
> Is there a way to display in the minibuffer the URL of the link under
> the point in the same way as when the mouse pointer is over the link?
>
> Thanks!
>
> Garjola
> --
>
>
>


Re: Public API change: How to handle function signature change gracefully

2020-04-21 Thread John Kitchin
I think what Nicolas suggests is probably the easiest path. Here is one
example that does what I think you are looking for. I use a simple string
comparison on the contents, you could do something more sophisticated.

#+BEGIN_SRC emacs-lisp
(defun fruit-link-face (path)
  (let* ((ln (org-element-context))
(start (org-element-property :contents-begin ln))
(end (org-element-property :contents-end ln))
(contents (if (and start end)
  (buffer-substring start end)
nil)))
(if (and contents (stringp contents))
(if (string> contents "j")
   '(:foreground "red")
 '(:foreground "blue"))
  'org-link)))


(org-link-set-parameters "fruit"
 :face 'fruit-link-face)
#+END_SRC

#+RESULTS:
| :face | fruit-link-face |

[[fruit:mango ][test]].  # this will be red

  fruit:apple. # regular org link.

 [[fruit:apple][bera]]. # this will be blue
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 Tue, Apr 21, 2020 at 1:57 PM Nicolas Goaziou 
wrote:

> Hello,
>
> Benjamin Andresen writes:
> >
> > I would like to change the public API of the :face part of
> `org-link-set-parameters':
> >
> > (org-link-set-parameters "file" :face 'org-link)
> >
> > My ultimate goal is to have org-links be able to be have their face
> changed based on the contents, not just the path of the link.
> >
> > I found the relevant code in org.el in the function `org-activate-links':
> >
> >'face (pcase (org-link-get-parameter type :face)
> >((and (pred functionp) face) (funcall face path))
> >((and (pred facep) face) face)
> >((and (pred consp) face) face) ;anonymous
> >(_ 'org-link))
> >
> > and would like to change this to
> >
> >'face (pcase (org-link-get-parameter type :face)
> >((and (pred functionp) face) (funcall face path contents)) ;; this is
> the change
> >((and (pred facep) face) face)
> >((and (pred consp) face) face) ;anonymous
> >(_ 'org-link))
> >
> > Now that will introduce a host of call issues because the callees don't
> expect to the amount of arguments changed under their bottom.
> >
> > I would like some guidance how I could get what I think is neat: The
> > contents of the bracket-style links as an additional parameter to set
> > faces on and not breaking existing hookups.
>
> Isn't the function called with point on the link? You may just need to
> extract the contents from the environment.
>
> Otherwise, a solution is to catch `wrong-number-of-arguments' error and
> call again the function with the old calling convention. See, e.g.,
> `org-link-open'.
>
> > To make this more palatable I would suggest it's changed so that the
> > 2nd argument will be a list of alists or keywords so to not have this
> > function signature problem if someone else comes up with a reason to
> > introduce yet more data.
>
> Beware the over-engineering. At this point, someone motivated enough can
> put an advice to the link fontification function.
>
> Regards,
>
> --
> Nicolas Goaziou
>
>


Re: org-ref: xxx-add-bibtex-entry with an org-capture like interface

2020-04-14 Thread John Kitchin
That function inserts into a bibtex file, and if you don't save it then
the new entry is not "findable", so it is somewhat critical to do that
in my mind. It could make sense to check if there is a file attached to
the buffer though, and only save in that case. That would preserve the
current behavior, and solve your problem I think. WDYT?

Daniele Nicolodi  writes:

> On 09-04-2020 13:43, John Kitchin wrote:
>> This is basically what doi-add-bibtex-entry does. There isn't one
>> function that does arxiv too, but there is arxiv-add-bibtex-entry. Those
>> are both commands in org-ref. These don't pop up a buffer for approval,
>> that is something you would have to build yourself.
>>
>> There are many workflows people want, the one above works for me when I
>> am writing, and just want to add entries with minimal disruption. I
>> usually polish the entries later if needed. I can see a slower, approach
>> like you describe too.
>
> Hello John,
>
> I have been able to hack something combining org-capture and the utility
> functions you mention that implements the workflow I described.
>
> There is only one issue: doi-utils-insert-bibtex-entry-from-doi contains
> a (save-buffer) call that does not play nicely when I call it on a
> temporary buffer. Why is the (save-buffer) there?
> doi-utils-insert-bibtex-entry-from-doi looks like an utility function,
> thus I think it should not try to save the current buffer. What do you
> think?
>
> Thank you.
>
> Cheers,
> Dan


--
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: org-ref: xxx-add-bibtex-entry with an org-capture like interface

2020-04-09 Thread John Kitchin
This is basically what doi-add-bibtex-entry does. There isn't one
function that does arxiv too, but there is arxiv-add-bibtex-entry. Those
are both commands in org-ref. These don't pop up a buffer for approval,
that is something you would have to build yourself.

There are many workflows people want, the one above works for me when I
am writing, and just want to add entries with minimal disruption. I
usually polish the entries later if needed. I can see a slower, approach
like you describe too.

Daniele Nicolodi  writes:

> Hello John,
>
> sorry for the cryptic subject but I was unable to come up with something
> better.  I am revamping my workflow to take notes about articles I read
> or that I save to be read later and I decided to explore if org-ref and
> the related utility packages fit what I would like to be able to do.
>
> org-ref offers quite a few very useful facilities, however, I would like
> an interface to add new entries to the bibliography more similar to
> org-capture: I would like to have a command that asks for an identifier
> (for example a URL, a DOI, an arXiv id) and pops up a buffer with a
> populated bibtex entry that can be verified and amended before being
> appended to a bibtex file (for example add some keywords).
>
> I think most of the building blocks are there, but before starting to
> hack something together myself I wanted to check if this functionality
> is already there and I missed it, and if it would be interesting to add
> it to the functionality shipped with org-ref. Of course, any hint on how
> to implement this effectively is greatly appreciated.
>
> Thank you.
>
> Cheers,
> Dan


--
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: wip-cite status question and feedback

2020-04-08 Thread John Kitchin
org-ref relies very heavily on the link functionality to provide actions on
a cite, e.g. to open the pdf, or url, allow sorting, to change the cite
color when it is a bad key, etc If the new syntax also has that capability,
e.g. through font-lock, then I would consider integrating it into org-ref,
but if not I think it would be a big regression in org-ref functionality.

If I were to dream, each cite would have text-properties that include the
key (so it is easy to get the key at point and do something with info in
the corresponding database), and a help-echo function that could be
user-defined, a face function that could be user-defined, a user-defined
keymap, and some properties that define the bounds of the cite. While at
it, maybe it is a good idea to allow a custom display, so one could toggle
between a short cite (e.g. number or author year) and the full cites. These
do not need to be part of the implementation, but if they were possible
from the implementation it would be a lot more useful for something like
org-ref.

It would be a gain in quality of export, especially for non-LaTeX documents
though, if there was an integrated citeproc.

For the bibliography you need to support a few variants, IMO. One is
bibtex-like, where you specify the source of the bibliography(ies) in the
place where you want it to appear. The other is biblatex like, where the
bibliography(ies) can be specified in a header or as properties, and you
have another way to specify where in the document you want the bibliography
to be.

It should also be possible to have no bibliography, but the correct
citations. And it should be possible to have the bibliography go to another
file.

Finally, the most common thing I do is use a default bibliography that is
defined in a variable in my init file. This lets me put citations in
org-files conveniently, but I almost never export these as they are usually
just notes.

If that all seemed possible, most likely it would make sense to start a new
generation of org-ref that largely eliminated the links. I would probably
still have to keep label and the ref links. There is not currently a way to
reference equations otherwise. Tables and Figures seem ok with native org
links.

A new org-ref wouldn't happen fast, I guess it would be a year long
project. But a clean slate would have some advantages to clean up and
consolidate some things.

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 Wed, Apr 8, 2020 at 8:19 AM Bruce D'Arcus  wrote:

> On Wed, Apr 8, 2020 at 5:32 AM Nicolas Goaziou 
> wrote:
> >
> > Hello,
> >
> > "Bruce D'Arcus"  writes:
> >
> > > Note that in CSL processors, the locators are meaningful key-values,
> > > basically; not plain text strings.
> >
> > OK, but it is enough for Org to feed a CSL processor with, e.g.,
> >
> >   key-> "@doe99"
> >   prefix -> "see "
> >   suffix -> ", pp. 33-35"
> >
> > Then CSL processor does its job to extract whatever information it
> > needs. Am I right?
>
> On this, I would defer to András and Albert (who maintains the pandoc
> org code, I believe).
>
> Bruce
>
>
>
> Bruce
>


virtual org-mode meetup tomorrow 11am EST

2020-03-14 Thread John Kitchin
Hi everyone,

I would like to host a virtual org-mode meetup tomorrow. It has been on my
mind to do this for a while, but recent events due to the coronavirus have
made it more urgent to figure out how to do this! For example, next week we
are teaching everything this way. So, tomorrow, I invite you to join my
meeting (details below) to chat about org-mode things. If it is a wild
success and there are a lot of you, maybe we will try making breakout rooms
in the meeting to have small groups on different topics.

The meeting will start at 11amEST and go to 12:30pm.

I am open to any topics for discussion. We could also have short
presentations if anyone wants to put one together. We could plan a virtual
org-mode conference for another date. We could collaborate in real time on
some new feature.  If you have some ideas let me know and I will see what
we can do!

I hope to see some of you tomorrow.

Best wishes,


John Kitchin is inviting you to a scheduled Zoom meeting.

Join Zoom Meeting
https://cmu.zoom.us/j/849205716
<https://www.google.com/url?q=https://cmu.zoom.us/j/849205716=D=2=AOvVaw0cCMKSpS34NehyeJu1YoL_>

Meeting ID: 849 205 716

One tap mobile
+19292056099,,849205716# US (New York)
+13126266799,,849205716# US (Chicago)

Dial by your location
+1 929 205 6099 US (New York)
+1 312 626 6799 US (Chicago)
+1 470 250 9358 US (Atlanta)
+1 646 518 9805 US (New York)
+1 786 635 1003 US (Miami)
+1 602 753 0140 US (Phoenix)
+1 651 372 8299 US
+1 669 219 2599 US (San Jose)
+1 669 900 6833 US (San Jose)
+1 720 928 9299 US (Denver)
+1 971 247 1195 US (Portland)
+1 213 338 8477 US (Los Angeles)
+1 253 215 8782 US
+1 301 715 8592 US
+1 346 248 7799 US (Houston)
Meeting ID: 849 205 716
Find your local number: https://cmu.zoom.us/u/aJ805L6JI
<https://www.google.com/url?q=https://cmu.zoom.us/u/aJ805L6JI=D=2=AOvVaw05cow-L8ZI04KAXEvWk6vk>

Join by SIP
849205...@zoomcrc.com

Join by H.323
162.255.37.11 (US West)
162.255.36.11 (US East)
221.122.88.195 (China)
115.114.131.7 (India Mumbai)
115.114.115.7 (India Hyderabad)
213.19.144.110 (EMEA)
103.122.166.55 (Australia)
209.9.211.110 (Hong Kong)
64.211.144.160 (Brazil)
69.174.57.160 (Canada)
207.226.132.110 (Japan)
Meeting ID: 849 205 716


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: Exploring properties

2020-02-25 Thread John Kitchin
ints?
> 3. Org-mode macros provide {{{property(PROPERTYNAME)}}} syntax for macro 
> replacement during export. But nothing as simple as this is available for use 
> in source code blocks. Something like this would allow using some code to 
> add/update records in a database. We should perhaps build on the property API 
> or org-ql for creating something like this.
>
> If we can resolve some of these and creating a simple application for 
> demonstration, it might help in showing the potential and identifying other 
> challenges.
>
> On Mon, Feb 24, 2020 at 09:39:51AM +0100, Bastien wrote:
>> Hi Vikas,
>>
>> Vikas Rawal  writes:
>>
>> > I am essentially thinking of org-mode providing an
>> > interface for feeding data to recutils.
>>
>> Yes, that would probably be useful.
>>
>> If you want to write a feature request, please write it as if the
>> reader does not know recutils and you precise use-case, so that we
>> understand all implication and motivate possible contributors.
>>
>> Thanks,
>>
>> --
>>  Bastien
>>


--
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: Org Babel: Submit SQL to command line app & capture results

2020-02-24 Thread John Kitchin
I think you can do something like this. I don't have impala-shell, so
I wasn't able to test this. It worked using another executable though.
This is pretty bare bones, no sessions, etc.

(require 'org)
(require 'ob)

(defun org-babel-execute:impala (body params)
  (let* ((code (org-babel-expand-body:generic body params))
 (src-dir (make-temp-file "ob-impala-" t))
 (src-file (f-join src-dir (concat (file-name-nondirectory src-dir) 
".imp"

(with-temp-file src-file
  (insert code))

;; Compile step
(org-babel-eval
 (format "impala-shell %s" src-file)
 "")))


;;;###autoload
(eval-after-load 'org
  '(add-to-list 'org-src-lang-modes '("impala" . impala)))


(add-to-list 'org-src-lang-modes '("impala" . sql))





Nathan Neff  writes:

> Hello all,
>
> I would like to use org-babel to have SQL code like this:
>
> * Some heading
>
> #+begin_src something
> SELECT COUNT(*) FROM some_table;
> #+end_src
>
> I would like to have the code highlighted as SQL.  However, I'm not reading
> from a DB matching the requirements of
> https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-sql.html
>
> What I would like to do when I run the code above is to:
> 1) simply take the contents of the code and push it into a tmp file
> 2) run a shell program on the tmp file:
> impala-shell -f tmp file.txt
> 3) Capture the STDOUT from the above command
>
> How would I do this using org-babel?  Create a new "language"?
> Are there already similar implementations which basically take the contents
> of the source code, save to a temp file then execute a standalone program
> and capture results?
>
> Again, I would like to have SQL style highlighting.
>
> Thanks for pointers -- I'm sure this is something that's reasonably easy
> to implement - I just don't want to start off on the wrong foo.t
> --Nate


--
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: How to display overlay or propertize text on file: link type about the file?

2020-02-23 Thread John Kitchin
In that case:

#+BEGIN_SRC emacs-lisp
(defun file-description (start end path bracketp)
  (put-text-property start end 'display (shell-command-to-string
(format "file %s" path

(org-link-set-parameters
 "file"
 :activate-func 'file-description)
#+END_SRC

With this, you have to have a way to insert links that isn't typing them in
by hand; as soon as emacs recognizes the link, it changes the display which
makes it hard to type.

The shell command puts a long string, so you might replace that with
something that has the output you wanted above.
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, Feb 22, 2020 at 11:55 PM stardiviner  wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
>
> John Kitchin  writes:
>
> > I think you are looking for the :activate-func property of a link. What
> > you want is somewhat tricky though, how would you edit the link?
> >
> > There is an example at
> >
> https://kitchingroup.cheme.cmu.edu/blog/2016/11/04/New-link-features-in-org-9/#org069cbfa
>
> Thanks for your tips. Helpful!!
>
> >
> > that might give you some ideas. You can use a 'display text property to
> > change the appearance, but you need some way to remove this if you want
> > to edit or see the original version.
>
> I usually edit link with =[C-c C-l]= to edit link URL and description, not
> literally.
>
> >
> > stardiviner  writes:
> >
> >> -BEGIN PGP SIGNED MESSAGE-
> >> Hash: SHA256
> >>
> >>
> >> I have a requirement, I want to display file: link's file type info on
> the link.
> >>
> >> For example, an Org file: link
> >>
> >> #+begin_src org
> >> [[file:~/Org/logo.png][logo]]
> >> [[file:~/Org/document.pdf][document]]
> >> [[file:~/Org/book.epub][book]]
> >> #+end_src
> >>
> >> I want to display link as:
> >>
> >> #+begin_src org
> >> logo (image: png)
> >> document (document: pdf)
> >> book (ebook: epub)
> >> #+end_src
> >>
> >> I'm inspired by this code snippet:
> >>
> >> #+begin_src emacs-lisp
> >> (org-link-set-parameters
> >>  "file+sys"
> >>  :complete 'org-file-complete-link
> >>  :face (lambda (path) (if (file-exists-p path) 'org-link 'org-warning)))
> >> #+end_src
> >>
> >> Is it possible to display those info between parentheses with an
> overlay or
> >> propertied text?
> >>
> >> If someone have any idea or how to implement this, please help me.
> Thanks in advanced.
> >>
> >> - --
> >> [ 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
> >>
> >> -BEGIN PGP SIGNATURE-
> >>
> >> iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl5OrLYUHG51bWJjaGls
> >> ZEBnbWFpbC5jb20ACgkQG13xyVromsPElQf/W71U1JQ9ZeFjCWCxICs0q87016Iq
> >> 8FQ5Fr3lSmRb6NRLqzqAAbY6b14roxtixxmllvArJgd7bz280xTZs3NGgYMm/HMf
> >> sZ+vtkpiHgJk31KXxAk/LT1OcgzYOrSv7g6c8Y3Gg8G5eSDmKGu+tMwqFzYtVmk2
> >> 6G0/wz9ezsdYAFLlNrX/FhcVaxCUSSdG08z0Ip/Op1I4iqh3Y86N7LalPVZWNa9H
> >> eZSFsf3Z8NqfVnCmTvmyJon4x1SGvJ8Iaf4QUiE7huNeizJK2+CSIhjSu8yDBGr4
> >> 2oMPrkAm1XkJDLMQh0FLjIrIJUoTLzLonEYtlmg3thvFEMqFuF8ziYaGdw==
> >> =sZhk
> >> -END PGP SIGNATURE-
>
>
> - --
> [ 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
>
> -BEGIN PGP SIGNATURE-
>
> iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl5SBYsUHG51bWJjaGls
> ZEBnbWFpbC5jb20ACgkQG13xyVromsOSOAgAmtN0JBgMB//D8EC7tQhrSwVX7spb
> NLH2EQbdDmzOyf2y+gwrvzGBojQ7TBLmM/dzm+IfPNsbyY4IMlLBvyrJST7D0uDC
> SXA8Ugi88qKkyS5H+Hw5jSNcOaPxwXLq5kxu3BXmtBpdNiIShL0qnTD4itNRHpG8
> v0NWFQwTcMI15OcsTKoGSG9PNw7qeJEt5vpYLL/oljAxMW0VsCnS061XjWda8w5u
> U2KWYLCeVAh3kXtas5pywar50F+ELAoutpr3USqJDtFPtRkyVYAmEKBHknFJ2R4u
> 8nTIchXoctS5JpINhwq4wfdmSRSjjcz1DYb9Y9LSMFjDbvzAKqcSk6eX4g==
> =xhBz
> -END PGP SIGNATURE-
>
>


Re: Exploring properties

2020-02-23 Thread John Kitchin
org-ql (https://github.com/alphapapa/org-ql) is also quite good for this
kind of thing.

Here is even a database like query to find the heading, and EMAIL property
from all the files in a list returned by the function nb-org-files.

(org-ql-query
  :select '(cons (fifth (org-heading-components))
 (org-entry-get (point) "EMAIL"))
  :from (nb-org-files)
  :where '(and (property "EMAIL")))


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 Sun, Feb 23, 2020 at 8:25 AM Vikas Rawal  wrote:

>
> >
> > > I don't know if I have missed something obvious. But I am trying to
> > > read all the properties data (key-value pairs) into an R source code
> > > block (essentially to gather into a data.frame before further
> > > processing).
> >
> > You might want to look at `org-map-entries'.
>
> Thanks. It seems it will take more lisp than I can handle. But let me try.
>
> I think there is a potential to combine orgmode tags and properties, with
> a little more lisp may be, along with version control to create small
> database applications.
>
> It would be good to design something as a proof-of-concept.
>
> Vikas
>
>


Re: Limiting properties and property values

2020-02-23 Thread John Kitchin
One solution to this is a function you would write that validates the
properties, and prevents saving if they are invalid. You would want to use
it in a buffer/directory hook.

For example:

(defun validate-properties ()
  (goto-char (point-min))
  (catch 'error
(while (re-search-forward org-heading-regexp nil t)
  (let ((v (org-entry-get (point) "NUMERIC")))
(when v
 ;; Let's say we only allow +/- integers
 (if (string-match "\\`[-+]?[0-9]+\\'" v)
 nil
   (error "Non-integer value found: %s" v)
   (throw 'error nil)
   nil))

(add-hook 'write-file-functions 'validate-properties t)

You could use a different function for floats, or to make sure a value was
one of a few allowed options...

This only works if you only edit the files through emacs, and if everyone
is setup so this is automatically loaded in the directory, etc. An
alternative place to put something like this is in a git hook, if you have
your project in a git repo. you would have to figure out how to write a
script that would run emacs to do this kind of thing. But, then you could
make sure no invalid files were commited, for example.



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 Sun, Feb 23, 2020 at 4:40 AM Vikas Rawal  wrote:

>
>
> On Sun, 23 Feb 2020 at 15:02, Bastien  wrote:
>
>> Hi Vikas,
>>
>> Vikas Rawal  writes:
>>
>> > 1. Is it possible to restrict the sub-tree of a headline to have only
>> > properties specified in the column property of the parent? That is,
>> > no additional property can be specified.
>>
>> No, it is currently not possible.  What would be the use-case?
>>
>
>
> I am thinking of using org-mode to compile a small database. I would like
> to use properties to add data, and some restrictions of this kind to limit
> what properties a particular kind of headline could have.
>
> It might seem like an over-kill, but then for org-mode, almost nothing is
> an over-kill.
>
> I am missing a few nuts and bolts, but would really like to see how it
> works to use org-mode for a small org-mode-skilled team to use it as a data
> platform.
>
> Warmest greetings and regards,
>
> Vikas
>


Re: How to display overlay or propertize text on file: link type about the file?

2020-02-22 Thread John Kitchin
I think you are looking for the :activate-func property of a link. What
you want is somewhat tricky though, how would you edit the link?

There is an example at
https://kitchingroup.cheme.cmu.edu/blog/2016/11/04/New-link-features-in-org-9/#org069cbfa

that might give you some ideas. You can use a 'display text property to
change the appearance, but you need some way to remove this if you want
to edit or see the original version.

stardiviner  writes:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
>
> I have a requirement, I want to display file: link's file type info on the 
> link.
>
> For example, an Org file: link
>
> #+begin_src org
> [[file:~/Org/logo.png][logo]]
> [[file:~/Org/document.pdf][document]]
> [[file:~/Org/book.epub][book]]
> #+end_src
>
> I want to display link as:
>
> #+begin_src org
> logo (image: png)
> document (document: pdf)
> book (ebook: epub)
> #+end_src
>
> I'm inspired by this code snippet:
>
> #+begin_src emacs-lisp
> (org-link-set-parameters
>  "file+sys"
>  :complete 'org-file-complete-link
>  :face (lambda (path) (if (file-exists-p path) 'org-link 'org-warning)))
> #+end_src
>
> Is it possible to display those info between parentheses with an overlay or
> propertied text?
>
> If someone have any idea or how to implement this, please help me. Thanks in 
> advanced.
>
> - --
> [ 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
>
> -BEGIN PGP SIGNATURE-
>
> iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl5OrLYUHG51bWJjaGls
> ZEBnbWFpbC5jb20ACgkQG13xyVromsPElQf/W71U1JQ9ZeFjCWCxICs0q87016Iq
> 8FQ5Fr3lSmRb6NRLqzqAAbY6b14roxtixxmllvArJgd7bz280xTZs3NGgYMm/HMf
> sZ+vtkpiHgJk31KXxAk/LT1OcgzYOrSv7g6c8Y3Gg8G5eSDmKGu+tMwqFzYtVmk2
> 6G0/wz9ezsdYAFLlNrX/FhcVaxCUSSdG08z0Ip/Op1I4iqh3Y86N7LalPVZWNa9H
> eZSFsf3Z8NqfVnCmTvmyJon4x1SGvJ8Iaf4QUiE7huNeizJK2+CSIhjSu8yDBGr4
> 2oMPrkAm1XkJDLMQh0FLjIrIJUoTLzLonEYtlmg3thvFEMqFuF8ziYaGdw==
> =sZhk
> -END PGP SIGNATURE-


--
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: Automatic LaTeX preview toggling

2020-02-17 Thread John Kitchin
The version I have at
https://github.com/jkitchin/scimax/blob/master/scimax-org-latex.el#L398
still works for me.

I don't use it a lot, but I just tried it now on a small example and it
seemed ok.

Ag Ibragimov  writes:

> I just recently discovered that this excellent code snippet that I found long 
> time ago here:
> http://slumpy.org/blog/2017-02-01-automatic-latex-preview-in-org-mode
>
> which is based on even older post originally written by John Kitchin:
>
> http://kitchingroup.cheme.cmu.edu/blog/2015/10/09/Automatic-latex-image-toggling-when-cursor-is-on-a-fragment/
>
> unfortunately stopped working. I guess I missed it, at some point it seems 
> org--list-latex-overlays function was removed.
>
> Does anyone know if there's updated version of this thing somewhere? Or maybe 
> this was extracted into some plugin or something that can be installed from 
> MELPA maybe and I don't even know?


--
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: Documentation: Side effects of org-entry-properties and others

2020-02-17 Thread John Kitchin
I guess org-element-context and (org-element-at-point) also do this too (or
at least once did), because I have code that wraps them in save-match data
with notes to my self that match-data changes.

There are other things that unexpectedly do this, like split-string I think
(again based on code using this that is wrapped in save-match-data).


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 Mon, Feb 17, 2020 at 6:20 PM D  wrote:

> Hi,
>
> it seems a few functions meant to expose org internals to programmers
> seem to cause undocumented side effects.  A particular example being
> org-entry-properties.  When called, it changes the match-data.  This can
> cause issues in cases where leaking match-data can cause font-lock to
> behave inconsistently or throw errors.  I think it would be a good idea
> to add a prominent warning to such interfacing functions, or document it
> somewhere in the module.
>
> The same is true for org-element-lineage, but I am not so sure whether
> it is intended for hacking purposes as much as org-entry-properties.
> Sadly, I have no overview over the scope of this issue, so I do not know
> whether my suggestion is unrealistic (for example, because it would mean
> adding warnings practically everywhere).
>
> Regards,
>
> D.
>
>


Re: [PATCH] (Tiny) Tweak Python session null return value

2020-02-17 Thread John Kitchin
On Mon, Feb 17, 2020 at 3:46 PM Jack Kamm  wrote:

> Hi John,
>
> John Kitchin  writes:
>
> > I can see why you would want to see True/False there, but to get the
> value,
> > you need to specifically return what you want because AFAIK the body is
> > wrapped in a function that is evaluated to get the value, it is not
> simply
> > the last thing that gets evaluated.
>
> This is true for non-session blocks, which require explicitly calling
> "return". However, session blocks aren't wrapped in functions and don't
> use "return" (even before the most recent patches). The problem is that
> variables created in a function have local scope, so session blocks
> can't be wrapped in functions.
>

Fair point, I am not a python session user (I have used the ob-ipython for
a long time, or stand-alone python blocks), and I had forgotten or not
known of this. Indeed in a REPL, you get something closer to what you
originally suggested.

>>> a = 1

>>> if a:

... True

... else:

... False

...

True

I guess I would expect something like that if I was using a Python session
in org-mode. It is like a REPL that is easier to edit.

My earlier concern is mostly related to consistency of what an org Python
block does compared to what you might do at a REPL or from a script. I also
note that I almost never use :results value, and almost always prefer
:results output. That reflects the kind of stuff we usually do here though,
and may not be representative of others.



> > Your example clarified to me at least why it would be tricky to figure
> > it out, you can't rely on the last line, for example.
>
> Since the recent patches, we do extract the last line, using the Python
> ast module, however this only works if the last line is a top-level
> statement like "f()" or "1+1", not an assignment (like "x = 1+1") or an
> indented block (like "if:...else:...").
>
> >  I don't know if there is some special Python variable that contains
> > that.
>
> There actually is -- in most Python interpreters, the variable "_"
> (underscore) refers to the last statement, unless it's been explicitly
> assigned to. This is what was previously relied on. Unfortunately, using
> "_" for a dummy variable is a common Python idiom (e.g. "for _ in
> range(10)"), and if used would break all subsequent Python session
> blocks. So we no longer rely on "_".


> In the standard Python interpreter, we can also use "__builtins__._",
> but this doesn't work in IPython. Furthermore, this only works for code

explicitly entered in the shell, it won't work for code executed in
> "exec()" or "eval()", which we now rely on, because it handles
> indentation much more robustly. In particular, ob-python sessions have
> had longstanding issues with multiline indented blocks, which are now
> solved in the recent patches.
>


Re: [PATCH] (Tiny) Tweak Python session null return value

2020-02-17 Thread John Kitchin
I can see why you would want to see True/False there, but to get the value,
you need to specifically return what you want because AFAIK the body is
wrapped in a function that is evaluated to get the value, it is not simply
the last thing that gets evaluated. Your example clarified to me at least
why it would be tricky to figure it out, you can't rely on the last line,
for example. I don't know if there is some special Python variable that
contains that.

It is also a little strange to me to put return specifically in like this:

#+begin_src python :session :results value
  if some_condition:
  a = True
  else:
  a = False
return a
#+end_src

or:

#+BEGIN_SRC python :results value
a = 1
return True if a else False
#+END_SRC

#+RESULTS:
: True

because it is not valid syntax in a script (try it with :results output),
but this is how it has been for ob-python all along when what you want is
the value returned.

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 Mon, Feb 17, 2020 at 2:06 PM Jack Kamm  wrote:

> Hi John,
>
> John Kitchin  writes:
>
> > I think None is correct. If you don't specify a return value in Python,
> > then a function returns None. I would expect that to happen in a Python
> > block too.
>
> Hmm, OK, thanks for your intuition, it's useful feedback.
>
> Working this out loud, I was considering the following sort of block:
>
> #+begin_src python :session :results value
>   if some_condition:
>   True
>   else:
>   False
> #+end_src
>
> #+RESULTS:
> : None
>
> Ideally, it would return True/False, but the current implementation
> cannot grab that result unfortunately. (In its defense, it at least
> doesn't crash like it did before).
>
> I was thinking not printing anything at all under "#+RESULTS" would be
> less surprising than printing "None". But both are admittedly surprising
> at first.
>
> I agree your preference of returning "None" is the more technically
> consistent behavior though.
>
> I don't want to rush a decision now, I think I need to gather more user
> feedback after the 9.4 release. I'll ask Bastien to revert that commit
> and put this off to 9.5, rather than writing an updated NEWS entry like
> he asked.
>
> Either way, we'll need to update Worg to clearly document what's going
> on here.
>


Re: [PATCH] (Tiny) Tweak Python session null return value

2020-02-17 Thread John Kitchin
I think None is correct. If you don't specify a return value in Python,
then a function returns None. I would expect that to happen in a Python
block too.


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 Mon, Feb 17, 2020 at 11:25 AM Jack Kamm  wrote:

> Hi,
>
> Below is a very small patch to Python session blocks, to make them
> return a blank result (empty string) instead of None when there is no
> return value.
>
> Normally I would push this myself, but since we are so close to 9.4, I
> thought it prudent to mail a patch and let the maintainers handle it. It
> would be nice to include in 9.4, but not a big deal if I've missed the
> window.
>
> Now for an explanation of the patch: 9.4 changes Python session blocks
> to fix several bugs and improve robustness overall [0]. However, there
> is a cost to these fixes, which is that the session blocks can only
> return a result when it is a top-level expression on the last line of
> the block. If the last line is not a top-level expression, the block
> would previously print "None". However, after some testing, I think this
> is a little counter-intuitive, and it would be better if it returned a
> blank (empty) result instead of "None".
>
> [0] https://lists.gnu.org/archive/html/emacs-orgmode/2020-01/msg00190.html
>
> Best,
> Jack
>
>
>


Re: org link to OCaml comment

2020-02-06 Thread John Kitchin
I think you need to do it like this:


#+BEGIN_SRC test.ml -r

(* Object projection functions  *) (ref:opf)


#+END_SRC


[[file:2020-02-05.org::(opf)]]

The -r in the header removes the coderef when you run it.

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 Thu, Feb 6, 2020 at 9:48 AM Alan Schmitt 
wrote:

> Hello,
>
> I'm trying to create an org link to a specific place in an OCaml file. I
> thought I would use some specific target in an OCaml comment, but it
> does not work.
>
> Here is an OCaml comment:
>
> (* Object projection functions *)
>
> Here is the link create by `org-store-link` (I put it here with no
> description)
>
> [[file:~/work/jsexplain/jsexplain/jsref/JsSyntax.ml::(* Object projection
> functions *)]]
>
> When I try to follow this link, I get the following error (note the
> missing parentheses):
>
> org-open-file: No match for coderef: * Object projection functions *
>
> and I am moved to the top of the file (instead of where I stored the
> link).
>
> Is there an escape problem here? And if so, is it a bug of
> `org-store-link` of not doing the escaping?
>
> Thanks,
>
> Alan
>
>


Re: getting item information in an export filter?

2020-02-03 Thread John Kitchin
Thanks Nicolas!

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 Mon, Feb 3, 2020 at 11:26 AM Nicolas Goaziou 
wrote:

> Hello,
>
> John Kitchin  writes:
>
> > In
> >
> https://emacs.stackexchange.com/questions/55231/org-mode-export-html-add-name-attirbute-to-checkbox-input
> >
> > there was a question about modifying a checkbox export. I wrote an answer
> > using a custom translate function in a derived backend, where I could get
> > the name of the parent list pretty easily.
> >
> > It seems like that should also be possible in a filter, but I don't
> > understand how to find the parent list in that case. I think it is buried
> > in the info.
> >
> > Is there a general way to get to the org-element information for
> something
> > in an export filter function?
>
> No, there's no simple way to access the element. Filters, with a few
> exceptions, are meant to operate on strings, not on the parse tree. They
> are usual meant as a simple way to transform the output. I.e., they are
> intentionally dumbed down.
>
> You could however, use the parse-tree filter to modify the parse tree
> before export.
>
> Regards,
>
> --
> Nicolas Goaziou
>


getting item information in an export filter?

2020-02-03 Thread John Kitchin
In
https://emacs.stackexchange.com/questions/55231/org-mode-export-html-add-name-attirbute-to-checkbox-input

there was a question about modifying a checkbox export. I wrote an answer
using a custom translate function in a derived backend, where I could get
the name of the parent list pretty easily.

It seems like that should also be possible in a filter, but I don't
understand how to find the parent list in that case. I think it is buried
in the info.

Is there a general way to get to the org-element information for something
in an export filter function?

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: Templating of PDF export

2020-02-03 Thread John Kitchin
I don't know of a nice Jinja like template for this.

I think what you need is a custom exporter. You can define template
function that is responsible for the latex source. In this function you
would check for the attachment, scale it as you want, and insert the
figure code in the latex source where you want it.

I have defined a template function for a memo that you might find some
inspiration from, you can see it at.

https://github.com/jkitchin/scimax/blob/master/ox-cmu/ox-cmu-memo.el

I guess somewhere around line 91 is where you would put the code to
insert attachments.

Yours might be quite a bit simpler if you don't need file keywords for
information.

Now that I am looking at this, you could use something like s-format or
mustache to get a reasonable template. I just used concat for the most
part. The trick would be finding the template system where escaping
characters wasn't too tedious, you already have to escape some things in
the template.



Florian Lindner  writes:

> Hello,
>
> I am collecting my cooking recipes in an org-mode file. While that
> certainly works for, I would like to have a nice LaTeX export for
> non-nerd mortals to look at. All recipes are in one file and each one
> looks like:
>
> * Pancakes
> ** Ingredients
> + 6 Eggs
> + 3 Apples
> ** Directions
> Just do it!
> ** Source
> My mother
>
> Sometimes I take a photo of the meal and ATTACH it.
>
> Most guides how to customize org export are about modifying the document
> class and latex snippets there there. However, the basic association
> with * Pancakes -> \section, ** Ingredients -> \subsection stays the same.
>
> Is there something builtin org-mode which allows to use a templating
> language that allows for a more freely combination of elements, similar
> to Jinja or alike?
>
> For example, I want to embed the attachment in the export, appropriately
> scaled and nicely placed and have a line break after each recipe.
>
> I know about org-chef, but AFAIK it's more about importing templates
> from websites, not about a nice export.
>
> Any ideas for that?
>
> Thanks!
> Florian


--
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: org table integrity

2020-02-02 Thread John Kitchin
This is a little tricky to guarantee; there are just so many ways to edit a
table.

One way to do this is like the following. The idea is to use the
org-cycle-hook to check the last cell you were in when you pressed TAB in a
table. This of course does not work if you don't use tab, and in its
current form does not work on shift-tab.  You set an #+attr_org line to
have list of predicate functions for each column. stringp is tricky, all
the cells are strings, so I tried a regexp for numbers. numberp is also not
quite right, for me "1a" converts to 1. This code is pretty lightly tested,
so tread warily!

I had to add the advice for some reason. I don't know why, but it appears
to me the org-cycle-hook does not get run inside org-cycle. I don't think
this should be necessary, but it was to test this out.

Here is the code. After you run it, each time you tab through the table,
you should see some messages telling you what was tested, and some of them
should cause an error with a message about it.

#+BEGIN_SRC emacs-lisp
(defun org-timestamp-p (contents)
  "Return non-nil if CONTENTS is a legal org timestamp"
  (with-temp-buffer
(insert contents)
(goto-char (point-min))
(re-search-forward org-element--timestamp-regexp nil t)))

(defun check-table-integrity (_state)
  (interactive)
  ;; get previous contents
  (let* ((column)
(element (org-element-context))
(attr)
(funcs)
(field)
(valid))

(while (and (org-at-table-p) (not (eq 'table (car element)))
(setq element (org-element-property :parent element

(when (eq 'table (car element))

  (setq attr (car (org-element-property :attr_org element))
   funcs (plist-get (read (format "(%s)" attr)) :types))

  (save-excursion
(org-table-previous-field)
(setq column (org-table-current-column)
 func (nth (- column 1) funcs)
 field (org-table-get-field)
 valid (funcall (eval func) (s-trim field)))

(message "checking %s field with %s" field func)

;; this is a little tricky. valid is non-nil, and 0 is considered non-nil
(unless valid
 (error "%s did not pass %s" field func))


(add-hook 'org-cycle-hook 'check-table-integrity)

(advice-add 'org-cycle :after (lambda (x) (cl-loop for func in
org-cycle-hook
  do (funcall func ""
#+END_SRC

#+RESULTS:

#+attr_org: :types ('org-timestamp-p (lambda (x) (string-match-p "[0-9]+"
x)) 'stringp)
| [2020-02-02 Sun] |  1 | no  |
| [2020-02-09 Sun] | no | yes |
| not a ts |  3 | 3   |

An alternative way to do this might be to have a function that runs when
you leave a table, then it could validate the cells in a similar way. The
easy way to do this is with a post-command hook, but this is hard to do
without performance hits. The harder way to do it is with cursor sensor
functions, but this requires a hack on font-lock for tables. A final way is
to make a save/kill-buffer hook function that would map over each table and
validate them before allowing the save/kill to complete.



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, Feb 1, 2020 at 9:09 PM Jude DaShiell  wrote:

> Does a way exist in orgmode to fix a column so that it only stores time
> stamps?  A table I'm using has two columns that could this kind of error
> protection and two that should contain text.
>
>
>
> --
>
>
>


Re: equal syntax highlighting for publishing code blocks to html and pdf

2020-02-01 Thread John Kitchin
My guess is you have two options:

1. Customize the colors in minted to match what is on your screen. I am
pretty sure that code in html looks very much like what is on your screen.
This might be an entry point to customizing minted style.
https://tex.stackexchange.com/questions/131456/customize-comment-color-in-minted-style

2. Customize the faces emacs uses for syntax highlighting to match the look
in minted.

either way, I don't see a simple way to have a common theme between them,
and they will probably always have some minor differences. It might be
easier to hack a new exporter for src blocks that turns the htmlized code
into latex markup perhaps.

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, Feb 1, 2020 at 4:28 AM Bastien  wrote:

> Hi Johannes,
>
> Johannes Brauer  writes:
>
> > Frequently I publish org-mode documents containing source code blocks
> > to html (htmlize) and pdf (minted). I would like to see the same
> > colors in both export types. But
> > I cannot figure out, what’s the best way to achieve this.
> >
> > Has anyone solved this problem? Are there any hints?
>
> I don't know how to do this and I guess it's difficult.
>
> If you find a solution, please mention it here, others may be
> interested.
>
> Thanks!
>
> --
>  Bastien
>
>


special treatment of one org-file in org-publish

2020-01-28 Thread John Kitchin
Hi everyone,

I have one org file I have to publish in a special way in an org-publish
project. I have this sub-component setup as:

  ("references"
 :base-directory "/Users/jkitchin/2020/01/26/org-files/"
 :exclude "org"
 :include ("c.org")
 :publishing-directory "docs"
 :publishing-function ox-manuscript-publish-references)

This seems to ignore all org files, except the one I included, and on that
one it runs the special publishing-function.

Is the version above preferable to:

  ("references"
 :base-directory "/Users/jkitchin/2020/01/26/org-files/"
 :base-extension "[^.*]"
 :include ("c.org")
 :publishing-directory "docs"
 :publishing-function ox-manuscript-publish-references)

They both seem to work.

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: Testimony on how to publish a book using Org-mode

2020-01-27 Thread John Kitchin
This sounds pretty interesting. I have been thinking for a while about a
setup for scientific publishing with org-mode. I am curious to learn
more about what they have setup. I will probably spend some time this
spring updating how I do this kind of thing myself.

Bastien  writes:

> Dear all,
>
> I recently met the authors of this book, entirely publish using
> Org-mode: https://ima.circex.org/storie/0-intro/index.html
>
> They explain how they do this here:
> https://ima.circex.org/vulgo_en.html
>
> I thought it might be of interest for those hackers who want to
> dive in and try publishing large texts with Org-mode.
>
> Please send me a private email if you want to get in touch with
> one of the author for details on their setup.
>
> Enjoy!


--
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: emacs build command for org-files

2020-01-27 Thread John Kitchin
that is also interesting to know, thanks!

Jack Kamm  writes:

> John Kitchin  writes:
>
>> If there was a lispy version of make that made this possible, I would
>> use it.
>
> This is an aside, but GNU Make can use Guile Scheme as an embedded
> extension language:
>
> https://www.gnu.org/software/make/manual/html_node/Guile-Integration.html
>
> I don't think this solves any issues in this thread, but I think it's
> pretty neat, and might scratch your itch if you're looking for a lispy
> make.


--
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: emacs build command for org-files

2020-01-27 Thread John Kitchin
navigate to function
definitions, and to debug and step through the code. This makes this
approach so superior to anything else in my opinion, it is hard to argue
any other feature of make/shell is worth giving it up for. I will
concede this is just a better tooling argument though, but these tools
do not exist as far as I know in a shell. You might get tab-completion,
but not easy access to documentation and code. If there was a lispy
version of make that made this possible, I would use it.

Anyway, I am not arguing make is not good for what it does. It is fine
for that. It isn't what I want to use for this though.

>
> Have you looked into emacs-lisp shell--i.e. the "eshell"?
>
> --and I believe you can call the "eshell" in batch mode from a shell
> command--and the "eshell" can execute emacs lisp functions of course
>
> --and you can even do all that from the Python interactive shell if you
> like--and call remote shells from it and/or use "IPython"
> https://en.wikipedia.org/wiki/IPython
>
>
>
>
>
> On Sun, Jan 26, 2020 at 2:38 PM briangpowell . 
> wrote:
>
>> "don't want it to necessarily use Makefiles"
>>
>> Why the hey not Dr. Kitchin!?
>>
>> Make is an extremely powerful language
>>
>> Problem is people make makefiles that are often hard for others to
>> read--suggest you try hard to keep it simple & avoid the fancy ways of
>> doing things
>>
>> Make has flow control & is a very rich language
>>
>> I use makefiles for every project Then Ccc to compile and/or run
>> everything--in Emacs--can't get easier and faster than that--as long as you
>> make the makefiles so easy that anyone can read & understand exactly what
>> it does
>>
>> This is my default, which I may edit on-the-fly and just put in another
>> project name:
>>
>> make --ignore-errors --jobs=555 -w --keep-going --warn-undefined-variables
>> --environment-overrides -f ~/n/n/etc/1cv2tex2doc-project_mak.makefile
>> 1cv2tex2doc-project-exe
>>
>> All slightly interesting ways to improve make have failed slightly, in one
>> way or another--they catch on for a few years until they're mostly
>> abandoned--for very good reasons
>>
>> Look at it this way: Is there anything wrong with make?  Where does it
>> fail?
>>
>> Everyone should learn & use make
>>
>> --Brian G. Powell, M.S.--that guy that still loves Makefiles and still
>> loves using asterisks ("***") as bullets in OrgMode
>>
>> On Sun, Jan 26, 2020 at 1:11 PM John Kitchin 
>> wrote:
>>
>>> Hi everyone,
>>>
>>> This is only semi-on-topic. I am looking for something like M-x compile
>>> for my org-files, but I don't want it to necessarily use Makefiles. I am
>>> looking for suggestions of existing solutions to this, or thoughts on how
>>> to implement this.
>>>
>>> Actually, if it was possible to get M-x compile to run an elisp function
>>> instead of a make file, it might be all I need, but it looks like it runs
>>> shell commands.
>>>
>>> For most of my files, simple exporting is totally adequate. But, some
>>> files are more complicated, and what I usually do in these cases is write
>>> an elisp code block in a section that is tagged :noexport: and then I run
>>> that block to build the result. A recent example was a proposal where I
>>> needed a pdf of the body, and separate pdf of the references.
>>>
>>> I have separate elisp functions that generate these, and then I added
>>> some custom cleanup code in the block to delete some intermediate
>>> directories. I don't want to put these in a makefile because they are
>>> specific to this document. While this works, in a large document I find it
>>> a little inconvenient to make a small change say at the top, and then to
>>> jump to the bottom to run the build block to see how it changed. What I
>>> would prefer is to just run a command like M-x org-compile that would know
>>> about this build block and run it. That block could of course be a shell
>>> block that runs a makefile, but it would most often be an elisp block. I
>>> could even imagine that there is a makefile block that is tangled before
>>> running a shell block that runs a make command.
>>>
>>> What I do in a function now is something like this in a save-excursion:
>>>
>>> (when (not (stringp (org-babel-goto-named-src-block "build")))
>>>   (org-babel-execute-src-block))
>>>
>>> I don't use this in the

Re: emacs build command for org-files

2020-01-27 Thread John Kitchin


Stefan Nobis  writes:

> John Kitchin  writes:
>
>> Hi everyone,
>
>> This is only semi-on-topic. I am looking for something like M-x compile for
>> my org-files, but I don't want it to necessarily use Makefiles. I am
>> looking for suggestions of existing solutions to this, or thoughts on how
>> to implement this.
>
> This may not be the solution you are looking for, but maybe a good
> source of ideas:
>
>https://github.com/doublep/eldev

Thanks for this tip. This is the kind of thing I was hoping this thread
would unearth. This seems kind of like rake from ruby, where the build
scripts are written in the language you are building from. That is more
aligned with what I am trying to do here.

>
> Another idea: Just use a (configurable) function name or source block
> name to look for in a document. Then some magic function (say
> org-compile-document) can look for a custom function/block inside the
> document (e.g. look for a marked source block) and execute it, if
> found. If no custom function/block is found, some default action will
> be executed (e.g. ask user what to do, run pre-configured default
> export action etc.).

This is what I do now. I thought (hoped?) maybe someone else had worked
out something similar, and had a better idea.


--
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: emacs build command for org-files

2020-01-27 Thread John Kitchin


Neil Jerram  writes:

> On Sun, 26 Jan 2020 at 18:11, John Kitchin  wrote:
>
>> Hi everyone,
>>
>> This is only semi-on-topic. I am looking for something like M-x compile
>> for my org-files, but I don't want it to necessarily use Makefiles. I am
>> looking for suggestions of existing solutions to this, or thoughts on how
>> to implement this.
>>
>> Actually, if it was possible to get M-x compile to run an elisp function
>> instead of a make file, it might be all I need, but it looks like it runs
>> shell commands.
>>
>
> So how about typing "M-: " instead of "M-x compile" ?  Why involve
> other layers when Emacs can directly evaluate elisp?

It is just a reflection of how long some of the build blocks are. They
frequently let-bind variables and functions to achieve some particular
goal for the specific project. Since it is a one-time block, I don't
usually make it a function, and the code exists in a src block. "M-:"
isn't convenient for me in this scenario.

>
> Best wishes,
> Neil


--
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: emacs build command for org-files

2020-01-26 Thread John Kitchin
On Sun, Jan 26, 2020 at 2:39 PM briangpowell . 
wrote:

> "don't want it to necessarily use Makefiles"
>
> Why the hey not Dr. Kitchin!?
>

1. I like all the build code in one file that also contains the document I
am building. I know I could put a makefile in a src block and tangle it
before running it, but make is not meeting my needs for this.
2. all the build code is mostly written in elisp
3. my emacs startup is slow and I don't use emacsclient so sequential build
commands that launch emacs with shell arguments are too slow compared to
the build sequences in src blocks.


>
> Make is an extremely powerful language
>

It is not as easy or readable for me to use as elisp, and probably not as
powerful. I don't like powerful programming in shell (or make) languages, I
prefer to do that in something like elisp or python where I my skills are
more developed and I have better tools for debugging.


>
> Problem is people make makefiles that are often hard for others to
> read--suggest you try hard to keep it simple & avoid the fancy ways of
> doing things
>

Sometimes you have fancy needs that require fancy ways of doing things.


>
> Make has flow control & is a very rich language
>

I don't really need flow control for this need.


> I use makefiles for every project Then Ccc to compile and/or run
> everything--in Emacs--can't get easier and faster than that--as long as you
> make the makefiles so easy that anyone can read & understand exactly what
> it does
>

When they are this easy, it is nearly equivalent to simply publishing the
org file to the target, so I am C-c C-e lo away from what I want.


>
> This is my default, which I may edit on-the-fly and just put in another
> project name:
>
> make --ignore-errors --jobs=555 -w --keep-going --warn-undefined-variables
> --environment-overrides -f ~/n/n/etc/1cv2tex2doc-project_mak.makefile
> 1cv2tex2doc-project-exe
>

This is exactly the kind of command I might put in a build source block. I
suppose you might save that as a file local variable so you can just M-x
compile away though.


>
> All slightly interesting ways to improve make have failed slightly, in one
> way or another--they catch on for a few years until they're mostly
> abandoned--for very good reasons
>
> Look at it this way: Is there anything wrong with make?  Where does it
> fail?
>

Make is perfectly fine for sequences of shell commands that operate on
files. With straight latex projects, make would be my goto.  With my org
files though, it is not a straight export to latex and carry on approach I
use. So, I am looking for something that is more aligned with sequences of
elisp commands on a buffer, and not in an asynchronous way. These command
sequences are usually customized on a per document basis, otherwise I would
already have wrapped them up into general export commands.


>
> Everyone should learn & use make
>

I know how to use make, and I don't like it for this purpose. The src
blocks serve my needs just fine, I am just looking for an easier way to
call them in large documents.


>
> --Brian G. Powell, M.S.--that guy that still loves Makefiles and still
> loves using asterisks ("***") as bullets in OrgMode
>
> On Sun, Jan 26, 2020 at 1:11 PM John Kitchin 
> wrote:
>
>> Hi everyone,
>>
>> This is only semi-on-topic. I am looking for something like M-x compile
>> for my org-files, but I don't want it to necessarily use Makefiles. I am
>> looking for suggestions of existing solutions to this, or thoughts on how
>> to implement this.
>>
>> Actually, if it was possible to get M-x compile to run an elisp function
>> instead of a make file, it might be all I need, but it looks like it runs
>> shell commands.
>>
>> For most of my files, simple exporting is totally adequate. But, some
>> files are more complicated, and what I usually do in these cases is write
>> an elisp code block in a section that is tagged :noexport: and then I run
>> that block to build the result. A recent example was a proposal where I
>> needed a pdf of the body, and separate pdf of the references.
>>
>> I have separate elisp functions that generate these, and then I added
>> some custom cleanup code in the block to delete some intermediate
>> directories. I don't want to put these in a makefile because they are
>> specific to this document. While this works, in a large document I find it
>> a little inconvenient to make a small change say at the top, and then to
>> jump to the bottom to run the build block to see how it changed. What I
>> would prefer is to just run a command like M-x org-compile that would know
>> about this build block and run it. That block could of course be a shell
>>

emacs build command for org-files

2020-01-26 Thread John Kitchin
Hi everyone,

This is only semi-on-topic. I am looking for something like M-x compile for
my org-files, but I don't want it to necessarily use Makefiles. I am
looking for suggestions of existing solutions to this, or thoughts on how
to implement this.

Actually, if it was possible to get M-x compile to run an elisp function
instead of a make file, it might be all I need, but it looks like it runs
shell commands.

For most of my files, simple exporting is totally adequate. But, some files
are more complicated, and what I usually do in these cases is write an
elisp code block in a section that is tagged :noexport: and then I run that
block to build the result. A recent example was a proposal where I needed a
pdf of the body, and separate pdf of the references.

I have separate elisp functions that generate these, and then I added some
custom cleanup code in the block to delete some intermediate directories. I
don't want to put these in a makefile because they are specific to this
document. While this works, in a large document I find it a little
inconvenient to make a small change say at the top, and then to jump to the
bottom to run the build block to see how it changed. What I would prefer is
to just run a command like M-x org-compile that would know about this build
block and run it. That block could of course be a shell block that runs a
makefile, but it would most often be an elisp block. I could even imagine
that there is a makefile block that is tangled before running a shell block
that runs a make command.

What I do in a function now is something like this in a save-excursion:

(when (not (stringp (org-babel-goto-named-src-block "build")))
  (org-babel-execute-src-block))

I don't use this in these projects, but they highlight some of the
complexities I am trying to simplify. These are book like projects with
special formatting needs, and multiple outputs.

In this project (
https://github.com/jkitchin/pycse/blob/master/pycse.org#L15096), I have
multiple output targets that I would run.

In this project (
https://github.com/jkitchin/dft-book/blob/master/dft.org#build) I use some
temporary filters to save the src blocks to files, and to embed them in the
pdf so they can be opened.

Anyway, it feels like I am reinventing something here, and that there might
be some better approach already out there. Maybe some elisp equivalent of a
makefile or something?

Thoughts?

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: preview src blocks that generate image files

2020-01-26 Thread John Kitchin
How would you handle source blocks that generate many figures? In iPython,
for example this happens pretty easily. I guess you are thinking about
blocks with a :file output or something though?

Once a preview was on it, would you have to C-c C-x C-v to toggle it off to
edit it? I have explored a few different approaches with latex fragments,
like clicking on it would turn the preview off, or entering it to turn it
off.

What would trigger putting the image preview on? Running C-c C-c on a
block? something more manual?

I guess you have a use case where this makes sense, but you can already see
an image preview on a link output, and there are ways to have the source
blocks be in other places in a document than where the results are.

Maybe for some src blocks like graphiz, or gnuplot where they more or less
only produce one graphic this idea could be a good one.

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 Sun, Jan 26, 2020 at 3:11 AM Matt Huszagh  wrote:

> Hi,
>
> I'm considering adding the ability to display an image preview overlay of
> source blocks that generate an image file, much in the same way that
> latex fragments can be previewed.
>
> Is anyone else interested in this feature? Any general thoughts/feature
> requests?
>
> Matt
>
>


Re: Org-ref issues

2020-01-25 Thread John Kitchin
That function should be defined in org-ref-core.el. If it is not there,
then probably something has gone wrong in the update, or you are somehow
loading a very old version of org-ref.

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, Jan 24, 2020 at 9:13 PM Marvin M. Doyley 
wrote:

> Hi there,
>
> I just upload org-ref on my system via melpa and get the following error
> when I issue the command doi-utils-add-bibtex-entry-from-doi
>
> Symbol’s function definition is void: org-ref-possible-bibfiles
>
>
> Does anybody know how to resolve this
>
> Thanks
>
> M
>
> Here is the backtrace
>
> Debugger entered--Lisp error: (void-function org-ref-possible-bibfiles)
>   org-ref-possible-bibfiles()
>   doi-utils-add-bibtex-entry-from-doi("10.1109/TUFFC.2019.2961875")
>   funcall-interactively(doi-utils-add-bibtex-entry-from-doi
> "10.1109/TUFFC.2019.2961875")
>   call-interactively(doi-utils-add-bibtex-entry-from-doi record nil)
>   command-execute(doi-utils-add-bibtex-entry-from-doi record)
>   helm-M-x-execute-command(doi-utils-add-bibtex-entry-from-doi)
>   helm-execute-selection-action-1()
>   helm-execute-selection-action()
>   helm-internalname . "Emacs Commands history") (candidates .
> #f(compiled-function () #)) (keymap keymap (keymap (13
> . helm-confirm-and-exit-minibuffer)) keymap (21 .
> helm-M-x-universal-argument) keymap (127 . delete-backward-char) (27 keymap
> (13 . helm-cr-empty-string)) (C-return . helm-cr-empty-string) keymap (tab
> . helm-execute-persistent-action) (26 . helm-select-action) (f13 lambda nil
> (interactive) (helm-select-nth-action 12)) (f12 lambda nil (interactive)
> (helm-select-nth-action 11)) (f11 lambda nil (interactive)
> (helm-select-nth-action 10)) (f10 lambda nil (interactive)
> (helm-select-nth-action 9)) (f9 lambda nil (interactive)
> (helm-select-nth-action 8)) (f8 lambda nil (interactive)
> (helm-select-nth-action 7)) (f7 lambda nil (interactive)
> (helm-select-nth-action 6)) (f6 lambda nil (interactive)
> (helm-select-nth-action 5)) (f5 lambda nil (interactive)
> (helm-select-nth-action 4)) (f4 lambda nil (interactive)
> (helm-select-nth-action 3)) (f3 lambda nil (interactive)
> (helm-select-nth-action 2)) (f2 lambda nil (interactive)
> (helm-select-nth-action 1)) (menu-bar keymap (help-menu keymap (describe
> keymap (describe-mode . helm-help (help keymap (109 . helm-help)) (23 .
> #f(compiled-function () (interactive nil) #)) (f1
> lambda nil (interactive) (helm-select-nth-action 0)) (8 keymap (109 .
> helm-help) (104 . undefined) (8 . undefined) (99 . helm-customize-group) (4
> . helm-enable-or-switch-to-debug)) (20 .
> helm-toggle-resplit-and-swap-windows) (C-tab . undefined) (67108897 .
> helm-toggle-suspend-update) (3 keymap (57 .
> helm-execute-selection-action-at-nth-+9) (56 .
> helm-execute-selection-action-at-nth-+8) (55 .
> helm-execute-selection-action-at-nth-+7) (54 .
> helm-execute-selection-action-at-nth-+6) (53 .
> helm-execute-selection-action-at-nth-+5) (52 .
> helm-execute-selection-action-at-nth-+4) (51 .
> helm-execute-selection-action-at-nth-+3) (50 .
> helm-execute-selection-action-at-nth-+2) (49 .
> helm-execute-selection-action-at-nth-+1) (63 . helm-help) (110 .
> #f(compiled-function () (interactive nil) #)) (108 .
> helm-display-line-numbers-mode) (62 . helm-toggle-truncate-line) (21 .
> helm-refresh) (6 . helm-follow-mode) (9 . helm-copy-to-buffer) (11 .
> helm-kill-selection-and-quit) (25 . helm-yank-selection) (37 .
> helm-exchange-minibuffer-and-header-line) (95 . helm-toggle-full-frame) (45
> . helm-swap-windows)) (67108987 . helm-enlarge-window) (67108989 .
> helm-narrow-window) (19 . undefined) (24 keymap (57 .
> helm-execute-selection-action-at-nth-+9) (56 .
> helm-execute-selection-action-at-nth-+8) (55 .
> helm-execute-selection-action-at-nth-+7) (54 .
> helm-execute-selection-action-at-nth-+6) (53 .
> helm-execute-selection-action-at-nth-+5) (52 . helm-select-4rd-action) (51
> . helm-select-3rd-action) (50 . helm-select-2nd-action) (49 .
> helm-execute-selection-action-at-nth-+1) (2 .
> helm-resume-list-buffers-after-quit) (98 .
> helm-resume-previous-session-after-quit) (6 . helm-quit-and-find-file)) (11
> . helm-delete-minibuffer-contents) (67108896 . helm-toggle-visible-mark) (0
> . helm-toggle-visible-mark) (C-M-up . helm-scroll-other-window-down)
> (C-M-down . helm-scroll-other-window) (M-prior .
> helm-scroll-other-window-down) (M-next . helm-scroll-other-window) (12 .
> helm-recenter-top-bottom-other-window) (15 . helm-next-source) (10 .
> helm-execute

Re: Latex export: setting options for packages included by default

2020-01-23 Thread John Kitchin
Is this package listed in org-latex-default-packages-alist?

If so, you might try something like:

#+BEGIN_SRC emacs-lisp
(let ((org-latex-default-packages-alist org-latex-default-packages-alist))
  (setf (nth (seq-position org-latex-default-packages-alist "color"
   (lambda (a b) (string= b (nth 1 a
 org-latex-default-packages-alist)
'("monochrome" "color" nil))
  (org-latex-export-to-pdf))
#+END_SRC

I think that would be a temporary modification just for the export.

Alternatively, you might define a new latex class like this:

(add-to-list 'org-latex-classes
 '("article-monochrome"
   "\\documentclass{article}
\\PassOptionsToPackage{monochrome}{color}
 [DEFAULT-PACKAGES]
 [PACKAGES]
 [EXTRA]"
   ("\\section{%s}" . "\\section*{%s}")
   ("\\subsection{%s}" . "\\subsection*{%s}")
   ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
   ("\\paragraph{%s}" . "\\paragraph*{%s}")
   ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))

and then specify #+LATEX_CLASS: article-monochrome in the org-file.

Jarmo Hurri  writes:

> Greetings.
>
> When I export to Latex, org automatically creates the following line in
> preamble:
>
> \usepackage{color}
>
> I would like to find a way to pass option [monochrome] to this
> package. Adding another \usepackage creates a conflict. My preferred way
> would be to add the line
>
> \PassOptionsToPackage{monochrome}{color}
>
> to the preamble before \usepackage.
>
> 1. Is there a way to do this (easily) in Org? I think it is possible to
>redefine the preamble template, but that would be an overkill.
>
> 2. If there is no direct option for this, could we have one? Like
>#+latex_header but which would be applied before any packages are
>loaded?
>
> Jarmo


--
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: Org-ref error

2020-01-22 Thread John Kitchin
that is strange. I was able to reproduce it a few times, but now it works
fine. all within a few minutes of trying to debug it.

This makes me think something was not right in the request or reply.

json-read-from-string("\n\015\n400 The plain HTTP
request was sent to HTTPS
port\015\n\015\n400 Bad
Request\015\nThe plain HTTP request was sent to HTTPS
port\015\ncloudflare\015\n\015\n\015\n")

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 Wed, Jan 22, 2020 at 8:08 PM Doyley, Marvin M. 
wrote:

> -Hi Everybody,
>
> For some reason, I keep getting an error (JSON readable error: 60)
> whenever I try to  add a BibTex entry to a BibTex file using
> doi-utils-add-bibtex-entry-from-doi. I would appreciate if someone could
> tell me how to resolve this problem.
>
> Best Wishes,
> M
>
> Here is the backtrace that I got when I execute the command.
>
>  Debugger entered--Lisp error: (json-readtable-error 60)
>   signal(json-readtable-error (60))
>   json-read()
>   json-read-from-string("\n\015\n400 The plain HTTP
> request was sent to HTTPS
> port\015\n\015\n400 Bad
> Request\015\nThe plain HTTP request was sent to HTTPS
> port\015\ncloudflare\015\n\015\n\015\n")
>   doi-utils-get-json-metadata("10.1109/TUFFC.2019.2961875")
>   doi-utils-doi-to-bibtex-string("10.1109/TUFFC.2019.2961875")
>   doi-utils-insert-bibtex-entry-from-doi("10.1109/TUFFC.2019.2961875")
>   doi-utils-add-bibtex-entry-from-doi("10.1109/TUFFC.2019.2961875")
>   funcall-interactively(doi-utils-add-bibtex-entry-from-doi
> "10.1109/TUFFC.2019.2961875")
>   call-interactively(doi-utils-add-bibtex-entry-from-doi record nil)
>   command-execute(doi-utils-add-bibtex-entry-from-doi record)
>   helm-M-x-execute-command(doi-utils-add-bibtex-entry-from-doi)
>   helm-execute-selection-action-1()
>   helm-execute-selection-action()
>   helm-internalname . "Emacs Commands history") (candidates .
> #f(compiled-function () #)) (keymap keymap (keymap (13
> . helm-confirm-and-exit-minibuffer)) keymap (21 .
> helm-M-x-universal-argument) keymap (127 . delete-backward-char) (27 keymap
> (13 . helm-cr-empty-string)) (C-return . helm-cr-empty-string) keymap (tab
> . helm-execute-persistent-action) (26 . helm-select-action) (f13 lambda nil
> (interactive) (helm-select-nth-action 12)) (f12 lambda nil (interactive)
> (helm-select-nth-action 11)) (f11 lambda nil (interactive)
> (helm-select-nth-action 10)) (f10 lambda nil (interactive)
> (helm-select-nth-action 9)) (f9 lambda nil (interactive)
> (helm-select-nth-action 8)) (f8 lambda nil (interactive)
> (helm-select-nth-action 7)) (f7 lambda nil (interactive)
> (helm-select-nth-action 6)) (f6 lambda nil (interactive)
> (helm-select-nth-action 5)) (f5 lambda nil (interactive)
> (helm-select-nth-action 4)) (f4 lambda nil (interactive)
> (helm-select-nth-action 3)) (f3 lambda nil (interactive)
> (helm-select-nth-action 2)) (f2 lambda nil (interactive)
> (helm-select-nth-action 1)) (menu-bar keymap (help-menu keymap (describe
> keymap (describe-mode . helm-help (help keymap (109 . helm-help)) (23 .
> evil-delete-backward-word) (f1 lambda nil (interactive)
> (helm-select-nth-action 0)) (8 keymap (109 . helm-help) (104 . undefined)
> (8 . undefined) (99 . helm-customize-group) (4 .
> helm-enable-or-switch-to-debug)) (20 .
> helm-toggle-resplit-and-swap-windows) (C-tab . undefined) (67108897 .
> helm-toggle-suspend-update) (3 keymap (57 .
> helm-execute-selection-action-at-nth-+9) (56 .
> helm-execute-selection-action-at-nth-+8) (55 .
> helm-execute-selection-action-at-nth-+7) (54 .
> helm-execute-selection-action-at-nth-+6) (53 .
> helm-execute-selection-action-at-nth-+5) (52 .
> helm-execute-selection-action-at-nth-+4) (51 .
> helm-execute-selection-action-at-nth-+3) (50 .
> helm-execute-selection-action-at-nth-+2) (49 .
> helm-execute-selection-action-at-nth-+1) (63 . helm-help) (110 .
> #f(compiled-function () (interactive nil) #)) (108 .
> helm-display-line-numbers-mode) (62 . helm-toggle-truncate-line) (21 .
> helm-refresh) (6 . helm-follow-mode) (9 . helm-copy-to-buffer) (11 .
> helm-kill-selection-and-quit) (25 . helm-yank-selection) (37 .
> helm-exchange-minibuffer-and-header-line) (95 . helm-toggle-full-frame) (45
> . helm-swap-windows)) (67108987 . helm-enlarge-window) (67108989 .
> helm-narrow-window) (19 . undefined) (24 keymap (57 .
> helm-execute-selection-action-at-nth-+9) (56 .
> helm-execute-selection-action-at-nth-+8) (55 .
> helm-execute-selection-action-at-nth-+7) (54 .
> helm-execute-selection-action-at-nth-+6

Re: Inline references in noweb?

2020-01-05 Thread John Kitchin
I think this is what you need. I am not sure if you can expand noweb
outside a src block, so I use an inline src block to get this.


#+name: required_date
#+BEGIN_SRC text :exports none
Jan 5, 2020
#+END_SRC

In order to engage the flux capacitor, you must set the
  chronometer dial to src_emacs-lisp[:noweb yes :exports
results]{"<>"} {{{results(=Jan 5\, 2020=)}}}.

#+begin_src conf :noweb yes
date: <>
#+end_src


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 Sun, Jan 5, 2020 at 4:47 AM Norman Walsh  wrote:

> Hello,
>
> I’ve read through most of the docs that turn up with the obvious web
> searches and I haven’t been able to figure this out. However, it seems
> like it should be possible…
>
> I’m quite pleased with how babel and noweb can be used to write
> “literate programs” for configuration files and scripts.
>
> Cross references between code blocks with <> work
> just fine. What I’d like, but can’t work out, is how to refer to, for
> example, a configuration value inline. Something like this:
>
>   In order to engage the flux capacitor, you must set the
>   chronometer dial to ~<>~.
>
>   #+begin_src conf :noweb yes
>   date: <>
>   #+end_src
>
> I don’t care how or where “required_date” is defined, I just want the
> ability to refer to it in the documentation and in code blocks.
>
> Have I overlooked something obvious?
>
> Be seeing you,
>   norm
>
> --
> Norman Walsh  | The stone fell on the pitcher? Woe to
> http://nwalsh.com/| the pitcher. The pitcher fell on the
>   | stone? Woe to the pitcher.--Rabbinic
>   | Saying
>


Re: org-element-context in table.el behavior

2020-01-02 Thread John Kitchin
Ok, thanks for confirming!

Nicolas Goaziou  writes:

> Hello,
>
> John Kitchin  writes:
>
>> I have run into a surprise with org-element-context on a link in a table.el
>> cell. It is best illustrated here:
>>
>> +---++
>> | # | name   |
>> +---++
>> | 1 | [[./test.org]] |
>> +---++
>>
>> #+BEGIN_SRC emacs-lisp :results code
>> (save-excursion
>>   (re-search-backward (concat "test." "org"))
>>   (org-element-context))
>> #+END_SRC
>>
>>
>> #+RESULTS:
>
>> #+begin_src emacs-lisp
>> (table
>>  (:begin 1463 :end 1563 :type table\.el :tblfm nil :contents-begin nil
>> :contents-end nil :value "+---++\n| # | name
>> |\n+---++\n| 1 | [[./test.org]] |\n+---++\n"
>> :post-blank 1 :post-affiliated 1463 :parent nil))
>> #+end_src
>>
>
> [...]
>
>> Is this expected behavior, or a bug?
>
> This is expected: table.el tables, as their name suggest, are opaque to
> Org mode. In particular, it doesn't know how to parse them. It just
> feeds table.el with them at export time.
>
> Regards,


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



  1   2   3   4   5   6   7   8   9   10   >