From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ihor Radchenko Subject: Re: Bug (with fix): org-tempo-add-block incorrectly inserts comma before next `#+begin_src' during expansion [9.3.2 (9.3.2-8-g47b104-elpaplus @ ~/.emacs.d/elpa/org-plus-contrib-20200127/)] Date: Mon, 03 Feb 2020 11:38:26 +0800 Message-ID: <87a7608hn1.fsf@localhost> References: <93C72314-096C-4C7A-83B6-D96F581E92D5@polymtl.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:52537) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iySbr-00027m-W6 for emacs-orgmode@gnu.org; Sun, 02 Feb 2020 22:41:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iySbp-0002Z5-P0 for emacs-orgmode@gnu.org; Sun, 02 Feb 2020 22:41:15 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:44420) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iySbp-0002Wr-Ei for emacs-orgmode@gnu.org; Sun, 02 Feb 2020 22:41:13 -0500 Received: by mail-pl1-x636.google.com with SMTP id d9so5271038plo.11 for ; Sun, 02 Feb 2020 19:41:11 -0800 (PST) In-Reply-To: <93C72314-096C-4C7A-83B6-D96F581E92D5@polymtl.ca> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Sender: "Emacs-orgmode" To: Bram Adams , emacs-orgmode@gnu.org It's a duplicate of my earlier bug report https://lists.gnu.org/archive/html/emacs-orgmode/2019-12/msg00326.html Hope, there will be some progress.=20 Best, Ihor Bram Adams writes: > Hi, > > I encountered a bug in org-tempo-add-block, where the following snippet i= n an org file (with =E2=80=9C =3D=3D=3D >

> [random text, potentially empty] > > #+begin_src any_code_block > [=E2=80=A6] > #+end_src > =3D=3D=3D=20 > > =E2=80=A6 expands into (notice the comma before `#+begin'): > =3D=3D=3D > [expansion of > [random text, potentially empty] > > ,#+begin_src any_code_block > [=E2=80=A6] > #+end_src > =3D=3D=3D > > (The issue does not occur when using `org-insert-structure-template=E2=80= =99.) > > The spurious comma seems to be generated by the second `=E2=80=99>=E2=80= =99 on line 125 of org-tempo.el: > =3D=3D=3D > (defun org-tempo-add-block (entry) > "Add block entry from `org-structure-template-alist'." > (let* ((key (format "<%s" (car entry))) > (name (cdr entry)) > (special (member name '("src" "export")))) > (tempo-define-template (format "org-%s" (replace-regexp-in-string " "= "-" name)) > `(,(format "#+begin_%s%s" name (if special " " "")) > ,(when special 'p) '> n '> ,(unless special 'p) n ;; <=E2=80=94= =E2=80=94 line 125 > ,(format "#+end_%s" (car (split-string name " "))) > >) > key > (format "Insert a %s block" name) > 'org-tempo-tags))) > =3D=3D=3D > > Removing the second `=E2=80=99>=E2=80=99 on line 125 fixes the issue. > > Kind regards, > > Bram Adams > > > =3D=3D=3D > =3D=3D=3D > =3D=3D=3D > > Emacs : GNU Emacs 26.3 (build 1, x86_64-apple-darwin17.7.0, Carbon Versi= on 158 AppKit 1561.6) > of 2019-08-29 > Package: Org mode version 9.3.2 (9.3.2-8-g47b104-elpaplus @ ~/.emacs.d/el= pa/org-plus-contrib-20200127/) > > current state: > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > (setq > org-src-mode-hook '(org-src-babel-configure-edit-buffer > org-src-mode-configure-edit-buffer) > org-fontify-whole-heading-line t > org-refile-target-verify-function 'verify-refile-target > org-agenda-scheduled-leaders '("Sch.: " "Sch.%2dx: ") > org-link-shell-confirm-function 'yes-or-no-p > org-babel-after-execute-hook '(org-redisplay-inline-images) > org-tempo-keywords-alist nil > org-metadown-hook '(org-babel-pop-to-session-maybe) > org-clock-out-hook '(org-clock-remove-empty-clock-drawer) > org-refile-targets '((nil :maxlevel . 4) (filter_out_cal :maxlevel . 4)) > org-enforce-todo-dependencies t > org-edit-src-content-indentation 0 > org-src-tab-acts-natively t > org-special-ctrl-a/e t > org-agenda-files '(=E2=80=9C/path/to/org/" > =E2=80=9C/path/to/org/archive/") > org-shiftup-final-hook '(windmove-up) > org-blocker-hook '(org-block-todo-from-checkboxes > org-block-todo-from-children-or-siblings-or-parent) > org-archive-location "archive/%s_archive.gpg::" > org-super-agenda-mode t > org-mode-hook '(add-pcomplete-to-capf org-bullets-mode org-tempo-setup > #[0 "\300\301\302\303\304$\207" > [add-hook change-major-mode-hook org-show-all append l= ocal] 5] > ob-ipython-auto-configure-kernels > #[0 "\300\301\302\303\304$\207" > [add-hook change-major-mode-hook org-babel-show-result= -all append > local] > 5] > org-babel-result-hide-spec org-babel-hide-all-hashes > #[0 "\301\211\207" [imenu-create-index-function org-imen= u-get-tree] > 2] > org-eldoc-load) > org-outline-path-complete-in-steps nil > org-archive-hook '(org-attach-archive-delete-maybe) > org-confirm-elisp-link-function 'yes-or-no-p > org-agenda-finalize-hook '(ap/org-super-agenda-origami-fold-default > gs/org-agenda-project-highlight-warning > #[0 "\300ed\301#\207" > [remove-text-properties (mouse-face t)] 4] > ) > org-agenda-before-write-hook '(org-agenda-add-entry-text) > org-metaup-hook '(org-babel-load-in-session-maybe) > org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n= \n(fn ENTRY)"] > org-shiftdown-final-hook '(windmove-down) > org-agenda-deadline-faces '((1.001 . error) (1.0 . org-warning) > (0.5 . org-upcoming-deadline) > (0.0 . org-upcoming-distant-deadline)) > org-track-ordered-property-with-tag t > org-babel-pre-tangle-hook '(save-buffer) > org-file-apps '((auto-mode . emacs) ("\\.mm\\'" . default) ("\\.x?html?\= \'" . default) > ("\\.pdf\\'" . default) ("\\.jpg\\'" . system) ("\\.JPG\= \'" . system) > ("\\.png\\'" . system) ("\\.PNG\\'" . system)) > org-tab-first-hook '(org-babel-hide-result-toggle-maybe org-babel-header= -arg-expand) > org-hide-leading-stars t > org-babel-load-languages '((R . t) (sql . t) (shell . t) (dot . t) (sqli= te . t) > (perl . t) (ditaa . t) (ipython . t) (python = . t) > (applescript . t) (emacs-lisp . t)) > org-shiftright-final-hook '(windmove-right) > org-agenda-time-grid '((daily today remove-match) (800 1200 1600 2000) "= ......" > "----------------") > org-log-done 'time > org-highlight-latex-and-related '(latex) > org-ellipsis " =E2=86=B4" > org-use-fast-todo-selection t > org-fast-tag-selection-single-key 'expert > org-src-lang-modes '(("jupyter-python" . python) ("arduino" . arduino) > ("redis" . redis) ("php" . php) ("ipython" . python= ) ("C" . c) > ("C++" . c++) ("asymptote" . asy) ("bash" . sh) > ("beamer" . latex) ("calc" . fundamental) ("cpp" . = c++) > ("ditaa" . artist) ("dot" . fundamental) ("elisp" .= emacs-lisp) > ("ocaml" . tuareg) ("screen" . shell-script) ("shel= l" . sh) > ("sqlite" . sql)) > org-src-preserve-indentation t > org-fontify-quote-and-verse-blocks t > org-fontify-done-headline t > org-catch-invisible-edits 'error > org-agenda-prefix-format '((agenda . " %i %?-12t% s") (todo . " %i %-12:= c") > (tags . " %i %-12:c") (search . " %i %-12:c")) > org-occur-hook '(org-first-headline-recenter) > org-agenda-mode-hook '(org-gcal-fetch origami-mode) > org-cycle-separator-lines 0 > org-agenda-window-setup 'current-window > org-log-into-drawer t > org-protocol-protocol-alist '(("capture-eww-readable" :protocol "capture= -eww-readable" > :function > org-protocol-capture-html--capture-eww-re= adable > :kill-client t) > ("capture-html" :protocol "capture-html" := function > org-protocol-capture-html--with-pandoc :k= ill-client t) > ) > org-agenda-search-headline-for-time nil > org-enforce-todo-checkbox-dependencies t > org-todo-state-tags-triggers '(("CANCELLED" ("CANCELLED" . t)) > ("WAITING" ("WAITING" . t)) > ("INACTIVE" ("WAITING") ("INACTIVE" . t)) > (done ("WAITING") ("INACTIVE")) > ("TODO" ("WAITING") ("CANCELLED") ("INACT= IVE")) > ("NEXT" ("WAITING") ("CANCELLED") ("INACT= IVE")) > ("NOW" ("WAITING") ("CANCELLED") ("INACTI= VE")) > ("SOMETIME" ("WAITING") ("CANCELLED") ("I= NACTIVE")) > ("DONE" ("WAITING") ("CANCELLED") ("INACT= IVE"))) > org-structure-template-alist '(("e" . "src emacs-lisp") ("i" . "src ipyt= hon") > ("a" . "src applescript") > ("r" . > "src R :results output :async t :session= mysession :cache yes :colnames yes") > ("p" . > "src python :results output graphics :as= ync t :session mysession :exports both") > ("b" . > "src shell :results output graphics :asy= nc t :session mysession") > ("s" . > "src sqlite :db /path/to/db :colnames ye= s :async t :session mysession") > ("q" . "quote") ("v" . "verse") ("V" . "v= erbatim") > ("c" . "center") ("C" . "comment") ("l" .= "src latex") > ("h" . "src html")) > org-archive-file-header-format "" > org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-show-empty-l= ines > org-optimize-window-after-visibility-change) > org-todo-keywords '((sequence "TODO(t)" "NEXT(n)" "NOW(o)" "SOMETIME(s)"= "|" "DONE(d)") > (sequence "WAITING(w@/!)" "INACTIVE(i)" "|" "CANCELL= ED(c@/!)" > "MEETING") > ) > org-speed-command-hook '(org-speed-command-activate org-babel-speed-comm= and-activate) > org-capture-mode-hook '(#[0 "\300\301\302\303 !\"A\304\232\205=00\305 \2= 07" > [assoc name frame-parameters selected-frame "r= emember" > delete-other-windows] > 4] > ) > org-shiftleft-final-hook '(windmove-left) > org-babel-tangle-lang-exts '(("apples" . "scpt") ("applescript" . "scpt") > ("python" . "py") ("perl" . "pl") ("emacs-l= isp" . "el") > ("elisp" . "el")) > org-refile-allow-creating-parent-nodes 'confirm > org-refile-use-outline-path t > org-font-lock-set-keywords-hook '(doom-org-custom-fontification) > org-confirm-shell-link-function 'yes-or-no-p > org-stuck-projects '("" nil nil "") > org-link-parameters '(("attachment" :follow org-attach-open-link :export > org-attach-export-link :complete org-attach-compl= ete-link) > ("eww" :follow eww :store org-eww-store-link) > ("rmail" :follow org-rmail-open :store org-rmail-s= tore-link) > ("mhe" :follow org-mhe-open :store org-mhe-store-l= ink) > ("irc" :follow org-irc-visit :store org-irc-store-= link :export > org-irc-export) > ("info" :follow org-info-open :export org-info-exp= ort :store > org-info-store-link) > ("gnus" :follow org-gnus-open :store org-gnus-stor= e-link) > ("docview" :follow org-docview-open :export org-do= cview-export > :store org-docview-store-link) > ("bibtex" :follow org-bibtex-open :store org-bibte= x-store-link) > ("bbdb" :follow org-bbdb-open :export org-bbdb-exp= ort :complete > org-bbdb-complete-link :store org-bbdb-store-link) > ("w3m" :store org-w3m-store-link) ("id" :follow or= g-id-open) > ("file+sys") ("file+emacs") > ("shell" :follow org-link--open-shell) > ("news" :follow > #[257 "\301\300\302Q!\207" ["news" browse-url ":"= ] 5 > "\n\n(fn URL)"] > ) > ("mailto" :follow > #[257 "\301\300\302Q!\207" ["mailto" browse-url "= :"] 5 > "\n\n(fn URL)"] > ) > ("https" :follow > #[257 "\301\300\302Q!\207" ["https" browse-url ":= "] 5 > "\n\n(fn URL)"] > ) > ("http" :follow > #[257 "\301\300\302Q!\207" ["http" browse-url ":"= ] 5 > "\n\n(fn URL)"] > ) > ("ftp" :follow > #[257 "\301\300\302Q!\207" ["ftp" browse-url ":"]= 5 > "\n\n(fn URL)"] > ) > ("help" :follow org-link--open-help) > ("file" :complete org-link-complete-file) > ("elisp" :follow org-link--open-elisp) > ("doi" :follow org-link--open-doi)) > org-agenda-file-regexp "\\`[^.].*\\.org\\(\\.gpg\\)?\\'" > org-link-elisp-confirm-function 'yes-or-no-p > org-todo-keyword-faces '(("TODO" :foreground "red" :weight bold) > ("NEXT" :foreground "blue" :weight bold) > ("NOW" :foreground "orange" :weight bold) > ("SOMETIME" :foreground "deep sky blue" :weight= bold) > ("DONE" :foreground "forest green" :weight bold) > ("WAITING" :foreground "orange" :weight bold) > ("INACTIVE" :foreground "magenta" :weight bold) > ("CANCELLED" :foreground "forest green" :weight= bold) > ("MEETING" :foreground "forest green" :weight b= old)) > org-capture-after-finalize-hook '(#[0 > "\300 \210\301\302\303\304 !\"A\305\= 232\205=00\306 \207" > [org-save-all-org-buffers assoc name > frame-parameters selected-frame "re= member" > delete-frame] > 4] > ) > org-tab-before-tab-emulation-hook '(org-tempo-complete-tag) > org-super-agenda-groups '((:name "Today:" :time-grid t) > (:name "NOW Tasks:" :todo "NOW") > (:name "Overdue Tasks:" :scheduled past) > (:name "Today's Tasks:" :scheduled today) > (:name "Future Tasks:" :scheduled future)) > org-startup-truncated nil > org-show-context-detail '((agenda . local) (bookmark-jump . lineage) > (isearch . lineage) (default . ancestors) (org= -goto . local) > (occur-tree . local) (link-search . local) > (tags-tree . local)) > org-src-window-setup 'current-window > org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate > org-deadline-warning-days 90 > org-agenda-custom-commands '(("c" "Simple agenda view" ((agenda "") (all= todo ""))) > ("X" "Agenda" ((agenda "") (alltodo)) > ((org-agenda-ndays 10) (org-agenda-start-o= n-weekday nil) > (org-agenda-start-day "-1d") > (org-agenda-start-with-log-mode t)) > ) > ) > org-directory =E2=80=9C/path/to/org/" > org-default-notes-file =E2=80=9C/path/to/org/my_notes.org" > ) > --=20 Ihor Radchenko, PhD, Center for Advancing Materials Performance from the Nanoscale (CAMP-nano) State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong U= niversity, Xi'an, China Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg