Re: [O] Ox-html: Replace with and with
Hello, Kaushal Modi writes: > I am not an HTML expert. But recently off-list, I learnt that and > tags aren't recommended to be used for styling any more (for a while now). > > Instead and should be used respectively. > > If there are no objections, I can commit this little change to the master > branch. > > References: > > - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/b > - > https://developer.mozilla.org/en-US/docs/Web/HTML/Element/i#Usage_Notes No objection from me. Thank you! Regards, -- Nicolas Goaziou
Re: [O] Inline code block syntax highlighting absence
Garreau, Alexandre writes: > Why is there no syntax highlighting for *inline* source/code blocks? > > For instance, if I type the following: > > #+BEGIN_SRC org > src_emacs-lisp{(foo bar (quux))} > #+END_SRC > > The underscore is not displayed, “emacs” is displayed in face > ~org-latex-and-related~ *and* in subscript display (smaller and > negatively raised), and all the rest in default face, with no syntax > highlighting, even inside the braces (that I would expect as it is done > inside non-inline blocks). I used to asked similar question, and answered my own question with a font-lock solution. This link might be helpful. https://stackoverflow.com/questions/20309842/how-to-syntax-highlight-for-org-mode-inline-source-code-src-lang -- [ stardiviner ] I try to make every word tell the meaning what I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
[O] [feature proposal] Export in foreign buffers - ASCII (ox-ascii)
Dear Org-Mode Developers, I was missing convert-region functions in the ox-ascii export back-end as are provided by the HTML, LaTeX, Texinfo, and MarkDown back-ends [1], and hence crafted my own (copied below) to go into my init file. My use case is composing emails using notmuch-message-mode. [1] https://orgmode.org/manual/Export-in-foreign-buffers.html I though this feature might be useful to others, too, and would likely also seem a low hanging fruit to implement? ;-)) It would be awesome to see this new feature in one of the next releases of ox-ascii. Many thanks in advance and cheers, --alexander -- (defun org-ascii-convert-region-to-ascii () "Assume the current region has org-mode syntax, and convert it to plain ASCII. This can be used in any buffer. For example, you could write an itemized list in org-mode syntax in a Mail buffer and then use this command to convert it." (interactive) (let ((my/org-ascii-charset org-ascii-charset)) (setq org-ascii-charset 'ascii) (org-export-replace-region-by 'ascii) (setq org-ascii-charset my/org-ascii-charset))) (defun org-ascii-convert-region-to-utf8 () "Assume the current region has org-mode syntax, and convert it to UTF-8. This can be used in any buffer. For example, you could write an itemized list in org-mode syntax in a Mail buffer and then use this command to convert it." (interactive) (let ((my/org-ascii-charset org-ascii-charset)) (setq org-ascii-charset 'utf-8) (org-export-replace-region-by 'ascii) (setq org-ascii-charset my/org-ascii-charset))) --
Re: [O] coderef does not provide file path for org-insert-link when not in original buffre
Nicolas Goaziou writes: >> ;; I tried to add this, but failed. because `coderef` is executed in >> `org-edit-src-code` which invokes `org-src--edit-element`, it create a >> dedicated buffer which does not have `buffer-file-name`. I don't know how to >> archive what I want now. >> ;; ((eq org-link-file-path-type 'adaptive) > > In "org-src.el", we create local variables to store information from > original buffer. See, e.g., `org-src--src-type' or `org-src--tab-width'. > Anyway, see my first question. Thanks for this hint, I added a new entry in org-src--babel-info list to pass the original parent file path. >From 6e8469545185a41d22b8046ebb367c3c742f0ff4 Mon Sep 17 00:00:00 2001 From: stardiviner Date: Wed, 24 Oct 2018 10:45:40 +0800 Subject: [PATCH] org.el: fix org-coderef does not support adaptive file path link type. * org.el (org-insert-link): support option org-link-file-path-type 'adaptive value. * ob-core.el (org-babel-get-src-block-info): add an new entry into src block info list to pass parent file path. --- lisp/ob-core.el | 5 +++-- lisp/org.el | 9 ++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 42360d618..73117f1a7 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -578,7 +578,7 @@ object instead. Return nil if point is not on a source block. Otherwise, return a list with the following pattern: - (language body arguments switches name start coderef)" + (language body arguments switches name start coderef parent-file-path)" (let* ((datum (or datum (org-element-context))) (type (org-element-type datum)) (inline (eq type 'inline-src-block))) @@ -609,7 +609,8 @@ a list with the following pattern: name (org-element-property (if inline :begin :post-affiliated) datum) - (and (not inline) (org-src-coderef-format datum) + (and (not inline) (org-src-coderef-format datum)) + buffer-file-name))) (unless light (setf (nth 2 info) (org-babel-process-params (nth 2 info (setf (nth 2 info) (org-babel-generate-file-param name (nth 2 info))) diff --git a/lisp/org.el b/lisp/org.el index 0b5e8d739..37524bce0 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -9249,13 +9249,14 @@ non-nil." (interactive? (let ((label (read-string "Code line label: "))) (end-of-line) - (setq link (format coderef-format label)) (let ((gc (- 79 (length link (if (< (current-column) gc) (org-move-to-column gc t) (insert " "))) - (insert link) - (setq link (concat "(" label ")")) + (insert (format coderef-format label)) + (setq link (format "file:%s::%s" + (car (last org-src--babel-info)) + (concat "(" label ")"))) (setq desc nil))) (t (setq link nil) @@ -9852,6 +9853,8 @@ Use TAB to complete link prefixes, then RET for type-specific completion support (setq path (expand-file-name path))) ((eq org-link-file-path-type 'relative) (setq path (file-relative-name path))) + ((eq org-link-file-path-type 'adaptive) + (setq path (file-relative-name path))) (t (save-match-data (if (string-match (concat "^" (regexp-quote -- 2.19.1 -- [ stardiviner ] I try to make every word tell the meaning what I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
[O] Ox-html: Replace with and with
Hello, I am not an HTML expert. But recently off-list, I learnt that and tags aren't recommended to be used for styling any more (for a while now). Instead and should be used respectively. If there are no objections, I can commit this little change to the master branch. References: - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/b - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/i#Usage_Notes -- Kaushal Modi
Re: [O] FYI: with-org-today-date macro, helps with testing
i duly saved this macro, didn't think to look for it, and used datefudge(1).
Re: [O] access a let* value whe ndefining a function?
Matt Price writes: > On Tue, Oct 23, 2018 at 2:32 PM John Kitchin > wrote: > >> I think that what you really want to do here is modify org-mime-compose so >> that you can use the send-actions argument to message-mail. In >> scimax-email.el I use that to be able to turn an org-heading into an email, >> send it, and then jump back to the heading to insert some information about >> the email into the heading properties after it is sent. A lot of the >> information gets passed via global variables. Maybe there is a better way >> to do that, I wrote that code a long time ago. >> >> > I'm trying to use mu4e~compose-mail instead of message-compose, I guess > mostly because I want to be able to use the mu4e email address completion > features in the `To:` header. And it wouldalso be nice to save the email > to the appropriate mu folder. But I didn't seem to be able to make mu4e > bounce back to my buffer no matter what I do, and though mu4e~compose-mail > accepts a return-action argument it doesn't actually use it :-(. This is kind of tricky. Here is an approach that seems to work: (defun my-compose () (interactive) (mu4e~compose-mail) (advice-add 'mu4e~switch-back-to-mu4e-buffer :after `(lambda () (switch-to-buffer (get-buffer ,(buffer-name) )) (advice-remove 'mu4e~switch-back-to-mu4e-buffer "om-temp-advice")) '((name . "om-temp-advice" You just call M-x my-compose to get this behavior. I guess you could advise mu4e~compose too to add the advice. It seems necessary to use a temporary advice here. I wasn't aware of the name way of removing advice, that is pretty nice here, since we use a changing anonymous function. > > >> Otherwise, you need to figure out how to use something like a macro that >> captures the current-buffer and creates a lambda function with that >> information in it, and attaches it to the message-buffer hook somehow. For >> example this will display a message-box for me after the message is sent. >> >> (let ((f `(lambda () >> (message-box "Came from %s" ,(current-buffer) >> (message-mail) >> (add-hook 'kill-buffer-hook f nil t)) >> >> Some important notes is this hook is added in local mode, so it only >> affects that email buffer. >> >> > Can you explain to me what yo umean by "added in local mode" -- how is that > achieved? This is what the final t argument in the add-hood function does. I think it makes the hook local to the buffer it runs in, as opposed to in every buffer. > > Meanwhile, htis is what I've done and it seems to work: > > (eval (car (read-from-string > (concat > "(advice-add 'mu4e~switch-back-to-mu4e-buffer :after > (lambda () > (switch-to-buffer >(get-buffer \"" > (buffer-name) > "\" )) > (advice-remove > 'mu4e~switch-back-to-mu4e-buffer \"om-temp-advice\")) > '((name . \"om-temp-advice\")))" This is practically the same as my `, solution above, you just use strings to protect some parts of code from evaluation, regular function calls in places, and then you concat it all together and read it. The `, syntax is optional, but without it you have to use list and quotes to build up the code in a similar way: (let ((f (list 'lambda () (list 'message-box "Came from %s" (current-buffer) (message-mail) (add-hook 'kill-buffer-hook f nil t)) here the ' means treat something like a symbol, and don't evaluate it. We build up the lambda expression using runtime information, e.g. what is the current-buffer when the code is run. > > seems a little baroque. Maybe what you have there is way better. I don't > really undertand backquotes and leading ocmmas even now. It takes some practice. Suppose you have some variables defined, e.g. a=3, then here are two ways to make a list where you put the value of a into the first place, and a symbol b in the second place. (list a 'b) => '(3 'b) `(,a b) => '(3 'b) This lets you build up expressions, including functions that are defined at runtime. Lots of macros use this syntax to build up expressions that are later evaluated. > > > > >> 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, Oct 23, 2018 at 1:40 PM Matt Price wrote: >> >>> Hey, I guess this is OT. >>> >>> I'm trying to advice org-mime-org-buffer-htmlize so that it returns to >>> the org buffer when its done. I want to do something like this: >>> >>> (let ((thisbuffer (current-buffer)) >>> (advice-add >>> 'mu4e-sent-handler >>> :after (lambda (docid props) >>> (switch-to-buffer thisbuffer) >>> (advice-rem
Re: [O] Trying to use :post header argument to set #+ATTR_LATEX: line
Dear Chuck, Thanks for suggesting xtables. I have used it in the past, but had more or less forgotten about it. I'll give it a try again. Best regards, Lennart. On 22-10-18 18:42, Berry, Charles wrote: > > >> On Oct 22, 2018, at 7:43 AM, L.C. Karssen wrote: >> >> Dear list, >> >> I'd like to create several tables from R and export those to a LaTeX >> document. Because only input variable differs for the R code that >> generates the tables, I thought I could use the :post header argument to >> add the #+ATTR_LATEX: line I need to each of the outputs of my R source >> code blocks. >> >> I tried to follow the Org manual (section 14.8.2.27), but that doesn't >> seem to work. My R results blocks all get colons in front of the output >> and if I set :results drawer, I get the following error: > > I do not doubt that this is possible with enough tooling. I think it will be > easier with the xtable R package. > > But for issues like this I usually find it easier to export the document to > *.Rmd (R markdown) or *.Rnw (knitr) and render from there. > > See https://github.com/chasberry/orgmode-accessories for some examples. > > > HTH, > > Chuck > -- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* L.C. Karssen 's-Hertogenbosch The Netherlands lenn...@karssen.org http://blog.karssen.org GPG key ID: A88F554A -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- signature.asc Description: OpenPGP digital signature
Re: [O] access a let* value whe ndefining a function?
On Tue, Oct 23, 2018 at 3:38 PM Matt Price wrote: > > > On Tue, Oct 23, 2018 at 2:32 PM John Kitchin > wrote: > >> I think that what you really want to do here is modify org-mime-compose >> so that you can use the send-actions argument to message-mail. In >> scimax-email.el I use that to be able to turn an org-heading into an email, >> send it, and then jump back to the heading to insert some information about >> the email into the heading properties after it is sent. A lot of the >> information gets passed via global variables. Maybe there is a better way >> to do that, I wrote that code a long time ago. >> >> > I'm trying to use mu4e~compose-mail instead of message-compose, I guess > mostly because I want to be able to use the mu4e email address completion > features in the `To:` header. And it wouldalso be nice to save the email > to the appropriate mu folder. But I didn't seem to be able to make mu4e > bounce back to my buffer no matter what I do, and though mu4e~compose-mail > accepts a return-action argument it doesn't actually use it :-(. > > >> Otherwise, you need to figure out how to use something like a macro that >> captures the current-buffer and creates a lambda function with that >> information in it, and attaches it to the message-buffer hook somehow. For >> example this will display a message-box for me after the message is sent. >> >> (let ((f `(lambda () >> (message-box "Came from %s" ,(current-buffer) >> (message-mail) >> (add-hook 'kill-buffer-hook f nil t)) >> >> Some important notes is this hook is added in local mode, so it only >> affects that email buffer. >> >> > Can you explain to me what yo umean by "added in local mode" -- how is > that achieved? > > Meanwhile, htis is what I've done and it seems to work: > > (eval (car (read-from-string > (concat > "(advice-add 'mu4e~switch-back-to-mu4e-buffer :after > (lambda () > (switch-to-buffer >(get-buffer \"" > (buffer-name) > "\" )) > (advice-remove > 'mu4e~switch-back-to-mu4e-buffer \"om-temp-advice\")) > '((name . \"om-temp-advice\")))" > > seems a little baroque. Maybe what you have there is way better. I don't > really undertand backquotes and leading ocmmas even now. > > > I'd think this owuld be equivalent but the advice removal isn't working: (advice-add 'mu4e~switch-back-to-mu4e-buffer :after (eval `(lambda () (switch-to-buffer (get-buffer ,(buffer-name) )) (advice-remove 'mu4e~switch-back-to-mu4e-buffer "om-temp-advice") '((name . "om-temp-advice") the naming isn't being carried out succesfully. I guess the regular quoting works differnely inside a backquote or osmething? > > >> 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, Oct 23, 2018 at 1:40 PM Matt Price wrote: >> >>> Hey, I guess this is OT. >>> >>> I'm trying to advice org-mime-org-buffer-htmlize so that it returns to >>> the org buffer when its done. I want to do something like this: >>> >>> (let ((thisbuffer (current-buffer)) >>> (advice-add >>> 'mu4e-sent-handler >>> :after (lambda (docid props) >>> (switch-to-buffer thisbuffer) >>> (advice-remove 'mu4e-sent-handler 'om-sent-advice) >>> ) '((name . 'om-sent-advice))) >>> >>> but by the time the hook is run, the (let) has long since lapsed, and >>> thisbuffer is no longer defined. Can I force evaluation of the variable >>> during definition? >>> >>> Thanks, >>> m >>> >>
Re: [O] Display-level automatic subtree numbering
On 2018-10-23 at 14:33, John Kitchin wrote: > There are some answers at > https://emacs.stackexchange.com/questions/32396/complete-path-numbering-of-org-mode-headlines-and-plain-lists Interesting. Thank you (I’m unfortunately not very friend with search engines): that also raises altogether the question of tables of contents. But that doesn’t answer the question: why “doesn’t it exist”? shouldn’t these functions be mainlined, if legally permitted? Btw, since I read overlays create slowness proportional to their numbers, and that’s surely a lot of overlays, wouldn’t it be better using text properties? these support `display' as well, and, I checked, even for strings of different length: is there a particular reasons they wouldn’t work as well?
Re: [O] access a let* value whe ndefining a function?
On Tue, Oct 23, 2018 at 2:32 PM John Kitchin wrote: > I think that what you really want to do here is modify org-mime-compose so > that you can use the send-actions argument to message-mail. In > scimax-email.el I use that to be able to turn an org-heading into an email, > send it, and then jump back to the heading to insert some information about > the email into the heading properties after it is sent. A lot of the > information gets passed via global variables. Maybe there is a better way > to do that, I wrote that code a long time ago. > > I'm trying to use mu4e~compose-mail instead of message-compose, I guess mostly because I want to be able to use the mu4e email address completion features in the `To:` header. And it wouldalso be nice to save the email to the appropriate mu folder. But I didn't seem to be able to make mu4e bounce back to my buffer no matter what I do, and though mu4e~compose-mail accepts a return-action argument it doesn't actually use it :-(. > Otherwise, you need to figure out how to use something like a macro that > captures the current-buffer and creates a lambda function with that > information in it, and attaches it to the message-buffer hook somehow. For > example this will display a message-box for me after the message is sent. > > (let ((f `(lambda () > (message-box "Came from %s" ,(current-buffer) > (message-mail) > (add-hook 'kill-buffer-hook f nil t)) > > Some important notes is this hook is added in local mode, so it only > affects that email buffer. > > Can you explain to me what yo umean by "added in local mode" -- how is that achieved? Meanwhile, htis is what I've done and it seems to work: (eval (car (read-from-string (concat "(advice-add 'mu4e~switch-back-to-mu4e-buffer :after (lambda () (switch-to-buffer (get-buffer \"" (buffer-name) "\" )) (advice-remove 'mu4e~switch-back-to-mu4e-buffer \"om-temp-advice\")) '((name . \"om-temp-advice\")))" seems a little baroque. Maybe what you have there is way better. I don't really undertand backquotes and leading ocmmas even 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, Oct 23, 2018 at 1:40 PM Matt Price wrote: > >> Hey, I guess this is OT. >> >> I'm trying to advice org-mime-org-buffer-htmlize so that it returns to >> the org buffer when its done. I want to do something like this: >> >> (let ((thisbuffer (current-buffer)) >> (advice-add >> 'mu4e-sent-handler >> :after (lambda (docid props) >> (switch-to-buffer thisbuffer) >> (advice-remove 'mu4e-sent-handler 'om-sent-advice) >> ) '((name . 'om-sent-advice))) >> >> but by the time the hook is run, the (let) has long since lapsed, and >> thisbuffer is no longer defined. Can I force evaluation of the variable >> during definition? >> >> Thanks, >> m >> >
Re: [O] Display-level automatic subtree numbering
There are some answers at https://emacs.stackexchange.com/questions/32396/complete-path-numbering-of-org-mode-headlines-and-plain-lists . 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, Oct 23, 2018 at 2:30 PM Garreau, Alexandre wrote: > Hi, > > This is provided on (almost?) all export formats, but yet when looking > at an org-file the prefered way, with emacs, there’s no numbering, by > default. > > It’s so useful and simple (using a display text/overlay property), is > there just anything implementing that? mainline? if so why isn’t it? > >
Re: [O] access a let* value whe ndefining a function?
I think that what you really want to do here is modify org-mime-compose so that you can use the send-actions argument to message-mail. In scimax-email.el I use that to be able to turn an org-heading into an email, send it, and then jump back to the heading to insert some information about the email into the heading properties after it is sent. A lot of the information gets passed via global variables. Maybe there is a better way to do that, I wrote that code a long time ago. Otherwise, you need to figure out how to use something like a macro that captures the current-buffer and creates a lambda function with that information in it, and attaches it to the message-buffer hook somehow. For example this will display a message-box for me after the message is sent. (let ((f `(lambda () (message-box "Came from %s" ,(current-buffer) (message-mail) (add-hook 'kill-buffer-hook f nil t)) Some important notes is this hook is added in local mode, so it only affects that email buffer. 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, Oct 23, 2018 at 1:40 PM Matt Price wrote: > Hey, I guess this is OT. > > I'm trying to advice org-mime-org-buffer-htmlize so that it returns to the > org buffer when its done. I want to do something like this: > > (let ((thisbuffer (current-buffer)) > (advice-add > 'mu4e-sent-handler > :after (lambda (docid props) > (switch-to-buffer thisbuffer) > (advice-remove 'mu4e-sent-handler 'om-sent-advice) > ) '((name . 'om-sent-advice))) > > but by the time the hook is run, the (let) has long since lapsed, and > thisbuffer is no longer defined. Can I force evaluation of the variable > during definition? > > Thanks, > m >
[O] Display-level automatic subtree numbering
Hi, This is provided on (almost?) all export formats, but yet when looking at an org-file the prefered way, with emacs, there’s no numbering, by default. It’s so useful and simple (using a display text/overlay property), is there just anything implementing that? mainline? if so why isn’t it?
[O] access a let* value whe ndefining a function?
Hey, I guess this is OT. I'm trying to advice org-mime-org-buffer-htmlize so that it returns to the org buffer when its done. I want to do something like this: (let ((thisbuffer (current-buffer)) (advice-add 'mu4e-sent-handler :after (lambda (docid props) (switch-to-buffer thisbuffer) (advice-remove 'mu4e-sent-handler 'om-sent-advice) ) '((name . 'om-sent-advice))) but by the time the hook is run, the (let) has long since lapsed, and thisbuffer is no longer defined. Can I force evaluation of the variable during definition? Thanks, m
Re: [O] electric-pair, autopair, smartparens, etc in org-mode
On Tuesday, 23 Oct 2018 at 19:48, stardiviner wrote: > This is really helpful for me, I use smartparens before, but it is a > little heavy. So I disabled it. I found your solution is simple and > fast. I modified a little: +1 I gave up long ago on smartparens but skeleton seems to work well. -- Eric S Fraga via Emacs 27.0.50, Org release_9.1.13-783-g97fac4
Re: [O] [PATCH] migrate ob-clojure initiate session code from ob-clojure-literate.el into ob-clojure.el
Nicolas Goaziou writes: Hi, sorry for late response, because I'm a little lazy on give effort on review my patch and improve it again. But now I finished it. Actually I corrected my patch as soon as you replied email with mentioned. Today I pick up this task again, and add a new improve which support CIDER new API which using sesman to manage REPL sessions. > > Would it make sense to add a few tests for this? > > Regards, It is hard for me to write tests for CIDER session. It has some kind of interactive and don't know how to verify it. >From f495c5b4e65fd8c6a64e8619d974d6eb051fb1f7 Mon Sep 17 00:00:00 2001 From: stardiviner Date: Thu, 19 Apr 2018 18:16:27 +0800 Subject: [PATCH 1/2] ob-clojure.el: Support `org-babel-initiate-session' to initialize. * ob-clojure.el (org-babel-clojure-initiate-session): Initialize session for src block. (org-babel-prep-session:clojure): Prepare Clojure session. (org-babel-clojure-var-to-clojure): Convert header argument :var into clojure variables definitions. (org-babel-variable-assignments:clojure): Support assign variables when initialize session. --- contrib/lisp/ob-clojure-literate.el | 56 - lisp/ob-clojure.el | 55 + testing/lisp/test-ob-clojure.el | 77 + 3 files changed, 132 insertions(+), 56 deletions(-) create mode 100644 testing/lisp/test-ob-clojure.el diff --git a/contrib/lisp/ob-clojure-literate.el b/contrib/lisp/ob-clojure-literate.el index 4c4d38a0f..b1cc386ee 100644 --- a/contrib/lisp/ob-clojure-literate.el +++ b/contrib/lisp/ob-clojure-literate.el @@ -184,62 +184,6 @@ If it is a directory, `ob-clojure-literate' will try to create Clojure project a (lambda (cons) (if (eq (car cons) :session) t cons)) org-babel-default-header-args:clojure) -;;; Support `org-babel-initiate-session' / [C-c C-v z] to initialize Clojure session. - -(defun org-babel-clojure-initiate-session (&optional session _params) - "Initiate a session named SESSION according to PARAMS." - (when (and session (not (string= session "none"))) -(save-window-excursion - (unless (org-babel-comint-buffer-livep session) -;; CIDER jack-in to the Clojure project directory. -(cond - ((eq org-babel-clojure-backend 'cider) - (require 'cider) - (let ((session-buffer (save-window-excursion - (cider-jack-in t) - (current-buffer -(if (org-babel-comint-buffer-livep session-buffer) -(progn (sit-for .25) session-buffer - ((eq org-babel-clojure-backend 'slime) - (error "Session evaluation with SLIME is not supported")) - (t - (error "Session initiate failed"))) -) - (get-buffer session) - ))) - -(defun org-babel-prep-session:clojure (session params) - "Prepare SESSION according to the header arguments specified in PARAMS." - (let* ((session (org-babel-clojure-initiate-session session)) - (var-lines (org-babel-variable-assignments:clojure params))) -(when session - (org-babel-comint-in-buffer session -(mapc (lambda (var) -(insert var) (comint-send-input nil t) - (org-babel-comint-wait-for-output session) - (sit-for .1) (goto-char (point-max))) var-lines))) -session)) - -(defun org-babel-clojure-var-to-clojure (var) - "Convert src block's `VAR' to Clojure variable." - (if (listp var) - (replace-regexp-in-string "(" "'(" var) -(cond - ((stringp var) - ;; wrap org-babel passed in header argument value with quote in Clojure. - (format "\"%s\"" var)) - (t - (format "%s" var - ) - -(defun org-babel-variable-assignments:clojure (params) - "Return a list of Clojure statements assigning the block's variables in `PARAMS'." - (mapcar - (lambda (pair) - (format "(def %s %s)" - (car pair) - (org-babel-clojure-var-to-clojure (cdr pair - (org-babel--get-vars params))) ;;; Support header arguments :results graphics :file "image.png" by inject Clojure code. (defun ob-clojure-literate-inject-code (args) diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el index d5b918b01..048ba3735 100644 --- a/lisp/ob-clojure.el +++ b/lisp/ob-clojure.el @@ -43,6 +43,7 @@ (require 'ob) (require 'org-macs) +(declare-function cider-jack-in "ext:cider" (&optional prompt-project cljs-too)) (declare-function cider-current-connection "ext:cider-client" (&optional type)) (declare-function cider-current-ns "ext:cider-client" ()) (declare-function nrepl--merge "ext:nrepl-client" (dict1 dict2)) @@ -211,6 +212,60 @@ using the :show-process parameter." (condition-case nil (org-babel-script-escape result) (error result) +(defun org-babel-clojure-initiate-session (&optional session _params) + "Initiate a session named SESSION according to PARAMS." + (when (and sessio
Re: [O] electric-pair, autopair, smartparens, etc in org-mode
Roland Everaert writes: > Hi, > > I use the following configuration: > > parenthèses, accolades et brackets ;; > (setq skeleton-pair t) > (global-set-key "[" 'skeleton-pair-insert-maybe) > (global-set-key "{" 'skeleton-pair-insert-maybe) > (global-set-key "(" 'skeleton-pair-insert-maybe) > (global-set-key "\"" 'skeleton-pair-insert-maybe) > (global-set-key "'" 'skeleton-pair-insert-maybe) > > This will only close the defined characters. > > > Hope this will help. > > Roland. > This is really helpful for me, I use smartparens before, but it is a little heavy. So I disabled it. I found your solution is simple and fast. I modified a little: #+begin_src emacs-lisp (require 'skeleton) (setq skeleton-pair t) (define-key org-mode-map (kbd "~") 'skeleton-pair-insert-maybe) (define-key org-mode-map (kbd "=") 'skeleton-pair-insert-maybe) (define-key org-mode-map (kbd "*") 'skeleton-pair-insert-maybe) (define-key org-mode-map (kbd "+") 'skeleton-pair-insert-maybe) (define-key org-mode-map (kbd "[") 'skeleton-pair-insert-maybe) (define-key org-mode-map (kbd "{") 'skeleton-pair-insert-maybe) (define-key org-mode-map (kbd "(") 'skeleton-pair-insert-maybe) (define-key org-mode-map (kbd "\"") 'skeleton-pair-insert-maybe) (define-key org-mode-map (kbd "'") 'skeleton-pair-insert-maybe) #+end_src -- [ stardiviner ] I try to make every word tell the meaning what I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
[O] Inline code block syntax highlighting absence
Why is there no syntax highlighting for *inline* source/code blocks? For instance, if I type the following: #+BEGIN_SRC org src_emacs-lisp{(foo bar (quux))} #+END_SRC The underscore is not displayed, “emacs” is displayed in face ~org-latex-and-related~ *and* in subscript display (smaller and negatively raised), and all the rest in default face, with no syntax highlighting, even inside the braces (that I would expect as it is done inside non-inline blocks).
Re: [O] Org source block header argument :var does not support space separated string
Berry, Charles writes: > > This works > > #+begin_src sh :var encrypted=(org-babel-ref-resolve "base64 encrypt text()") > echo $encrypted > #+end_src > > You might write a wrapper, so something like (quote-ref "base64 encrypt > text")will handle it. > Thanks very much! this solved my problem. -- [ stardiviner ] I try to make every word tell the meaning what I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
Re: [O] electric-pair, autopair, smartparens, etc in org-mode
Hi, I use the following configuration: parenthèses, accolades et brackets ;; (setq skeleton-pair t) (global-set-key "[" 'skeleton-pair-insert-maybe) (global-set-key "{" 'skeleton-pair-insert-maybe) (global-set-key "(" 'skeleton-pair-insert-maybe) (global-set-key "\"" 'skeleton-pair-insert-maybe) (global-set-key "'" 'skeleton-pair-insert-maybe) This will only close the defined characters. Hope this will help. Roland. Matt Price writes: > wow, I learned a whole lot from your answer Nicholas, but still not quite > enough to make this work for me. After some puzzling over the syntax for > character values, I believe that what I want should be something like this: > > (add-function :before-until electric-pair-inhibit-predicate > (lambda (c) > (and (eq ?\[ c) > (eq major-mode 'org-mode) > (memq (char-before (1- (point))) '(?\[ ?\]) > > The manual says to use advice-add instead of add-function for these cases, > so this could be written like this instead: > > (defun mwp-org-mode-electric-inhibit (c) > (and >(eq ?\[ c) >(eq major-mode 'org-mode) >(memq (char-before (1- (point))) '(?\[ ?\]) ))) > > (advice-add electric-pair-inhibit-predicate :before-until > #'mwp-org-mode-electric-inhibit) > > it seems to sort of work. That is, the code is effective, but it doesn't > do what I want, so I had to think about the desired behaviour, which is > maybe too complex for this modification: > > when I start a link [ > go ahead and add pair to > [] > when I add a second [, don't complete > [[] > this is what my code does! > > but what I really want is, when I finish adding a link reference, somehow > allow me to stay inside the link to add the link text: > [[https://google.com]] --> [[https://google.com][]] > with point between the final [ and ]. > This seems like it needs a more complex intervention. > > For now I've just turned off pairing of brackets entirely: > > (defun mwp-org-mode-electric-inhibit (c) > (and >(eq ?\[ c) >(eq major-mode 'org-mode)) > > This works fine, though I'd still like the other :-/ > > Thanks Nicholas! > On Sun, Oct 21, 2018 at 3:28 AM Nicolas Goaziou > wrote: > >> Hello, >> >> Matt Price writes: >> >> > - electric-pair and autopair complete [[ immediately, and don't seem to >> > allow me to skip past the closing brackets, so if I try to type [[ >> > https://link.to.somewhere][link text]] I end up with >> > [[link.to.somewhere]][link-text] . >> >> I use C-c C-l to insert links with description. However, electric >> pairing does get in the way when writing sub/superscript. I use the >> following snippet to work around the issue: >> >>(add-function :before-until electric-pair-inhibit-predicate >> (lambda (c) >>(and (eq ?\{ c) >> (eq major-mode 'org-mode) >> (memq (char-before (1- (point))) '(?_ ?^) >> >> I guess you could do something similar to disable pairing when entering >> a bracket link. >> >> Regards, >> >> -- >> Nicolas Goaziou >> -- Luke, use the FOSS Sent from Emacs