Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Lars Ingebrigtsen writes: > Eli Zaretskii writes: > >>> This doesn't work: >>> M-x shell RET xdg-open /tmp/test.pdf RET >> >> How about asking the xdg-open developers to help us figure out the >> reason? Or, failing that, debug xdg-open in the problematic >> situations to find out what fails there and why? E.g., could it be >> that it fails because stdin/stdout is a PTY? what happens if you bind >> process-connection-type to nil when starting the async subprocess? > > I'm unable to reproduce the problem at all -- all the various ways of > calling xdg-open work fine for me (on this Debian bullseye laptop w/ > Gnome Shell). For me, I get M-! xdg-open /tmp/test.pdf works M-x shell xdg-open /tmp/test.pdf works M-& xdg-open /tmp/test.pdf fails M-x eshell xdg-open /tmp/test.pdf fails The two which fail do not report any error - just now pdf viewer open. I also have no problems with org export menu when I choose export to pdf and open. This was on a Ubuntu 20.10, latest Emacs 27 (27.5.91), mate DE and default shell zsh. -- Tim Cross
bug#44824: 27.1; Org export as pdf and open file does not open it
Eli Zaretskii writes: >> This doesn't work: >> M-x shell RET xdg-open /tmp/test.pdf RET > > How about asking the xdg-open developers to help us figure out the > reason? Or, failing that, debug xdg-open in the problematic > situations to find out what fails there and why? E.g., could it be > that it fails because stdin/stdout is a PTY? what happens if you bind > process-connection-type to nil when starting the async subprocess? I'm unable to reproduce the problem at all -- all the various ways of calling xdg-open work fine for me (on this Debian bullseye laptop w/ Gnome Shell). -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no
Re: org-goto and org-store-link/org-id-get-create
Peter Klenner writes: > Calling either org-store-link or org-id-get-create in an indirect > org-goto buffer results in an empty ID-property drawer with (setq > org-id-link-to-org-use-id t). Confirmed. This is because org-goto buffer is in read-only state, which is ignored when inserting empty property drawer, but respected when trying to insert :ID: property, which is indeed inconsistent. Currently, the following functions disregard the read-only state in org buffers: org-store-log-note, org-insert-property-drawer, org-agenda-undo, org-agenda-todo, org-agenda-add-note, org-agenda-priority, org-agenda-set-tags, org-agenda-set-property, org-agenda-set-effort, org-agenda-toggle-archive-tag, and org-columns-store-format. A fix to this particular issue could be using org-no-read-only in org-entry-put. Though more functions may suffer from similar issues in read-only org buffers. Best, Ihor
Re: org-attach-git don't automatically commit changes
Juan Manuel Macías writes: > The default value of `org-attach-id-dir' is "data/", and if I evaluate > `(expand-file-name org-attach-id-dir)' on my current node, it returns a > wrong path to the attached folder. `org-attach-sync' only works for me > if I set in `org-attach-git-commit' the variable like this: Does it mean that your attachment folder is set in :DIR: property? > #+begin_src emacs-lisp > ;; ... > (let* ((dir (expand-file-name org-attach-id-dir)) > ;; ... > #+end_src I suspect that it is a leftover from the major changes in org-attach when :DIR: property was introduced. The org-attach-git presumes that all the attachments in current file are stored in sub-directories located inside org-attach-id-dir, which is no longer guaranteed. In fact, the existing approach to treat all the attachments to all headings in current file as files in a single git repo cannot be used. I can see two possible fixes: 1. Treat each attachment dir as individual git repo (breaking change for those who are using :ID: property to build the attachment dirs) 2. Treat attachment dirs defined by :DIR: property individually and leave the :ID:-defined attachments as they were treated before (inconsistent). I am in favour of the first approach since I do not like the idea of keeping all the attachments in the whole file in a single git repo. I think feedback from other is needed to decide what we need to do here. P.S. Marking this as a bug. Best, Ihor
clock-table and hooking that into org-capture file+olp+datetree
Hello everyone! Here's a reasonably easy (I think) question because I'm quite new to Emacs and org-mode. I have an org-capture template using file+olp+datetree[1], which works great at filing my thoughts for the day. Separately I know I can generate clock tables[2] based on dynamic blocks to show me what I've been doing with my time for any given period. What I'm struggling with is to glue parts of these together to achieve the following: 1. I org-capture to the datetree. When it does so it either creates or updates an org-clock-report at the top of the datetree header (the bit that says "2020-11-12 Thursday", for example.) I guess this would be the parent of what I'm capturing. 2. For all my historical journal entries, if I could move point to a headline with a date such as the example below and it would pull the date out and add a clocktable below via an interactive function that would be my ideal. This is less of a problem for me as I don't have much in the way of history in my diary yet or my other org files. An example tree would be #+BEGIN_QUOTE * Work ** 2021 *** 2021-01 January 2021-01-07 Thursday * Ate some chips * Drank some soda #+END_QUOTE I tried looking at the org-mode source, and it is too advanced for me to follow. The closest I can get (or at least here's a scrap of code to prove I did actually try) is as follows: #+BEGIN_SRC emacs-lisp (defun cc/create-or-update-effort-table () (save-excursion (find-file (concat org-directory "/diary.org")) (goto-char (org-find-olp (list (concat org-directory "/diary.org" ) "Work" "2021" "2021-01 January" "2021-01-07 Thursday"))) (beginning-of-line) (next-line) (if (looking-at-p "[[:space:]]*#\\+BEGIN: clocktable") (forward-word 3) (progn (insert "\n")(previous-line))) (org-clock-report))) #+END_SRC A lot of beginner missteps there that I'm sure people can correct, but hopefully you can see the intent. If you see anything amiss please let me know, but my main problems are: 1. I hardcoded the datetree part whereas I'd like this to be today's date or even the date picker built into org-mode. I am very far off using the datepicker to generate ("%Y" "%Y-%m %B" "%Y-%m-%d %A") [3] or even from today's date. 2. I obviously don't understand how markers work well enough because I had to add the ~find-file~ whereas I would imagine you could just do it all in the goto-char line, if I knew how to use markers better . 3. The function would fail if the tree doesn't exist. I'd like it created like org-capture would. Not all clocked items are in my diary, so I may want to run the function before any diary items exist for today. 4. I would like to customize the variables org-clock-report uses to generate the report. It looks to be assigned by the defaults ~org-clocktable-defaults~. The ~:block~ option is the obvious option I'd like to change to a set date. In other words, I want to change the options in the function above but not use org-clocktable-defaults unless it reverts after the function is finished. 5. Even if the function above worked, I have no idea how to hook that into file+olp+datetree. Would I need to switch to file+function and add the clock table as a side-effect? The function cc/create-or-update-effort-table has to use olp, not headline, as the headline "2021-01-07 Thursday" is not unique in the file. Thank you for taking the time to read this far, and thank you to all the people who've contributed to Emacs and Org-Mode. I wish I'd discovered them sooner. Christopher. [1] https://orgmode.org/manual/Template-elements.html [2] https://orgmode.org/manual/The-clock-table.html [3] https://man7.org/linux/man-pages/man1/date.1.html The links are for my benefit when I come back to this email, rather than anyone else's, but I guess it doesn't hurt to include them for other people new to org-mode like myself.
[PATCH] ox-md.el export code blocks using grave accents
[PATCH] ox-md.el export code blocks using grave accents. This patch includes the following changes in =ox-md.el= + =org-md-example-block= now exports code blocks using triple grave accents instead of four spaces of indentation. This has been done for two main reasons: 1. To be able to include the language so that Markdown engines can syntax highlight the content of code blocks 2. To be able to put the source code and the results of evaluation in different code blocks. When using indentation, both the source code and the results are shown in the same code block by Markdown engines. + The variable =org-md-lang-export= is now included in order to map Org Mode language names to Markdown language names. The file =mre.org= contains a minimal reproducible example; =mre.md= , the resulting file when exporting using the current version; and =mre-patched.md=, the resulting file when exporting with the changes of this patch applied. The patch is shown below. #+begin_src dash :dir (progn default-directory) :epilogue ":" diff -u ox-md.el ox-md-patched.el #+end_src #+RESULTS: #+begin_example --- ox-md.el2021-01-28 22:18:51.566067501 -0500 +++ ox-md-patched.el2021-01-28 22:14:34.762735829 -0500 @@ -50,6 +50,14 @@ (const :tag "Use \"atx\" style" atx) (const :tag "Use \"Setext\" style" setext))) +(defcustom org-md-lang-export + '(("dash" . "sh")) + "Alist mapping languages to the corresponding language names in Markdown." + :group 'org-export-md + :type '(repeat + (cons + (string "Org Mode language name") + (string "Markdown language name" Footnotes @@ -181,10 +189,24 @@ "Transcode EXAMPLE-BLOCK element into Markdown format. CONTENTS is nil. INFO is a plist used as a communication channel." - (replace-regexp-in-string - "^" "" - (org-remove-indentation -(org-export-format-code-default example-block info + (let* (language +(org-language + (plist-get (car (cdr example-block)) :language)) +(markdown-language + (cdr (assoc org-language org-md-lang-export))) ; +(content + (org-remove-indentation + (org-export-format-code-default example-block info + +(if markdown-language + (setq language markdown-language) + (setq language org-language)) + +(setq content (replace-regexp-in-string + "\\`" (concat "```" language "\n") + content)) + +(replace-regexp-in-string "\\'" "```" content))) (defun org-md-export-block (export-block contents info) "Transcode a EXPORT-BLOCK element from Org to Markdown. #+end_example -- Greetings, Rodrigo Morales.
bug#44824: 27.1; Org export as pdf and open file does not open it
On Sat, 30 Jan 2021 at 19:04, Maxim Nikulin wrote: > […] > > Geraldo, "M-x shell" case is rather strange. Could you, please, confirm > ones more that okular window with the file content does not appear if > you call xdg-open from an *interactive* emacs shell buffer? The link to > an emacs-orgmode list message, that I have posted earlier, explains why > async-shell-command *may* fail while shell-command should work reliably. > I am really surprised by failure when command is executed in a [e]shell > buffer. > I was expecting something similar, surprisingly here is what I observed on my system (with emacs -Q, GNOME and Evince — Document Viewer). M-x eshell $ xdg-open ~/Documents/test.pdf [Nothing happens] M-x shell $ xdg-open ~/Documents/test.pdf [Evince pops up with the PDF] M-! xdg-open ~/Documents/test.pdf [Evince pops up with the PDF] M-& xdg-open ~/Documents/test.pdf [Nothing happens] Emacs: 27.1.91 GNOME: 3.38.3 xdg-open 1.1.3+ -- Warm Regards, Bhavin Gandhi (bhavin192) | https://geeksocket.in
Re: [PATCH] ox-md.el export code blocks using grave accents
Sorry for not attaching the files. Here they are. # Table of Contents When exporting the following code block using indentation, it is not possible to know where the source code ends and the results of evaluation starts. echo "echo ab" echo "seq 1 2" echo ab seq 1 2 The language of the following code block will be `sh` because `dash` doesn't belong to `org-md-lang-export` result=0 for i in $(seq 1 5) do for j in $(seq 1 5) do result=$((result + i + j)) done done echo "$result" 150 The language of the following code block will be the same as the one used in Org Mode because `R` doesn't belong to `org-md-lang-export` data(Loblolly) max(Loblolly $ height) [1] 64.1 # Table of Contents When exporting the following code block using indentation, it is not possible to know where the source code ends and the results of evaluation starts. ```sh echo "echo ab" echo "seq 1 2" ``` ``` echo ab seq 1 2 ``` The language of the following code block will be `sh` because `dash` doesn't belong to `org-md-lang-export` ```sh result=0 for i in $(seq 1 5) do for j in $(seq 1 5) do result=$((result + i + j)) done done echo "$result" ``` ``` 150 ``` The language of the following code block will be the same as the one used in Org Mode because `R` doesn't belong to `org-md-lang-export` ```R data(Loblolly) max(Loblolly $ height) ``` ``` [1] 64.1 ``` mre.org Description: Lotus Organizer --- ox-md.el 2021-01-28 22:18:51.566067501 -0500 +++ ox-md-patched.el 2021-01-28 22:14:34.762735829 -0500 @@ -50,6 +50,14 @@ (const :tag "Use \"atx\" style" atx) (const :tag "Use \"Setext\" style" setext))) +(defcustom org-md-lang-export + '(("dash" . "sh")) + "Alist mapping languages to the corresponding language names in Markdown." + :group 'org-export-md + :type '(repeat + (cons + (string "Org Mode language name") + (string "Markdown language name" Footnotes @@ -181,10 +189,24 @@ "Transcode EXAMPLE-BLOCK element into Markdown format. CONTENTS is nil. INFO is a plist used as a communication channel." - (replace-regexp-in-string - "^" "" - (org-remove-indentation -(org-export-format-code-default example-block info + (let* (language + (org-language + (plist-get (car (cdr example-block)) :language)) + (markdown-language + (cdr (assoc org-language org-md-lang-export))) ; + (content + (org-remove-indentation + (org-export-format-code-default example-block info + +(if markdown-language + (setq language markdown-language) + (setq language org-language)) + +(setq content (replace-regexp-in-string + "\\`" (concat "```" language "\n") + content)) + +(replace-regexp-in-string "\\'" "```" content))) (defun org-md-export-block (export-block contents info) "Transcode a EXPORT-BLOCK element from Org to Markdown. -- Greetings, Rodrigo Morales.
bug#45915: 27.1.91; deletechar distorts org-table
I confirm that there still is following problem on 27.1.91. Could someone take a look and show me work around? > I am using emacs 27.1 with orgtbl-mode. On certain condition, typing > distorts alighment of a table. Then, typing moves > previous line but far right position. > > | | rownames | | | rownames | > | / | | | / | | > |---+--| -> |---+--| > | / | a| | | a| > > Here is a recipe to reproduce the glitch started from emcas -Q. I > hope that together with bug#45091, this would be fixed before 27.2. > > 1. Create a buffer with (text-mode) and yank following table. > > | | rownames | > | / | | > |---+--| > | | a| > > 2. (progn (require 'org) (call-interactively 'orgtbl-mode)) > 3. Move point to the first column and the third line with letter 'a'. > 4. Hit . > 5. Hit . > 6. Hit .
Re: [PATCH] ox-md.el export code blocks using grave accents.
Tim Cross writes: > I don't think this patch is correct. > > From your explanation, I suspect what you really need is to use the > github flavoured markdown package available as ox-gfm on MELPA rather > than the default ox-md package in org mode. Thank you very much for the detailed information. Didn't know much of the things you mentioned. I mainly wrote the patch because most of the times I wrote Markdown for answering questions in Stack Exchange and writing issues in Github and these changes were really helpful to me. I wouldn't have done this if I had known of "ox-gfm", which I suppose solve some of my needs (I will check it out later). Next time I will make sure to read the relevant part in the Info manual and search some related keywords in the mailing list archive. -- Greetings, Rodrigo Morales.
Re: [PATCH] ox-md.el export code blocks using grave accents.
I don't think this patch is correct. There are no precise standards for markdown, but org states in the manual that the version of markdown it supports is that defined at http://daringfireball.net/projects/markdown - which uses the indentation style for code blocks, not the style. Note that there is the github markdown exporter which does support the style. One of the problems with markdown is the differing flavours out there. While may be supported on sites like github and stackoverflow, other sites only support the indentation style. We therefore need to be somewhat conservative with respect to introducing changes as while we may 'fix' things for some sites, we could easily break them for others. Given there is a package which supports the style code blocks, I don't think modifying the existing markdown exporter is necessary. >From your explanation, I suspect what you really need is to use the github flavoured markdown package available as ox-gfm on MELPA rather than the default ox-md package in org mode. Note that I have no particular preference for the markdown style defined on daringfireball.net and there has been past discussions on this list regarding what flavour of markdown org should support, so I know there are varying opinions in this area. My main point is that if we specify in the manual that we support a particular flavour, then that is the flavour of markdown we should support. In other words, if we are going to add features/support for syntax not defined on the daringfireball.net flavour of markdown, we would need to document what syntax we do support and consider things like backwards compatibility for any changes introduce. Rodrigo Morales writes: > This patch includes the following changes in =ox-md.el= > > + =org-md-example-block= now exports code blocks using triple grave > accents instead of four spaces of indentation. This has been done > for two main reasons: > > 1. To be able to include the language so that Markdown engines can > syntax highlight the content of code blocks. Syntax highlighting > can also occur when using indentation in some websites (see > [[https://meta.stackexchange.com/questions/184108][this]]. However, > this method doesn't work in all websites (I haven't found > information about this on Github.). Therefore, using grave accents > is more generic. > > 2. To be able to put the source code and the results of evaluation > in different code blocks. When using indentation, both the source > code and the results are shown in the same code block by Markdown > engines. > > + The variable =org-md-lang-export= is now included in order to map > Org Mode language names to Markdown language names. > > The file =mre.org= contains a minimal reproducible example; =mre.md= , > the resulting file when exporting using the current version; and > =mre-patch.md=, the resulting file when exporting with the changes > of this patch applied. > > The patch is shown below. > > #+begin_src dash :dir (progn default-directory) :epilogue ":" > gunzip -c /usr/share/emacs/27.1/lisp/org/ox-md.el.gz > ox-md.el > diff -u ox-md.el ox-md-patched.el > #+end_src > > #+RESULTS: > #+begin_example > --- ox-md.el 2021-01-30 16:49:33.459042367 -0500 > +++ ox-md-patched.el 2021-01-30 16:48:40.232375347 -0500 > @@ -50,6 +50,14 @@ > (const :tag "Use \"atx\" style" atx) > (const :tag "Use \"Setext\" style" setext))) > > +(defcustom org-md-lang-export > + '(("dash" . "sh")) > + "Alist mapping languages to the corresponding language names in Markdown." > + :group 'org-export-md > + :type '(repeat > + (cons > +(string "Org Mode language name") > +(string "Markdown language name" > > Footnotes > > @@ -181,10 +189,24 @@ >"Transcode EXAMPLE-BLOCK element into Markdown format. > CONTENTS is nil. INFO is a plist used as a communication > channel." > - (replace-regexp-in-string > - "^" "" > - (org-remove-indentation > -(org-export-format-code-default example-block info > + (let* (language > + (org-language > + (plist-get (car (cdr example-block)) :language)) > + (markdown-language > + (cdr (assoc org-language org-md-lang-export))) ; > + (content > + (org-remove-indentation > +(org-export-format-code-default example-block info > + > +(if markdown-language > + (setq language markdown-language) > + (setq language org-language)) > + > +(setq content (replace-regexp-in-string > + "\\`" (concat "```" language "\n") > + content)) > + > +(replace-regexp-in-string "\\'" "```" content))) > > (defun org-md-export-block (export-block contents info) >"Transcode a EXPORT-BLOCK element from Org to Markdown. > #+end_example -- Tim Cross
Re: [bug] Exporting results in "Wrong type argument" when "+CALL" is used
I forgot including the attachments, they are included in this reply. Sorry about that. (require 'ox-md) (setq org-confirm-babel-evaluate nil) (org-babel-do-load-languages 'org-babel-load-languages '((shell . t))) main.org Description: Lotus Organizer -- Greetings, Rodrigo Morales.
Re: How to avoid generating the Table of Contents when exporting to markdown?
Thanks for the help :) After searching the information you mentioned in the Info manual of Org Mode, I found information on the variable =org-export-with-toc= and have included the following in my configuration. #+begin_src elisp (setq org-export-with-toc nil) #+end_src -- Greetings, Rodrigo Morales.
[bug] Exporting results in "Wrong type argument" when "+CALL" is used
As the subject states, executing some exporting commands (see list in step 2 below) results in an error when there is at least one "#+CALL" statement. The backtrace is shown below. #+begin_example Debugger entered--Lisp error: (wrong-type-argument consp nil) org-babel-exp-code(nil lob) org-babel-exp-do-export(nil lob) org-babel-exp-process-buffer() org-export-as(md nil nil nil nil) org-export-to-buffer(md "*Org MD Export*" nil nil nil nil nil #f(compiled-function () #)) org-md-export-as-markdown(nil nil nil) (lambda (a s v b) (org-md-export-as-markdown a s v))(nil nil nil nil) org-export-dispatch(nil) funcall-interactively(org-export-dispatch nil) call-interactively(org-export-dispatch nil nil) command-execute(org-export-dispatch) #+end_example You can reproduce this bug by 1. Open the file =main.org= by loading the =init.el= file (see attachments). You can accomplish this by executing the following command. #+begin_src sh emacs -Q -l ~/Downloads/init.el ~/Downloads/main.org #+end_src 2. Execute any of the following + =org-md-export-to-markdown=. + =org-latex-export-as-latex=. + =org-html-export-as-html=. 3. The error might occur. I'm currently using GNU Emacs 27.1 -- Greetings, Rodrigo Morales.
Re: How to avoid generating the Table of Contents when exporting to markdown?
Rodrigo Morales writes: > When answering questions in Emacs Stack Exchange, I usually write my answer > in Org Mode and then export it to Markdown so that I can copy it to the > answer textbox in Stack Exchange. For this reason, I don't need the > export to contain a Table of Contents because the Markdown content is > not big enough to require it. > > For this reason, I don't want the Table of Contents to be included when > exporting. You can try putting #+OPTIONS: toc:nil in the header of your org file. This is covered in the 'Table of Contents' sub-section of the Exporting section of the org manual. -- Tim Cross
Re: clock-table and hooking that into org-capture file+olp+datetree
Thanks again Richard. I now have a working solution which I share below, warts and all. One snag I hit that I feel I should mention is what I believe to be a mistake in the documentation[1]. I was scratching my head as why org-clocktable-defaults wasn't working, but it was only when I brought up the inline documentation that I see that this probably is some vestigial variableand it has since moved to org-clock-clocktable-default-properties. Is mentioning this here on the list enough or should I report it somewhere else? Christopher #+BEGIN_SRC emacs-lisp (defun org-date-to-list () "Run `org-read-date' and return it in the form '(mm dd ). This form is more useful for functions that require it in this format, such as `org-datetree-find-date-create'." (let* ((date-string (org-read-date)) (year (substring date-string 0 4)) (month (substring date-string 5 7)) (day (substring date-string 8 10))) (mapcar 'string-to-number (list month day year (defun org-update-clocktable-on-date (date) (let* ((year (number-to-string (nth 2 date))) (month (number-to-string (nth 0 date))) (day (number-to-string (nth 1 date))) (org-clock-clocktable-default-properties (list :scope 'agenda :maxlevel 6 :block (concat year "-" month "-" day (save-excursion ;; open the file containing the datetree: (find-file (concat org-directory "/diary.org")) ;; jump to the subtree for the given date: ;; note: date must look like (m d y) where all three values are integers (org-datetree-find-date-create date) ;; narrow to the subtree for this date, so we don't update ;; any other clocktables (org-narrow-to-subtree) ;; update the clock report, or create it if it doesn't exist ;; note: we pass a prefix argument to tell org-clock-report to ;; update the first clocktable it finds in the (narrowed) buffer (org-clock-report t) ;; widen to the whole buffer again (widen ;; Usage ; (org-update-clocktable-on-date (org-date-to-list)) #+END_SRC [1] Variable org-clocktable-defaults is mentioned here https://orgmode.org/manual/The-clock-table.html
Re: How to avoid generating the Table of Contents when exporting to markdown?
You can disable export of the TOC by setting the toc option to nil, with a line like this at the top of the file: #+options: toc:nil See https://orgmode.org/manual/Table-of-Contents.html --Diego On Sat, Jan 30, 2021 at 11:21 PM Rodrigo Morales < moralesrodrigo1...@gmail.com> wrote: > > When answering questions in Emacs Stack Exchange, I usually write my answer > in Org Mode and then export it to Markdown so that I can copy it to the > answer textbox in Stack Exchange. For this reason, I don't need the > export to contain a Table of Contents because the Markdown content is > not big enough to require it. > > For this reason, I don't want the Table of Contents to be included when > exporting. > > -- > Greetings, > Rodrigo Morales. > >
How to avoid generating the Table of Contents when exporting to markdown?
When answering questions in Emacs Stack Exchange, I usually write my answer in Org Mode and then export it to Markdown so that I can copy it to the answer textbox in Stack Exchange. For this reason, I don't need the export to contain a Table of Contents because the Markdown content is not big enough to require it. For this reason, I don't want the Table of Contents to be included when exporting. -- Greetings, Rodrigo Morales.
[PATCH] ox-md.el export code blocks using grave accents.
This patch includes the following changes in =ox-md.el= + =org-md-example-block= now exports code blocks using triple grave accents instead of four spaces of indentation. This has been done for two main reasons: 1. To be able to include the language so that Markdown engines can syntax highlight the content of code blocks. Syntax highlighting can also occur when using indentation in some websites (see [[https://meta.stackexchange.com/questions/184108][this]]. However, this method doesn't work in all websites (I haven't found information about this on Github.). Therefore, using grave accents is more generic. 2. To be able to put the source code and the results of evaluation in different code blocks. When using indentation, both the source code and the results are shown in the same code block by Markdown engines. + The variable =org-md-lang-export= is now included in order to map Org Mode language names to Markdown language names. The file =mre.org= contains a minimal reproducible example; =mre.md= , the resulting file when exporting using the current version; and =mre-patch.md=, the resulting file when exporting with the changes of this patch applied. The patch is shown below. #+begin_src dash :dir (progn default-directory) :epilogue ":" gunzip -c /usr/share/emacs/27.1/lisp/org/ox-md.el.gz > ox-md.el diff -u ox-md.el ox-md-patched.el #+end_src #+RESULTS: #+begin_example --- ox-md.el2021-01-30 16:49:33.459042367 -0500 +++ ox-md-patched.el2021-01-30 16:48:40.232375347 -0500 @@ -50,6 +50,14 @@ (const :tag "Use \"atx\" style" atx) (const :tag "Use \"Setext\" style" setext))) +(defcustom org-md-lang-export + '(("dash" . "sh")) + "Alist mapping languages to the corresponding language names in Markdown." + :group 'org-export-md + :type '(repeat + (cons + (string "Org Mode language name") + (string "Markdown language name" Footnotes @@ -181,10 +189,24 @@ "Transcode EXAMPLE-BLOCK element into Markdown format. CONTENTS is nil. INFO is a plist used as a communication channel." - (replace-regexp-in-string - "^" "" - (org-remove-indentation -(org-export-format-code-default example-block info + (let* (language +(org-language + (plist-get (car (cdr example-block)) :language)) +(markdown-language + (cdr (assoc org-language org-md-lang-export))) ; +(content + (org-remove-indentation + (org-export-format-code-default example-block info + +(if markdown-language + (setq language markdown-language) + (setq language org-language)) + +(setq content (replace-regexp-in-string + "\\`" (concat "```" language "\n") + content)) + +(replace-regexp-in-string "\\'" "```" content))) (defun org-md-export-block (export-block contents info) "Transcode a EXPORT-BLOCK element from Org to Markdown. #+end_example mre.org Description: Lotus Organizer # Table of Contents When exporting the following code block using indentation, it is not possible to know where the source code ends and the results of evaluation starts. echo "echo ab" echo "seq 1 2" echo ab seq 1 2 The language of the following code block will be `sh` because `dash` doesn't belong to `org-md-lang-export` result=0 for i in $(seq 1 5) do for j in $(seq 1 5) do result=$((result + i + j)) done done echo "$result" 150 The language of the following code block will be the same as the one used in Org Mode because `R` doesn't belong to `org-md-lang-export` data(Loblolly) max(Loblolly $ height) [1] 64.1 # Table of Contents When exporting the following code block using indentation, it is not possible to know where the source code ends and the results of evaluation starts. ```sh echo "echo ab" echo "seq 1 2" ``` ``` echo ab seq 1 2 ``` The language of the following code block will be `sh` because `dash` doesn't belong to `org-md-lang-export` ```sh result=0 for i in $(seq 1 5) do for j in $(seq 1 5) do result=$((result + i + j)) done done echo "$result" ``` ``` 150 ``` The language of the following code block will be the same as the one used in Org Mode because `R` doesn't belong to `org-md-lang-export` ```R data(Loblolly) max(Loblolly $ height) ``` ``` [1] 64.1 ``` --- ox-md.el 2021-01-28 22:18:51.566067501 -0500 +++ ox-md-patched.el 2021-01-28 22:14:34.762735829 -0500 @@ -50,6 +50,14 @@ (const :tag "Use \"atx\" style" atx) (const :tag "Use \"Setext\" style" setext))) +(defcustom org-md-lang-export + '(("dash" . "sh")) + "Alist mapping languages to the corresponding language names in Markdown." + :group 'org-export-md + :type '(repeat + (cons + (string "Org Mode language name") + (string "Markdown language name" Footnotes @@
table: unwrap org-table-wrap-region
Hi I use org-table-wrap-region a lot, however when I export to odt or docx this is not the best solution. So I would sometimes unwrap, join or merge cells, is this possible? Thanks and regards Uwe Brauer
Re: clock-table and hooking that into org-capture file+olp+datetree
Hi Christopher and all, "Christopher Causer" writes: >> Note that org-datetree-find-date has a slightly annoying interface, in >> that you need to provide a list of three integers representing a >> calendar date. > > Yes, that is a little awkward. What I did think of using was substrings to > extract the date from the picker interface. > > #+BEGIN_SRC emacs-lisp > (defun org-date-picker-to-list () > (let* ((date-string (org-read-date)) >(year (substring date-string 0 4)) >(month (substring date-string 5 7)) >(day (substring date-string 8 10))) > (mapcar 'string-to-number (list month day year > #+END_SRC > > Does that look sensible? As sensible as anything :) I recently added my version, using decode-time and nth, as a helper function to my .emacs. I feel sure that it must already exist *somewhere* in Emacs but I searched quite a while for it and didn't find it. I will use this again below: #+begin_src emacs-lisp (defun time-as-calendar-date (time) "Convert time in Emacs' time format to a calendar date list (MONTH DAY YEAR)" (let ((parsed-time (decode-time time))) (list (nth 4 parsed-time) (nth 3 parsed-time) (nth 5 parsed-time #+end_src > My two next things to tackle are > > 1. A hook to run the function when I run org-capture. Here you might find it useful to grab the value of the :default-time key from org-capture-plist (which should contain either the time you entered at the date prompt during capture, or the current time, in Emacs' time format). Then, using the functions above, you can say something like this in your hook: #+being_src emacs-lisp (let* ((default-time (plist-get org-capture-plist :default-time)) (date (time-as-calendar-date default-time))) (org-update-clocktable-on-date date)) #+end_src > 2. Changing the org-clock-report options in your function above, but not the > defaults. > > For the second point, is there some trick to swap a global variable for the > run of a function? The variable in this case would be org-clocktable-defaults. Emacs Lisp has dynamic scope by default, which makes this is pretty easy in general: just set the value you want to use in a let form around the code that uses this variable, like: (let ((org-clocktable-defaults your-custom-value-here)) ...) > Thank you so much Richard. You've probably saved me days of going through the > org-mode documentation and source. No problem! That's what this list is for. I recently spent a fair amount of time digging through the datetree stuff myself, so I was glad to have a chance to share what I learned. -- Best, Richard
bug#44824: 27.1; Org export as pdf and open file does not open it
Il 30/01/2021 14:31, Maxim Nikulin ha wrote: On 30/01/2021 15:42, Eli Zaretskii wrote: This works: M-! xdg-open /tmp/test.pdf RET This doesn't work: M-& xdg-open /tmp/test.pdf RET This doesn't work: M-x shell RET xdg-open /tmp/test.pdf RET Geraldo, "M-x shell" case is rather strange. Could you, please, confirm ones more that okular window with the file content does not appear if you call xdg-open from an *interactive* emacs shell buffer? The link to an emacs-orgmode list message, that I have posted earlier, explains why async-shell-command *may* fail while shell-command should work reliably. I am really surprised by failure when command is executed in a [e]shell buffer. I confirm. I can see the Okular icon appear and disappear immediately in the panel. As mentioned I can make a video of everything, but I have no idea where to upload it. If it is okay to make the video and you think it is useful please tell me which commands to execute for more information on the operating environment How about asking the xdg-open developers to help us figure out the reason? Or, failing that, debug xdg-open in the problematic situations to find out what fails there and why? E.g., could it be that it fails because stdin/stdout is a PTY? what happens if you bind process-connection-type to nil when starting the async subprocess? I do not think, it is xdg-open problem. It just calls kde-open5 that spawns actual handler and immediately exits.
Re: clock-table and hooking that into org-capture file+olp+datetree
On Sat, 30 Jan 2021, at 12:53, Richard Lawrence wrote: > #+begin_src emacs-lisp > (defun org-update-clocktable-on-date (date) > (save-excursion > ;; open the file containing the datetree: > (find-file (concat org-directory "/diary.org")) > ;; jump to the subtree for the given date: > ;; note: date must look like (m d y) where all three values are integers > (org-datetree-find-date-create date) > ;; narrow to the subtree for this date, so we don't update > ;; any other clocktables > (org-narrow-to-subtree) > ;; update the clock report, or create it if it doesn't exist > ;; note: we pass a prefix argument to tell org-clock-report to > ;; update the first clocktable it finds in the (narrowed) buffer > (org-clock-report t) > ;; widen to the whole buffer again > (widen))) > #+end_src This is wonderful Richard, and a great help to me. I had no idea of the org-datree-find-date-create, and the argument to org-clock-report cuts out a lot of my code. > Note that org-datetree-find-date has a slightly annoying interface, in > that you need to provide a list of three integers representing a > calendar date. Yes, that is a little awkward. What I did think of using was substrings to extract the date from the picker interface. #+BEGIN_SRC emacs-lisp (defun org-date-picker-to-list () (let* ((date-string (org-read-date)) (year (substring date-string 0 4)) (month (substring date-string 5 7)) (day (substring date-string 8 10))) (mapcar 'string-to-number (list month day year #+END_SRC Does that look sensible? My two next things to tackle are 1. A hook to run the function when I run org-capture. 2. Changing the org-clock-report options in your function above, but not the defaults. For the second point, is there some trick to swap a global variable for the run of a function? The variable in this case would be org-clocktable-defaults. Thank you so much Richard. You've probably saved me days of going through the org-mode documentation and source.
bug#44824: 27.1; Org export as pdf and open file does not open it
> From: Maxim Nikulin > Date: Sat, 30 Jan 2021 22:58:06 +0700 > Cc: 44...@debbugs.gnu.org > > The problem is that emacs does not expect that kde-open5 and thus > xdg-open exits instantly. Why is that a problem, and how does it cause the invocation to fail, i.e. not show the file in question? > The question could be addressed to KDE developers, but unlike the > issue with temporary files, in my opinion, pty+SIGHUP problem should > be fixed in org mode. What do you mean by "pty+SIGHUP problem" in this case? What exactly is the problem?
bug#44824: 27.1; Org export as pdf and open file does not open it
On 30/01/2021 20:49, Eli Zaretskii wrote: How about asking the xdg-open developers to help us figure out the reason? I do not think, it is xdg-open problem. It just calls kde-open5 that spawns actual handler and immediately exits. I didn't say it was their problem, I suggested to ask them to help us understand why xdg-open doesn't work in those cases, under the assumption that they are familiar with their code better than us. What kind of help do you expect from xdg-open developers? It is a shell script, you could easily inspect it. I have posted already a command how to trace its execution. However currently I am almost sure that it merely calls 'kde-open5 /tmp/file.pdf'. The problem is that emacs does not expect that kde-open5 and thus xdg-open exits instantly. The question could be addressed to KDE developers, but unlike the issue with temporary files, in my opinion, pty+SIGHUP problem should be fixed in org mode. Some convenience function in emacs core would be nice but org mode is compatible with older emacs releases. Thus the only option is to change the org-open-files function.
bug#44824: 27.1; Org export as pdf and open file does not open it
> From: Maxim Nikulin > Date: Sat, 30 Jan 2021 20:31:53 +0700 > Cc: gbio...@gmail.com > > > How about asking the xdg-open developers to help us figure out the > > reason? Or, failing that, debug xdg-open in the problematic > > situations to find out what fails there and why? E.g., could it be > > that it fails because stdin/stdout is a PTY? what happens if you bind > > process-connection-type to nil when starting the async subprocess? > > I do not think, it is xdg-open problem. It just calls kde-open5 that > spawns actual handler and immediately exits. I didn't say it was their problem, I suggested to ask them to help us understand why xdg-open doesn't work in those cases, under the assumption that they are familiar with their code better than us.
Re: org-attach-git don't automatically commit changes
Hi Ihor, Ihor Radchenko writes: > Note that org "sees" changes in the attachment dir only when you use > M-x org-attach command to manage the attachments. Directly changing the > attachment directory will not be noticed. You can force org-mode to > check for changes in attachment dir by running "C-c C-a z". Thanks for the explanation. It seems that I had misinterpreted what the manual said :-) Anyway, in my case, it still doesn't work (?). I think it's for a path problem. In `org-attach-git-commit' there is this variable: #+begin_src emacs-lisp ;; ... (let* ((dir (expand-file-name org-attach-id-dir)) ;; ... #+end_src The default value of `org-attach-id-dir' is "data/", and if I evaluate `(expand-file-name org-attach-id-dir)' on my current node, it returns a wrong path to the attached folder. `org-attach-sync' only works for me if I set in `org-attach-git-commit' the variable like this: #+begin_src emacs-lisp ;; ... (let* ((dir (org-attach-dir)) ;; < ;; ... #+end_src In that case, it does recognize the path correctly. Again, I don't know if I'm missing something... Best regards, Juan Manuel
bug#44824: 27.1; Org export as pdf and open file does not open it
On 30/01/2021 15:42, Eli Zaretskii wrote: This works: M-! xdg-open /tmp/test.pdf RET This doesn't work: M-& xdg-open /tmp/test.pdf RET This doesn't work: M-x shell RET xdg-open /tmp/test.pdf RET Geraldo, "M-x shell" case is rather strange. Could you, please, confirm ones more that okular window with the file content does not appear if you call xdg-open from an *interactive* emacs shell buffer? The link to an emacs-orgmode list message, that I have posted earlier, explains why async-shell-command *may* fail while shell-command should work reliably. I am really surprised by failure when command is executed in a [e]shell buffer. How about asking the xdg-open developers to help us figure out the reason? Or, failing that, debug xdg-open in the problematic situations to find out what fails there and why? E.g., could it be that it fails because stdin/stdout is a PTY? what happens if you bind process-connection-type to nil when starting the async subprocess? I do not think, it is xdg-open problem. It just calls kde-open5 that spawns actual handler and immediately exits.
Re: tickler file & recurring events
Saša Janiška writes: > so wonder if > it's possible for such tasks to be added to agenda view **only** when > they're due and not before? Check org-agenda-show-future-repeats ( v org-agenda-show-future-repeats ). Best, Ihor
org-goto and org-store-link/org-id-get-create
Calling either org-store-link or org-id-get-create in an indirect org-goto buffer results in an empty ID-property drawer with (setq org-id-link-to-org-use-id t). There is a recent thread about "Indirect buffers, ~org-store-link~, and ~org-insert-link~" (https://orgmode.org/list/rhob8q$t26$1...@ciao.gmane.io/) which seems to have resulted in a fix for org-store-link in indirect buffers. Yet, for an org-goto buffer the described problem of an empty target remains. System: Emacs 27.1, Windows 10, org 9.4.4 Thanks in advance for any pointers!
Re: clock-table and hooking that into org-capture file+olp+datetree
Hi Christopher, "Christopher Causer" writes: > Hello everyone! Here's a reasonably easy (I think) question because I'm quite > new to Emacs and org-mode. > > I have an org-capture template using file+olp+datetree[1], which works great > at filing my thoughts for the day. Separately I know I can generate clock > tables[2] based on dynamic blocks to show me what I've been doing with my > time for any given period. What I'm struggling with is to glue parts of these > together to achieve the following: > > 1. I org-capture to a subheading of datetree. When it does so it either > creates or updates an org-clock-report just below the datetree header (the > bit that says "2020-11-12 Thursday", for example.) I guess this would be the > parent of what I'm capturing. > > 2. For all my historical journal entries, if I could move point to a headline > with a date such as the example below and it would pull the date out and add > a clocktable below via an interactive function that would be my ideal. This > is less of a problem for me as I don't have much in the way of history in my > diary yet or my other org files. > If I understand right, what you need for both of these things is a function to jump to a date in your diary datetree and update the clocktable there. Right? Some functions that will help with this: - org-datetree-find-date-create - org-narrow-to-subtree So, something like this should get you started: #+begin_src emacs-lisp (defun org-update-clocktable-on-date (date) (save-excursion ;; open the file containing the datetree: (find-file (concat org-directory "/diary.org")) ;; jump to the subtree for the given date: ;; note: date must look like (m d y) where all three values are integers (org-datetree-find-date-create date) ;; narrow to the subtree for this date, so we don't update ;; any other clocktables (org-narrow-to-subtree) ;; update the clock report, or create it if it doesn't exist ;; note: we pass a prefix argument to tell org-clock-report to ;; update the first clocktable it finds in the (narrowed) buffer (org-clock-report t) ;; widen to the whole buffer again (widen))) #+end_src Then you can call this function, providing the date, in different contexts where you want to create or update the clocktable. Note that org-datetree-find-date has a slightly annoying interface, in that you need to provide a list of three integers representing a calendar date. One easy way to do that interactively is with calendar-read-date, which prompts you for the year, month and day, so you could say (org-update-clocktable-on-date (calendar-read-date)) calendar-read-date is not as nice to use interactively as org-read-date, but as far as I know, there is no easy way to get the calendar (m d y) format out of its return value, which is either a string like "2021-01-30" or a value in Emacs' internal time representation format. But you can do something like (let* ;; prompt for the date and decode the resulting internal time as a list: ((decoded (decode-time (org-read-date nil t nil "Update on date:"))) ;; unpack the date as a list (m d y) from the decoded time: (date (list (nth 4 decoded) ; month (nth 3 decoded) ; day (nth 5 decoded ; year (org-update-clocktable-on-date date)) Hope that helps get you to your next step! -- Best, Richard
Re: Refile Targets Custom Function Support
Kevin Foley writes: > I'd like to use an `org-ql' query in order to get eligible targets when > calling `org-refile'. > I actually also wanted to do that a couple of weeks ago. I ended up using org-ql and completing-read to select a target. The last optional argument to org-refile lets you specify a location to refile to. I have shared this code in my dotfiles: https://github.com/Zetagon/literate-dotfiles/blob/master/config.org#refiling . Keep in mind that it depends on dash.el too. I also discussed this in an issue in org-ql: https://github.com/alphapapa/org-ql/issues/177
Re: [PATCH] ob-java: Allow import to end with asterisk
Thanks. And thanks for taking the time to fix issues that you find. It continues to improve because of your contributions. The patch looks good. Applied. On Thu, Jan 28, 2021 at 3:04 PM John Herrlin wrote: > > > ian martins writes: > > >> I found this case: > >> And it seems to me that the import regex dont see the asterisk. > >> > >> I attached a possible patch. > > > > Thanks again, John. You're right the regex is missing the asterisk > > include. Thanks for the patch fixing. This works but it will add > > redundant includes if the source block includes something that is also > > in the list of classes to automatically include. > > > > for example, this: > > > > #+begin_src java :results value > > import java.util.*; > > return "test"; > > #+end_src > > > > will end up pulling in > > > > import java.util.List; > > import java.util.*; > > > > It wouldn't hurt anything, but could probably be prevented by changing > > the regexp in =org-babel-java--import-maybe= to look for asterisk as > > well as =class=. Do you feel like updating the patch? > > > > [1] https://code.orgmode.org/bzg/org-mode/src/master/lisp/ob-java.el#L314 > > Here is an updated patch. It seems to work on my cases. > > Of topic, I am very happy with the latest updates on ob-java and I think > it works really good! Thanks for the awesome work Ian! > > Stay safe! >
bug#44824: 27.1; Org export as pdf and open file does not open it
> From: Lars Ingebrigtsen > Date: Sat, 30 Jan 2021 07:09:50 +0100 > Cc: 44...@debbugs.gnu.org > > This works: > M-! xdg-open /tmp/test.pdf RET > > This doesn't work: > M-& xdg-open /tmp/test.pdf RET > > This doesn't work: > M-x shell RET xdg-open /tmp/test.pdf RET How about asking the xdg-open developers to help us figure out the reason? Or, failing that, debug xdg-open in the problematic situations to find out what fails there and why? E.g., could it be that it fails because stdin/stdout is a PTY? what happens if you bind process-connection-type to nil when starting the async subprocess?
clock-table and hooking that into org-capture file+olp+datetree
Hello everyone! Here's a reasonably easy (I think) question because I'm quite new to Emacs and org-mode. I have an org-capture template using file+olp+datetree[1], which works great at filing my thoughts for the day. Separately I know I can generate clock tables[2] based on dynamic blocks to show me what I've been doing with my time for any given period. What I'm struggling with is to glue parts of these together to achieve the following: 1. I org-capture to a subheading of datetree. When it does so it either creates or updates an org-clock-report just below the datetree header (the bit that says "2020-11-12 Thursday", for example.) I guess this would be the parent of what I'm capturing. 2. For all my historical journal entries, if I could move point to a headline with a date such as the example below and it would pull the date out and add a clocktable below via an interactive function that would be my ideal. This is less of a problem for me as I don't have much in the way of history in my diary yet or my other org files. An example tree would be #+BEGIN_QUOTE * Work ** 2021 *** 2021-01 January 2021-01-07 Thursday * Ate some chips * Drank some soda #+END_QUOTE I tried looking at the org-mode source, and it is too advanced for me to follow. The closest I can get (or at least here's a scrap of code to prove I did actually try) is as follows: #+BEGIN_SRC emacs-lisp (defun cc/create-or-update-effort-table () (save-excursion (find-file (concat org-directory "/diary.org")) (goto-char (org-find-olp (list (concat org-directory "/diary.org" ) "Work" "2021" "2021-01 January" "2021-01-07 Thursday"))) (beginning-of-line) (next-line) (if (looking-at-p "[[:space:]]*#\\+BEGIN: clocktable") (forward-word 3) (progn (insert "\n")(previous-line))) (org-clock-report))) #+END_SRC A lot of beginner missteps there that I'm sure people can correct, but hopefully you can see the intent. If you see anything amiss please let me know, but my main problems are: 1. I hardcoded the datetree part whereas I'd like this to be today's date or even the date picker built into org-mode. I am very far off using the datepicker to generate ("%Y" "%Y-%m %B" "%Y-%m-%d %A") [3]. This would also be needed for point 4. 2. I obviously don't understand how markers work well enough because I had to add the ~find-file~ whereas I would imagine you could just do it all in the goto-char line, if I knew how to use markers better. 3. The function would fail if the tree doesn't exist. I'd like it created like org-capture would. Not all clocked items are in my diary, so I may want to run the function before any diary items exist for today. 4. I would like to customize the variables org-clock-report uses to generate the report. It looks to be assigned by the defaults ~org-clocktable-defaults~. The ~:block~ option is the obvious option I'd like to change to a set date. In other words, I want to change the options in the function above but not use org-clocktable-defaults unless it reverts after the function is finished. 5. Even if the function above worked, I have no idea how to hook that into file+olp+datetree. Would I need to switch to file+function and add the clock table as a side-effect? The function cc/create-or-update-effort-table has to use olp, not headline, as the headline "2021-01-07 Thursday" is not unique in the file. Thank you for taking the time to read this far, and thank you to all the people who've contributed to Emacs and Org-Mode. I wish I'd discovered them sooner. Christopher. [1] https://orgmode.org/manual/Template-elements.html [2] https://orgmode.org/manual/The-clock-table.html [3] https://man7.org/linux/man-pages/man1/date.1.html The links are for my benefit when I come back to this email, rather than anyone else's, but I guess it doesn't hurt to include them for other people new to org-mode like myself.
tickler file & recurring events
Hello, I'd like to improve my GTD workflow by adding tickler file so that my agenda views is not cluttered with reminders for e.g. paying bills and similar tasks. I've followed, more or less, the setup described here (https://emacs.cafe/emacs/orgmode/gtd/2017/06/30/orgmode-gtd.html) and I can capture the task which is then put into tickler.org file, but the problem is that most of such tasks are recurring ones, e.g. ** water the plants <2021-02-15 Mon +5d> but in such case, all reminders are visible in agenda view, so wonder if it's possible for such tasks to be added to agenda view **only** when they're due and not before? SIncerely, Gour -- Many, many births both you and I have passed. I can remember all of them, but you cannot, O subduer of the enemy!