This variable was new to me when I saw it mentioned last week, so I turned it on, but either it doesn't work or I'm doing something wrong. My steps: In Org source tree, `make repro`. In Emacs: `M-: (setq org-fontify-quote-and-verse-blocks t) RET` Create a temporary Org file like this: #+begin_quote This is a quote. #+end_quote Put pointer inside the quote block and run `M-x describe-text-properties`. It says that the face is org-block, not org-quote as expected: There are text properties here: face (org-block) Bill -- William Denton https://www.miskatonic.org/ Librarian, artist and licensed private investigator. Toronto, Canada
Max Nikulin writes:
> An update with a couple of bugs fixed. Now it is possible to specify
> different export rules for a backend and all its derivatives:
I have implemented your code in the last commit. I think it is a great
improvement, thanks a lot.
As I mentioned in a past email, these days I will be somewhat busy, but
I will try to keep up to date with your comments. Although it may take a
while to respond.
[-- Attachment #1.1.1: Type: text/plain, Size: 331 bytes --] Hi again, I hope this time I'm not mistaken. When I compile the attached file into a PDF with org-beamer-export-to-pdf, I get a PDF file where the footnotes numbering are using numbers in the text and letters in the footer. Am I doing something wrong? Is there a simple workaround? Good night -- Guillaume MULLER [-- Attachment #1.1.2: BuggyFootnotes.org --] [-- Type: application/vnd.lotus-organizer, Size: 476 bytes --] [-- Attachment #1.1.3: OpenPGP public key --] [-- Type: application/pgp-keys, Size: 673 bytes --] [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 236 bytes --]
On Monday, 18 Mar 2024 at 20:59, Visuwesh wrote: > You give me far too credit: I merely placed an edebug trigger for > calc-push-list and used a simple-minded ' [1,2,3;4,5,6] RET to figure > out the vector format (then later I found the commentary). Cute! > If I get the time, I will try to look into your request. Unfortunately, > I cannot promise anything since I am near the end of my semester making > me annoyingly busy. That's perfectly fine! I'm in no rush; it's just an itch that needs scratching. :-) Thank you, eric -- Eric S Fraga, https://profiles.ucl.ac.uk/5958-eric-fraga
[திங்கள் மார்ச் 18, 2024] Fraga, Eric wrote: > Thank you for this. Potentially very useful. > > As you have managed to understand calc internals (to a much greater > degrees than I have ever managed), do you know if there is any way to go > the other way? Specifically, I would love to make reference to calc > variables, especially those defined using embedded calc, in org tables. You give me far too credit: I merely placed an edebug trigger for calc-push-list and used a simple-minded ' [1,2,3;4,5,6] RET to figure out the vector format (then later I found the commentary). If I get the time, I will try to look into your request. Unfortunately, I cannot promise anything since I am near the end of my semester making me annoyingly busy. [ I would like to make ob-calc turn matrices into tables in the result: like what ob-fortran and others already do. ] > Thanks again, > eric
Thank you for this. Potentially very useful. As you have managed to understand calc internals (to a much greater degrees than I have ever managed), do you know if there is any way to go the other way? Specifically, I would love to make reference to calc variables, especially those defined using embedded calc, in org tables. Thanks again, eric -- Eric S Fraga, https://profiles.ucl.ac.uk/5958-eric-fraga
On Sunday, 17 Mar 2024 at 10:29, Wu Ming wrote:
> Haven’t tried Org export options yet. What is your organization system
> with tables?
I don't have a system! Often, tables in my documents are the output of
some other code and the tables are the results that need further
processing (or visualising). Most of my tables are standalone. As I
think I mentioned earlier, I have seldom (but not never) made use of
remote references.
I do however often have multiple tables as inputs to the post-processing
or visualisation codes.
--
: Eric S Fraga, with org release_9.6.19-1215-g67d937 in Emacs 30.0.50
[-- Attachment #1: Type: text/plain, Size: 1047 bytes --] When I open an org file before opening the agenda, my habits show up as regular tasks, rather than with the consistency graph. Additionally, many CANCELed tasks still show up in the agenda. When I open the agenda first however, everything goes fine. Interestingly, this only happens when I bind 'org-agenda' to a key. To show this, I have attached bad.el and good.el which reproduce the issue on current main (Org mode version 9.7-pre (release_9.6.21-1295-g46909a @ /opt/org-mode/lisp/)). Note that they set (setq org-directory "/tmp/tmp.emacs/notes") and they expect '/tmp/tmp.emacs/notes/file.org' to exist, see attachment. Reproduce with: emacs -Q -l bad.el /tmp/tmp.emacs/notes/file.org so that it definitely opens an org-file before the org-agenda. After opening the agenda, my habits do not show up as habits. My habits do show up with: emacs -Q -l bad.el --eval="(org-agenda-list)" and with they also show up: emacs -Q -l good.el /tmp/tmp.emacs/notes/file.org I am running Emacs 29.2. Am I doing something wrong here? [-- Attachment #2: bad.el --] [-- Type: text/plain, Size: 306 bytes --] (use-package org :load-path "/opt/org-mode/lisp" :init (setq org-directory "/tmp/tmp.emacs/notes")) (use-package org-agenda :ensure nil :load-path "/opt/org-mode/lisp" :config (add-to-list 'org-modules 'org-habit t) (setq org-agenda-files '("file.org")) :bind (("C-c a" . org-agenda))) [-- Attachment #3: good.el --] [-- Type: text/plain, Size: 272 bytes --] (use-package org :load-path "/opt/org-mode/lisp" :init (setq org-directory "/tmp/tmp.emacs/notes")) (use-package org-agenda :ensure nil :load-path "/opt/org-mode/lisp" :config (add-to-list 'org-modules 'org-habit t) (setq org-agenda-files '("file.org"))) [-- Attachment #4: file.org --] [-- Type: application/vnd.lotus-organizer, Size: 185 bytes --]
On 15/03/2024 20:49, Ihor Radchenko wrote: > Max Nikulin writes: >> On 12/03/2024 20:03, Ihor Radchenko wrote: >> - '%i' and "%i" in any position including e.g. --option='%i' and >> protocol:"%i" >> - 'something%i' and "something%i" surrounded by spaces or at the end of >> command but with no spaces in "something". > > I am not confident that it will be safe. For example, consider something > awkward like foo\"%ibar\". I imagine that other edge cases are possible, > especially in exotic shells. I think quotes should not be stripped in such peculiar cases. The variants I suggested do not match it. Is it realistic? >> ... It should be applied to %%%i, >> but not to %%i. > > I am not sure what you mean here. "%%" is a way to specify literal "%" in `format-spec'. So '%%i' means in %i shell command and unquoting should not be applied to it. >>>> - I expected it as bugfix. > > It does not matter that most users will not be affected. Some users > being affected is enough to not commit this to bugfix. Our policy is not > to commit unsafe changes that may break existing configurations to > bugfix branch. Except critical fixes. Reasons why I consider this issue a severe enough: - Something weird may be executed as shell commands - Incorrect formulas in exported documents are more than just disappointment. An example of complain related to another bug: Re: Inequalities in math blocks. Wed, 06 Oct 2021 09:39:23 +0200. https://list.orgmode.org/m2bl42bo0k.fsf@me.com From my point of view, it is better to explain users that they are disturbed to be on the safe side. It is not choice between good and bad variants. Any decision is bad. >> emacs -Q --batch --eval '(find-file-noselect "not-found.txt" t)' >> Error: (file-missing "Searching for program" "No such file or directory" >> "git") > > This looks like Emacs bug. Likely in `vc-refresh-state'. It as an Emacs bug that missing git executable leads to a fatal error. It is a bug in Org that some hooks are called when just file content is necessary.
Thanks Alan, I found a fix to my problem. -- Nasser Alkmim +43 677 6408 9171
[-- Attachment #1: Type: text/plain, Size: 726 bytes --] Hello, On 2024-03-17 19:05, Nasser Alkmim <nasser.alkmim@gmail.com> writes: > Hi Alan, how did you effectively solve the problem? Here is the contents of my export-init file: (setq user-emacs-directory "/Users/schmitta/projets/plain-emacs-config/") (add-to-list 'load-path (expand-file-name "straight/build/org/" user-emacs-directory)) (setq-default indent-tabs-mode nil) (setq org-latex-src-block-backend 'minted) (setq org-latex-pdf-process '("latexmk -pdflatex='%latex --shell-escape -8bit' -pdf -quiet %f")) (setq org-export-async-debug t) (require 'ox-beamer) (add-to-list 'org-beamer-environments-extra '("onlyenv" "O" "\\begin{onlyenv}%a" "\\end{onlyenv}")) Best, Alan [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 528 bytes --]
Thanks, I hadn't understood the significance of named functions vs variables for advice. But now I realise this is not solving the same problem as the original patch. The point is that I was thinking org-roam should advise/modify/hook the specific function `org-id-find' [to find ids in its database] but NOT the more general `(org-link-get-parameter "id" :follow)' [because `org-id-open' has a lot of extra logic for search-strings, backwards compatibility, where to open the new location, which it would not be reasonable to duplicate]. Is there a way to do this using the approach you are suggesting?
[-- Attachment #1: Type: text/plain, Size: 237 bytes --] Ihor Radchenko <yantar92@posteo.net> writes: > It would be nice to attach the patch :) I'm sorry. Here it is. -- Damien Cassou "Success is the ability to go from one failure to another without losing enthusiasm." --Winston Churchill [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-ox-odt-Avoid-warning-when-everything-is-fine.patch --] [-- Type: text/x-patch, Size: 1014 bytes --] From 9dd17fcb7c774f148166d999fd1d021dae9fda3b Mon Sep 17 00:00:00 2001 From: Damien Cassou <damien@cassou.me> Date: Sun, 17 Mar 2024 20:24:59 +0100 Subject: [PATCH] ox-odt: Avoid warning when everything is fine * lisp/ox-odt.el (org-odt--translate-latex-fragments): When processing-type is already 'verbatim, no need to print any warning. --- lisp/ox-odt.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index 666d5da1a..3f1f1a5a8 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -3728,6 +3728,7 @@ (defun org-odt--translate-latex-fragments (tree _backend info) (if (eq processing-type 'dvipng) "dvipng" "convert") "" t)) (setq warning "`org-odt-with-latex': LaTeX to PNG converter not available. Falling back to verbatim.") (setq processing-type 'verbatim))) + (verbatim) ;; nothing to do (otherwise (setq warning "`org-odt-with-latex': Unknown LaTeX option. Forcing verbatim.") (setq processing-type 'verbatim))) -- 2.43.2
[-- Attachment #1: Type: text/plain, Size: 696 bytes --] > Kepa<gnu.cognition199@slmails.com> writes: > > >/Each time I change the DIR property for attachments, I have to answer / > >/correctly two questions: if I want to move every file to the new > path, and if / > >/I want to delete the old folder./ > > > >/Is it possible to not receive these questions?/ > >/For me, it's a big risk I don't want to take every time./ > > May you elaborate on what other behavior you would prefer to see? > > -- > Ihor Radchenko // yantar92, Hi Ihor. It would be enough to have the option to not having those prompt. If I could set it to don't offer to copy files, and the option to don't offer to delete old folder, it would be enough. Best regards, Kepa [-- Attachment #2: Type: text/html, Size: 1190 bytes --]
Looking at the last patch of https://list.orgmode.org/18e4deaa1bd.ff0f87fa694858.5955779335024266818@excalamus.com/, I would expect a reaction of something like, "WTF is all that weird org-trim string-join stuff on the prompt filter?" --- lisp/ob-comint.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lisp/ob-comint.el b/lisp/ob-comint.el index d13aacccc..f2251892a 100644 --- a/lisp/ob-comint.el +++ b/lisp/ob-comint.el @@ -325,9 +325,10 @@ STRING contains the output originally inserted into the comint buffer." until (and (equal (match-string 1) "start") (equal (match-string 2) uuid)) finally return (+ 1 (match-end 0))))) - ;; Apply callback to clean up the result - (res-str (funcall org-babel-comint-async-chunk-callback - res-str-raw))) + ;; Remove prompt + (res-promptless (org-trim (string-join (mapcar #'org-trim (org-babel-comint--prompt-filter res-str-raw)) "\n") "\n")) + ;; Apply user callback + (res-str (funcall org-babel-comint-async-chunk-callback res-promptless))) ;; Search for uuid in associated org-buffers to insert results (cl-loop for buf in org-buffers until (with-current-buffer buf -- 2.41.0 The reason is that the current result of =org-babel-comint-with-output= is a list because the final expression is =delete=: https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/ob-comint.el?id=46909a54e1a2ce0d948e94e0e19ff64af1a39eb9#n164 Why =org-babel-comint-with-output= returns a list is unclear to me. The docstring for =org-babel-comint-with-output= says it should "return all process output". AFAIK, process output is a string, always has been, always will be, and Babel has always gotten a substring of the process buffer (for that code path). Yet for some reason, it was decided to have =org-babel-comint-with-output= return a list. This goes back to the beginning, in 2009, when the final expression used =split-string= instead of =delete=: https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/lisp/org-babel-comint.el?id=dd0392a4f23b40fae7491c55aa44a2324248c103 You might ask, "But wouldn't returning a list require you to then convert it back into a string since =org-babel-comint-with-output= is really just a sentinel on process output?" The answer is, "Yes, that's exactly what you'd need to do." Call grep on =org-babel-comint-with-output= and you'll see in every case except the Ruby ':results value' results and Lua the ':results value' results, that indeed the return value of =org-babel-comint-with-output= is concatenated or the first string element taken. | file | line | result modified? | result used? | comment | |---------------+------+--------------------------+--------------+------------------------------------------------------------------------------| | ob-ruby.el | 263 | no | no | used to send eoe-string | | | 272 | yes, mapconcat | yes | as returned value (for :results output) | | | 281 | no | yes | as returned value (for :results value) | |---------------+------+--------------------------+--------------+------------------------------------------------------------------------------| | ob-js.el | 111 | yes, nth 1 | yes | as returned value (for the default :results) | |---------------+------+--------------------------+--------------+------------------------------------------------------------------------------| | ob-shell.el | 357 | yes, mapconcat | yes | as returned value (for session results of all types) | |---------------+------+--------------------------+--------------+------------------------------------------------------------------------------| | ob-julia.el | 327 | yes, mapconcat | yes | as returned value (for :results output) | |---------------+------+--------------------------+--------------+------------------------------------------------------------------------------| | ob-lua.el | 391 | yes, mapconcat | yes | as returned value (for :results output) | | | 400 | no | yes | as returned value (for :results value) | |---------------+------+--------------------------+--------------+------------------------------------------------------------------------------| | ob-haskell.el | 169 | yes, (cdr (reverse ...)) | yes | as returned value? (for :results output) hard to tell, see lines 194 and 201 | |---------------+------+--------------------------+--------------+------------------------------------------------------------------------------| | ob-octave.el | 239 | yes, (cdr (reverse ...)) | yes | as returned value (for :results output) | |---------------+------+--------------------------+--------------+------------------------------------------------------------------------------| | ob-ocaml.el | 72 | yes, whoa... | yes | as returned value (for at least :results output) | |---------------+------+--------------------------+--------------+------------------------------------------------------------------------------| | ob-R | 460 | yes, mapconcat | yes | as returned value (for :results output) | |---------------+------+--------------------------+--------------+------------------------------------------------------------------------------| It looks like the original implementation aggregated process buffer output, collecting it into a list. It then passed this list on to a function that did, as predicted, (cdr (reverse ...)) to get a string. https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=dd0392a4f23b40fae7491c55aa44a2324248c103 It seems like the return type of =org-babel-comint-with-output= is not what it should be. It looks like it should be a string. Am I missing something? Obviously, changing the return type would be a big job, requiring updates to at least 10 files, and has the potential to introduce bugs. However, as far as I can tell, the return type isn't appropriate and so requires some kind of workaround, of which there are currently three. I guess the best argument I can come up with at the moment for taking on the task of changing the return type is that, assuming my understanding is correct, the current implementation is simply an inappropriate, or outdated, design choice that only adds complexity. My hope is that Babel continues to support new languages. As that happens, they will need to apply work arounds, further entrenching the design and making it harder to correct. What are people's thoughts on changing the return type of =org-babel-comint-with-output=? -- Matt Trzcinski Emacs Org contributor (ob-shell) Learn more about Org mode at https://orgmode.org Support Org development at https://liberapay.com/org-mode
[-- Attachment #1: Type: text/plain, Size: 1966 bytes --] ---- On Mon, 19 Feb 2024 12:07:55 +0100 Ihor Radchenko wrote --- > Matt matt@excalamus.com> writes: > > > - Split prompt filtering and input echoing into two filters > > + this seems to imply a =-hook= or =-functions= type implementation > > Not necessarily. You may just split the filter into (1) prompt > remover; (2) body remover. The filter does not need to interact with > comint buffer and may simply be provided a regexp/string to be removed. > Then, the caller will be responsible to supply prompt regexp/body. Attached are patches which split the prompt and echo filtering into separate functions. These are then used to refactor =org-babel-comint-with-output= and to remove the prompt from async results. I also wrote tests, one for the reported bug and two for the filter functions. Tests for the filter functions are in a new file, 'test-ob-comint.el'. Two thoughts: 1. Can people please test that the changes to =org-babel-comint-with-output= haven't broken other languages? The filter, which I extracted from =org-babel-comint-with-output=, works according to the test I wrote. The test is based on ob-shell output. However, =org-babel-comint-with-output= is used by other languages. I wasn't sure if echoes showed up for other languages and I had no examples from other languages to work from. The filter is untested for anything but shell, aside from running 'make test' (which returns no unexpected errors). If no echo argument is given, the filter simply returns the string it would otherwise try to remove the echo from. So, I suspect the worst outcome would be that echoes might start showing up in output. But when have my predictions ever been right? :) 2. Legacy code woes I'll start another thread to rant, er, discuss. -- Matt Trzcinski Emacs Org contributor (ob-shell) Learn more about Org mode at https://orgmode.org Support Org development at https://liberapay.com/org-mode [-- Attachment #2: 0001-testing-lisp-test-ob-comint.el-Make-test-for-prompt-.patch --] [-- Type: application/octet-stream, Size: 2871 bytes --] From 66cc514eb27a9c50fb0128fa30e55b7609bb9b18 Mon Sep 17 00:00:00 2001 From: Matthew Trzcinski <matt@excalamus.com> Date: Sun, 17 Mar 2024 16:47:22 +0100 Subject: [PATCH 1/7] testing/lisp/test-ob-comint.el: Make test for prompt filter * test-ob-comint.el: Make new file for comint tests. (test-org-babel-comint/prompt-filter-removes-prompt): Test that the prompt is removed from process buffer output. --- testing/lisp/test-ob-comint.el | 55 ++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 testing/lisp/test-ob-comint.el diff --git a/testing/lisp/test-ob-comint.el b/testing/lisp/test-ob-comint.el new file mode 100644 index 000000000..9193ef8f3 --- /dev/null +++ b/testing/lisp/test-ob-comint.el @@ -0,0 +1,55 @@ +;;; test-ob-comint.el -*- lexical-binding: t; -*- + +;; Copyright (c) 2024 Matthew Trzcinski +;; Authors: Matthew Trzcinski + +;; This file is not part of GNU Emacs. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <https://www.gnu.org/licenses/>. + +\f +;;; Comment: + +;; See testing/README for how to run tests. + +\f +;;; Requirements: + +\f +;;; Code: +(ert-deftest test-org-babel-comint/prompt-filter-removes-prompt () + "Test that prompt is actually removed." + (let* ((prompt "org_babel_sh_prompt> ") + (results "org_babel_sh_prompt> echo 'ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59' +# print message +echo \"hello world\" +echo 'ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59' +ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59 +org_babel_sh_prompt> org_babel_sh_prompt> \"hello world\" +org_babel_sh_prompt> ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59 +org_babel_sh_prompt> ")) + (should (string= + (org-trim (string-join (mapcar #'org-trim (org-babel-comint--prompt-filter results prompt)) "\n") "\n") + "echo 'ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59' +# print message +echo \"hello world\" +echo 'ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59' +ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59 +\"hello world\" +ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59")))) + + +(provide 'test-ob-comint) + +;;; test-ob-comint.el ends here -- 2.41.0 [-- Attachment #3: 0002-lisp-ob-comint.el-Create-comint-prompt-filter.patch --] [-- Type: application/octet-stream, Size: 1536 bytes --] From ed5f3e358f2e32c12d3487de9ab17797370eaf81 Mon Sep 17 00:00:00 2001 From: Matthew Trzcinski <matt@excalamus.com> Date: Sun, 17 Mar 2024 16:54:33 +0100 Subject: [PATCH 2/7] lisp/ob-comint.el: Create comint prompt filter * lisp/ob-comint.el (org-babel-comint--prompt-filter): Extract prompt filtering logic from `org-babel-comint-with-output' into a new function. --- lisp/ob-comint.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lisp/ob-comint.el b/lisp/ob-comint.el index 1ec84e865..882e19289 100644 --- a/lisp/ob-comint.el +++ b/lisp/ob-comint.el @@ -74,6 +74,19 @@ This is useful when prompt unexpectedly changes." (setq comint-prompt-regexp org-babel-comint-prompt-regexp-old org-babel-comint-prompt-regexp-old tmp)))) +(defun org-babel-comint--prompt-filter (string &optional prompt-regexp) + "Remove PROMPT-REGEXP from STRING. + +PROMPT-REGEXP defaults to `comint-prompt-regexp'." + (let* ((prompt-regexp (or prompt-regexp comint-prompt-regexp)) + (separator "org-babel-comint--prompt-filter-separator\n")) + (while (string-match-p prompt-regexp string) + (setq string + (replace-regexp-in-string + (format "\\(?:%s\\)?\\(?:%s\\)[ \t]*" separator prompt-regexp) + separator string))) + (delete "" (split-string string separator)))) + (defmacro org-babel-comint-with-output (meta &rest body) "Evaluate BODY in BUFFER and return process output. Will wait until EOE-INDICATOR appears in the output, then return -- 2.41.0 [-- Attachment #4: 0003-testing-lisp-test-ob-comint.el-Make-test-for-echo-fi.patch --] [-- Type: application/octet-stream, Size: 1962 bytes --] From 44bccab228b9dee80672b3a3dd9d27b2cc26c4b3 Mon Sep 17 00:00:00 2001 From: Matthew Trzcinski <matt@excalamus.com> Date: Sun, 17 Mar 2024 16:56:43 +0100 Subject: [PATCH 3/7] testing/lisp/test-ob-comint.el: Make test for echo filter * test-ob-comint.el: (test-org-babel-comint/echo-filter-removes-echo): Test that echoed input is removed from process buffer output. --- testing/lisp/test-ob-comint.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/testing/lisp/test-ob-comint.el b/testing/lisp/test-ob-comint.el index 9193ef8f3..8f6def8ca 100644 --- a/testing/lisp/test-ob-comint.el +++ b/testing/lisp/test-ob-comint.el @@ -49,6 +49,26 @@ ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59 \"hello world\" ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59")))) +(ert-deftest test-org-babel-comint/echo-filter-removes-echo () + "Test that echo is actually removed." + (let* ((echo "echo 'ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59' +# print message +echo \"hello world\" +echo 'ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59'") + (result "org_babel_sh_prompt> echo 'ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59' +# print message +echo \"hello world\" +echo 'ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59' +ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59 +org_babel_sh_prompt> org_babel_sh_prompt> \"hello world\" +org_babel_sh_prompt> ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59 +org_babel_sh_prompt> ")) + (should (string= + (org-babel-comint--echo-filter result echo) + "\nob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59 +org_babel_sh_prompt> org_babel_sh_prompt> \"hello world\" +org_babel_sh_prompt> ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59 +org_babel_sh_prompt> ")))) (provide 'test-ob-comint) -- 2.41.0 [-- Attachment #5: 0004-lisp-ob-comint.el-Create-comint-echo-filter.patch --] [-- Type: application/octet-stream, Size: 1203 bytes --] From c629cb7041d25480cba82812ba5da41329f4e435 Mon Sep 17 00:00:00 2001 From: Matthew Trzcinski <matt@excalamus.com> Date: Sun, 17 Mar 2024 16:58:52 +0100 Subject: [PATCH 4/7] lisp/ob-comint.el: Create comint echo filter * lisp/ob-comint.el (org-babel-comint--echo-filter): Extract echo filtering logic from `org-babel-comint-with-output' into a new function. --- lisp/ob-comint.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lisp/ob-comint.el b/lisp/ob-comint.el index 882e19289..e8d8e7609 100644 --- a/lisp/ob-comint.el +++ b/lisp/ob-comint.el @@ -87,6 +87,15 @@ PROMPT-REGEXP defaults to `comint-prompt-regexp'." separator string))) (delete "" (split-string string separator)))) +(defun org-babel-comint--echo-filter (string &optional echo) + "Remove ECHO from STRING." + (and echo string + (string-match + (replace-regexp-in-string "\n" "[\r\n]+" (regexp-quote echo)) + string) + (setq string (substring string (match-end 0)))) + string) + (defmacro org-babel-comint-with-output (meta &rest body) "Evaluate BODY in BUFFER and return process output. Will wait until EOE-INDICATOR appears in the output, then return -- 2.41.0 [-- Attachment #6: 0005-lisp-ob-comint.el-Refactor-org-babel-comint-with-out.patch --] [-- Type: application/octet-stream, Size: 3632 bytes --] From f9821b7ff50aeae096be2ebb55f6d920c0afa1e0 Mon Sep 17 00:00:00 2001 From: Matthew Trzcinski <matt@excalamus.com> Date: Sun, 17 Mar 2024 18:24:43 +0100 Subject: [PATCH 5/7] lisp/ob-comint.el: Refactor `org-babel-comint-with-output' * lisp/ob-comint.el (org-babel-comint-with-output): Replace logic for prompt and echo filtering with `org-babel-comint--prompt-filter' and `org-babel-comint--echo-filter'. Delete `org-babel-comint-prompt-separator' variable and move related comment to `org-babel-comint--prompt-filter'. --- lisp/ob-comint.el | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/lisp/ob-comint.el b/lisp/ob-comint.el index e8d8e7609..d13aacccc 100644 --- a/lisp/ob-comint.el +++ b/lisp/ob-comint.el @@ -79,6 +79,9 @@ This is useful when prompt unexpectedly changes." PROMPT-REGEXP defaults to `comint-prompt-regexp'." (let* ((prompt-regexp (or prompt-regexp comint-prompt-regexp)) + ;; We need newline in case if we do progressive replacement + ;; of agglomerated comint prompts with `comint-prompt-regexp' + ;; containing ^. (separator "org-babel-comint--prompt-filter-separator\n")) (while (string-match-p prompt-regexp string) (setq string @@ -112,12 +115,7 @@ or user `keyboard-quit' during execution of body." (let ((buffer (nth 0 meta)) (eoe-indicator (nth 1 meta)) (remove-echo (nth 2 meta)) - (full-body (nth 3 meta)) - (org-babel-comint-prompt-separator - ;; We need newline in case if we do progressive replacement - ;; of agglomerated comint prompts with `comint-prompt-regexp' - ;; containing ^. - "org-babel-comint-prompt-separator\n")) + (full-body (nth 3 meta))) `(org-babel-comint-in-buffer ,buffer (let* ((string-buffer "") (comint-output-filter-functions @@ -161,31 +159,12 @@ or user `keyboard-quit' during execution of body." (goto-char (process-mark (get-buffer-process (current-buffer)))) (insert dangling-text) + ;; remove echo'd FULL-BODY from input + (and ,remove-echo ,full-body + (setq string-buffer (org-babel-comint--echo-filter string-buffer ,full-body))) + ;; Filter out prompts. - (while (string-match-p comint-prompt-regexp string-buffer) - (setq string-buffer - (replace-regexp-in-string - ;; Sometimes, we get multiple agglomerated - ;; prompts together in a single output: - ;; "prompt prompt prompt output" - ;; Or even "<whitespace>prompt<whitespace>prompt ...>. - ;; Remove them progressively, so that - ;; possible "^" in the prompt regexp gets to - ;; work as we remove the heading prompt - ;; instance. - (format "\\(?:%s\\)?\\(?:%s\\)[ \t]*" ,org-babel-comint-prompt-separator comint-prompt-regexp) - ,org-babel-comint-prompt-separator - string-buffer))) - ;; remove echo'd FULL-BODY from input - (when (and ,remove-echo ,full-body - (string-match - (replace-regexp-in-string - "\n" "[\r\n]+" (regexp-quote (or ,full-body ""))) - string-buffer)) - (setq string-buffer (substring string-buffer (match-end 0)))) - (delete "" (split-string - string-buffer - ,org-babel-comint-prompt-separator)))))) + (org-babel-comint--prompt-filter string-buffer))))) (defun org-babel-comint-input-command (buffer cmd) "Pass CMD to BUFFER. -- 2.41.0 [-- Attachment #7: 0006-testing-lisp-test-ob-shell.el-Test-async-prompt-remo.patch --] [-- Type: application/octet-stream, Size: 2036 bytes --] From 4f943d1e72c1e32f02723a53d4d8f5ee201dfbbb Mon Sep 17 00:00:00 2001 From: Matthew Trzcinski <matt@excalamus.com> Date: Sun, 17 Mar 2024 18:27:11 +0100 Subject: [PATCH 6/7] testing/lisp/test-ob-shell.el: Test async prompt removal * testing/lisp/test-ob-shell.el (test-ob-shell/session-async-results): Create test verifying bug report that shell prompt appears in async results. --- testing/lisp/test-ob-shell.el | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el index 879555af0..8cebd8467 100644 --- a/testing/lisp/test-ob-shell.el +++ b/testing/lisp/test-ob-shell.el @@ -129,6 +129,30 @@ echo 2<point> (if (should (string= ": 1\n: 2\n" (buffer-substring-no-properties (point) (point-max)))) (kill-buffer session-name))))) +(ert-deftest test-ob-shell/session-async-results () + "Test that async evaluation removes prompt from results." + (let* ((session-name "test-ob-shell/session-async-results") + (kill-buffer-query-functions nil) + (start-time (current-time)) + (wait-time (time-add start-time 3)) + uuid-placeholder) + (org-test-with-temp-text + (concat "#+begin_src sh :session " session-name " :async t +# print message +echo \"hello world\"<point> +#+end_src") + (setq uuid-placeholder (org-trim (org-babel-execute-src-block))) + (catch 'too-long + (while (string-match uuid-placeholder (buffer-string)) + (progn + (sleep-for 0.01) + (when (time-less-p wait-time (current-time)) + (throw 'too-long (ert-fail "Took too long to get result from callback")))))) + (search-forward "#+results") + (beginning-of-line 2) + (if (should (string= ": hello world\n" (buffer-substring-no-properties (point) (point-max)))) + (kill-buffer session-name))))) + (ert-deftest test-ob-shell/generic-uses-no-arrays () "Test generic serialization of array into a single string." (org-test-with-temp-text -- 2.41.0 [-- Attachment #8: 0007-lisp-ob-comint.el-Fix-prompt-appearing-in-async-shel.patch --] [-- Type: application/octet-stream, Size: 1546 bytes --] From abe14703390e9ae56829a118c3d4e488443f6845 Mon Sep 17 00:00:00 2001 From: Matthew Trzcinski <matt@excalamus.com> Date: Sun, 17 Mar 2024 19:04:39 +0100 Subject: [PATCH 7/7] lisp/ob-comint.el: Fix prompt appearing in async shell results * lisp/ob-comint.el (org-babel-comint-async-filter): Call prompt `org-babel-comint--prompt-filter' Reported-by: "Matthew Trzcinski" <matt@excalamus.com> Link: https://list.orgmode.org/18d753c1e8a.cfb3e1921191837.5665565128507976741@excalamus.com/ --- lisp/ob-comint.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lisp/ob-comint.el b/lisp/ob-comint.el index d13aacccc..f2251892a 100644 --- a/lisp/ob-comint.el +++ b/lisp/ob-comint.el @@ -325,9 +325,10 @@ STRING contains the output originally inserted into the comint buffer." until (and (equal (match-string 1) "start") (equal (match-string 2) uuid)) finally return (+ 1 (match-end 0))))) - ;; Apply callback to clean up the result - (res-str (funcall org-babel-comint-async-chunk-callback - res-str-raw))) + ;; Remove prompt + (res-promptless (org-trim (string-join (mapcar #'org-trim (org-babel-comint--prompt-filter res-str-raw)) "\n") "\n")) + ;; Apply user callback + (res-str (funcall org-babel-comint-async-chunk-callback res-promptless))) ;; Search for uuid in associated org-buffers to insert results (cl-loop for buf in org-buffers until (with-current-buffer buf -- 2.41.0
Damien Cassou <damien@cassou.me> writes: > In my unit tests, I don't want to see any LaTeX-related warnings because > they don't use that. I thus changed my unit-tests to force :with-latex > to be 'verbatim. But this still requires this patch. It would be nice to attach the patch :) -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>
William Denton <william@williamdenton.org> writes: > On Saturday, March 16th, 2024 at 14:56, Ihor Radchenko <yantar92@posteo.net> wrote: > >> Did you try setting org-highlight-latex-and-related to nil? > > That did it! Thank you! Org is back to normal, fast and responsive. What do you make of all this? Was it just something about my individual setup? > (In fact I now have it set to '(script entities). Both 'latex and 'native gave me the problems, but this works.) That's because `org-latex-regexps' is a bit too complex for Emacs regexp engine in some cases. For some unfortunate Org files, these regexps may trigger stack overflow while matching. Eventually, we will switch to parser-based fontification, and the problem will be solved. For now, I have no clue how to simplify the problematic regexps without risking regressions. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>
Remember to cover the basics, that is, what you expected to happen and what in fact did happen. You don't know how to make a good report? See https://orgmode.org/manual/Feedback.html#Feedback Your bug report will be posted to the Org mailing list. ------------------------------------------------------------------------ In my unit tests, I don't want to see any LaTeX-related warnings because they don't use that. I thus changed my unit-tests to force :with-latex to be 'verbatim. But this still requires this patch. Emacs : GNU Emacs 29.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.41, cairo version 1.18.0) Package: Org mode version 9.6.21 ( @ /nix/store/m6x04fr6nmhxk44qr0m8xsyr8vapppgr-emacs-packages-deps/share/emacs/site-lisp/elpa/org-9.6.21/) -- Damien Cassou "Success is the ability to go from one failure to another without losing enthusiasm." --Winston Churchill
Rudi C <rudiwillalwaysloveyou@gmail.com> writes: > Thanks, that works great. Can these work with ID links, too? > (`[[id:9bbb6468-2907-4e74-a4d1-2e391e33e0fe::...]]`) Yes, on the latest main, where we support search strings in id: links. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>
On Saturday, March 16th, 2024 at 14:56, Ihor Radchenko <yantar92@posteo.net> wrote: > Did you try setting org-highlight-latex-and-related to nil? That did it! Thank you! Org is back to normal, fast and responsive. What do you make of all this? Was it just something about my individual setup? (In fact I now have it set to '(script entities). Both 'latex and 'native gave me the problems, but this works.) Thanks again, Bill -- William Denton https://www.miskatonic.org/ Librarian, artist and licensed private investigator. Toronto, Canada
Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
> The document header was not the problem, as it happened with any
> file. The core of the issue is that the org version used to initiate the
> export must be the same than the org version run in the asynchronous
> export process, as bytecode from org is passed between them (and in my
> case this bytecode was mentioning a recently introduced org function
> that is not available in the org shipped with emacs). Making sure the
> async init file loaded the same org version than the one I use everyday
> solved the problem.
>
> Alan
>
Hi Alan, how did you effectively solve the problem?
I'm experiencing the same.
I tried to add the recent org folder that I use to the load-path after loading 'ox, but it does not work.
--
Nasser Alkmim
+43 677 6408 9171
Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
> The document header was not the problem, as it happened with any
> file. The core of the issue is that the org version used to initiate the
> export must be the same than the org version run in the asynchronous
> export process, as bytecode from org is passed between them (and in my
> case this bytecode was mentioning a recently introduced org function
> that is not available in the org shipped with emacs). Making sure the
> async init file loaded the same org version than the one I use everyday
> solved the problem.
>
> Alan
>
Hi Alan, how did you effectively solve the problem?
I'm experiencing the same.
I tried to add the recent org folder that I use to the load-path after loading 'ox, but it does not work.
--
Nasser Alkmim
+43 677 6408 9171
[-- Attachment #1: Type: text/plain, Size: 1158 bytes --] Thanks, that works great. Can these work with ID links, too? (`[[id:9bbb6468-2907-4e74-a4d1-2e391e33e0fe::...]]`) On Sun, Mar 17, 2024 at 4:47 PM Ihor Radchenko <yantar92@posteo.net> wrote: > Rudi C <rudiwillalwaysloveyou@gmail.com> writes: > > > How do I link to a specific line in an org-babel block? > > a.org: > > #+begin_src emacs-lisp > (message "Hello world!") > (message "Hello other worlds!!!") ; (ref:greetworlds) > #+end_src > > b:org > [[./a.org::(greetworlds)]] > > See https://orgmode.org/manual/Literal-Examples.html > > > I tried using [[file:.../my.org::search-term]] , but this only works for > > jumping to a heading, not an arbitrary line. (It does work for non-org > > files.) > > That's because "search-term" is used for fuzzy search, which is limited > to headings by default. You can customize > `org-link-search-must-match-exact-headline' to change this. > > -- > Ihor Radchenko // yantar92, > Org mode contributor, > Learn more about Org mode at <https://orgmode.org/>. > Support Org development at <https://liberapay.com/org-mode>, > or support my work at <https://liberapay.com/yantar92> > [-- Attachment #2: Type: text/html, Size: 2021 bytes --]
---- On Sun, 17 Mar 2024 17:26:48 +0100 Max Nikulin wrote --- > On 17/03/2024 20:42, Matt wrote: > > ---- On Sun, 17 Mar 2024 11:31:00 +0100 Ihor Radchenko wrote --- > > > > > > (1) revert the commit; (2) re-apply the > > > commit version with the correct author attribution. > > > > Done. > > > > 1. git revert > > 2. make changes (e.g. emacs followed by *type-type-type* or some incantation of 'git apply' or 'git am') > > 3. git commit --author "Arthur Author " > > In this particular case "git am" works fine and no explicit "git commit" > is necessary. Thank you for taking the time to verify the patch formatting. Sounds like a PEBKAC. I'll look into fixing it :) -- Matt Trzcinski Emacs Org contributor (ob-shell) Learn more about Org mode at https://orgmode.org Support Org development at https://liberapay.com/org-mode