* parsing of emphasis versus links
@ 2017-03-16 19:48 Eric S Fraga
2017-03-17 19:32 ` John Kitchin
[not found] ` <ddb8a56dba05452a83cf00b9166123bb@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
0 siblings, 2 replies; 3+ messages in thread
From: Eric S Fraga @ 2017-03-16 19:48 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 2095 bytes --]
Hello,
I have been playing with using embedded calc equations in org mode. I
have tried filters and with org emphasis markers but finally have come
around to using the new org link capabilities. Thank you John for
these!
I've defined the following:
#+begin_src emacs-lisp
(org-link-set-parameters
"calc"
:export (lambda (path desc backend)
(cond
((eq 'latex backend)
(format "\\texttt{%s}" desc))))
:face '(:foreground "chartreuse"))
#+end_src
which I then use like this:
#+begin_src org
[[calc:][Pv := 10^(6.886 - 1175.817 / (100 + 224.867)) => 1847.653]]
#+end_src
and with appropriate settings for calc [1], calc can manipulate and
evaluate the expressions. So far, so good.
Two minor issues:
1. the fontification doesn't colour the links in the colour I would like
(chartreuse, #7fff00).
2. if I have two expressions close enough, both with := and =>
operators, org seems to get confused and interprets two of the =
symbols, each from one expression, as emphasis markers, as in this
example:
#+begin_src org
[[calc:][y := 3 x - 5 => 55]] [[calc:][z := sqrt(y) => 7.416]]
#+end_src
Screenshot attached showing both problems: colour and second = sign
disappearing in first link and first = sign in second link.
Any suggestions on how to improve/fix these aspects? Both are minor
presentation issues and everything else is working very well. Calc
allows me to work with these expressions easily in org now!
Many thanks,
eric
Footnotes:
[1] Settings using calc: links:
#+begin_src emacs-lisp
(defun esf/org-mode-calc-settings ()
(setq calc-embedded-open-formula "\\[\\[calc:]\\["
calc-embedded-open-new-formula "[[calc:]["
calc-embedded-close-formula "]]"
calc-embedded-close-new-formula "]]"))
(add-hook 'org-mode-hook #'esf/org-mode-calc-settings)
#+end_src
--
: Eric S Fraga (0xFFFCF67D), Emacs 26.0.50.1, Org release_9.0.5-370-g9f3a02.dirty
[-- Attachment #1.2: screendump-20170316193437.png --]
[-- Type: image/png, Size: 5224 bytes --]
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: parsing of emphasis versus links
2017-03-16 19:48 parsing of emphasis versus links Eric S Fraga
@ 2017-03-17 19:32 ` John Kitchin
[not found] ` <ddb8a56dba05452a83cf00b9166123bb@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
1 sibling, 0 replies; 3+ messages in thread
From: John Kitchin @ 2017-03-17 19:32 UTC (permalink / raw)
To: Eric S Fraga; +Cc: emacs-orgmode
I can not reproduce all the things you report.
I think part of the problem is [calc:]. I have to have at least two
characters of path to get a link that is colored.
Eric S Fraga writes:
> Hello,
>
> I have been playing with using embedded calc equations in org mode. I
> have tried filters and with org emphasis markers but finally have come
> around to using the new org link capabilities. Thank you John for
> these!
>
> I've defined the following:
>
> #+begin_src emacs-lisp
> (org-link-set-parameters
> "calc"
> :export (lambda (path desc backend)
> (cond
> ((eq 'latex backend)
> (format "\\texttt{%s}" desc))))
> :face '(:foreground "chartreuse"))
> #+end_src
>
> which I then use like this:
>
> #+begin_src org
> [[calc:][Pv := 10^(6.886 - 1175.817 / (100 + 224.867)) => 1847.653]]
> #+end_src
>
> and with appropriate settings for calc [1], calc can manipulate and
> evaluate the expressions. So far, so good.
>
> Two minor issues:
>
> 1. the fontification doesn't colour the links in the colour I would like
> (chartreuse, #7fff00).
I get partial chartreuse, but there are some fontlock that can go on
top, e.g. if it looks like a latex fragment.
>
> 2. if I have two expressions close enough, both with := and =>
> operators, org seems to get confused and interprets two of the =
> symbols, each from one expression, as emphasis markers, as in this
> example:
>
> #+begin_src org
> [[calc:][y := 3 x - 5 => 55]] [[calc:][z := sqrt(y) => 7.416]]
> #+end_src
I can reproduce the issue above, but I have no way to help improve it.
This particular case looks like emphasis from a simple regexp pov.
Fixing it might require checking that the start/end are in the
same org-element maybe.
>
> Screenshot attached showing both problems: colour and second = sign
> disappearing in first link and first = sign in second link.
>
> Any suggestions on how to improve/fix these aspects? Both are minor
> presentation issues and everything else is working very well. Calc
> allows me to work with these expressions easily in org now!
>
> Many thanks,
> eric
>
>
> Footnotes:
> [1] Settings using calc: links:
>
> #+begin_src emacs-lisp
> (defun esf/org-mode-calc-settings ()
> (setq calc-embedded-open-formula "\\[\\[calc:]\\["
> calc-embedded-open-new-formula "[[calc:]["
> calc-embedded-close-formula "]]"
> calc-embedded-close-new-formula "]]"))
> (add-hook 'org-mode-hook #'esf/org-mode-calc-settings)
> #+end_src
--
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
^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <ddb8a56dba05452a83cf00b9166123bb@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>]
* Re: parsing of emphasis versus links
[not found] ` <ddb8a56dba05452a83cf00b9166123bb@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
@ 2017-03-18 10:18 ` Eric S Fraga
0 siblings, 0 replies; 3+ messages in thread
From: Eric S Fraga @ 2017-03-18 10:18 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 689 bytes --]
On Friday, 17 Mar 2017 at 19:32, John Kitchin wrote:
> I can not reproduce all the things you report.
Hi John,
But you did reproduce most so it's not my imagination :-)
> I think part of the problem is [calc:]. I have to have at least two
> characters of path to get a link that is colored.
Ah, okay. I'll think about extending the template for embedded calc
recognition.
> This particular case looks like emphasis from a simple regexp pov.
Yes, indeed. I'm getting around it by making sure there is only one
calc: link per line but not ideal. More thinking required!
Thanks for having a look.
--
: Eric S Fraga (0xFFFCF67D), Emacs 26.0.50, Org release_9.0.5-378-gf6f02e.dirty
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-18 10:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-16 19:48 parsing of emphasis versus links Eric S Fraga
2017-03-17 19:32 ` John Kitchin
[not found] ` <ddb8a56dba05452a83cf00b9166123bb@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2017-03-18 10:18 ` Eric S Fraga
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).