emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bram Adams <bram.adams@polymtl.ca>
To: Ihor Radchenko <yantar92@gmail.com>
Cc: emacs-orgmode@gnu.org
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: Sun, 2 Feb 2020 23:35:13 -0500	[thread overview]
Message-ID: <E655F861-183D-4BF4-917D-64456D574397@polymtl.ca> (raw)
In-Reply-To: <87a7608hn1.fsf@localhost>

[-- Attachment #1: Type: text/plain, Size: 16205 bytes --]

Hi Ihor,

> It's a duplicate of my earlier bug report
> https://lists.gnu.org/archive/html/emacs-orgmode/2019-12/msg00326.html <https://lists.gnu.org/archive/html/emacs-orgmode/2019-12/msg00326.html>

True, I seem to notice the same symptoms and also had `org-src-tab-acts-natively’ set.

> Hope, there will be some progress. 

Yes, hopefully removing the `’>’ in org-tempo.el is only a temporary hack (cannot use `org-insert-structure-template’ due to other templates).

Thanks for the quick reply,

Bram Adams



> Bram Adams <bram.adams@polymtl.ca> writes:
> 
>> Hi,
>> 
>> I encountered a bug in org-tempo-add-block, where the following snippet in an org file (with “<p” representing an arbitrary entry in `org-structure-template-alist’):
>> ===
>> <p
>> 
>> [random text, potentially empty]
>> 
>> #+begin_src any_code_block
>> […]
>> #+end_src
>> === 
>> 
>> … expands into (notice the comma before `#+begin'):
>> ===
>> [expansion of <p]
>> 
>> [random text, potentially empty]
>> 
>> ,#+begin_src any_code_block
>> […]
>> #+end_src
>> ===
>> 
>> (The issue does not occur when using `org-insert-structure-template’.)
>> 
>> The spurious comma seems to be generated by the second `’>’ on line 125 of org-tempo.el:
>> ===
>> (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 ;; <—— line 125
>> 			     ,(format "#+end_%s" (car (split-string name " ")))
>> 			     >)
>> 			   key
>> 			   (format "Insert a %s block" name)
>> 			   'org-tempo-tags)))
>> ===
>> 
>> Removing the second `’>’ on line 125 fixes the issue.
>> 
>> Kind regards,
>> 
>> Bram Adams
>> 
>> 
>> ===
>> ===
>> ===
>> 
>> Emacs  : GNU Emacs 26.3 (build 1, x86_64-apple-darwin17.7.0, Carbon Version 158 AppKit 1561.6)
>> of 2019-08-29
>> Package: Org mode version 9.3.2 (9.3.2-8-g47b104-elpaplus @ ~/.emacs.d/elpa/org-plus-contrib-20200127/)
>> 
>> current state:
>> ==============
>> (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 '(“/path/to/org/"
>>                    “/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 local] 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-imenu-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) (sqlite . 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 " ↴"
>> 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) ("shell" . 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-readable
>>                                :kill-client t)
>>                               ("capture-html" :protocol "capture-html" :function
>>                                org-protocol-capture-html--with-pandoc :kill-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") ("INACTIVE"))
>>                                ("NEXT" ("WAITING") ("CANCELLED") ("INACTIVE"))
>>                                ("NOW" ("WAITING") ("CANCELLED") ("INACTIVE"))
>>                                ("SOMETIME" ("WAITING") ("CANCELLED") ("INACTIVE"))
>>                                ("DONE" ("WAITING") ("CANCELLED") ("INACTIVE")))
>> org-structure-template-alist '(("e" . "src emacs-lisp") ("i" . "src ipython")
>>                                ("a" . "src applescript")
>>                                ("r" .
>>                                 "src R :results output :async t :session mysession :cache yes :colnames yes")
>>                                ("p" .
>>                                 "src python :results output graphics :async t :session mysession :exports both")
>>                                ("b" .
>>                                 "src shell :results output graphics :async t :session mysession")
>>                                ("s" .
>>                                 "src sqlite :db /path/to/db :colnames yes :async t :session mysession")
>>                                ("q" . "quote") ("v" . "verse") ("V" . "verbatim")
>>                                ("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-lines
>>                  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)" "|" "CANCELLED(c@/!)"
>>                      "MEETING")
>>                     )
>> org-speed-command-hook '(org-speed-command-activate org-babel-speed-command-activate)
>> org-capture-mode-hook '(#[0 "\300\301\302\303 !\"A\304\232\205\305 \207"
>>                           [assoc name frame-parameters selected-frame "remember"
>>                            delete-other-windows]
>>                           4]
>>                         )
>> org-shiftleft-final-hook '(windmove-left)
>> org-babel-tangle-lang-exts '(("apples" . "scpt") ("applescript" . "scpt")
>>                              ("python" . "py") ("perl" . "pl") ("emacs-lisp" . "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-complete-link)
>>                       ("eww" :follow eww :store org-eww-store-link)
>>                       ("rmail" :follow org-rmail-open :store org-rmail-store-link)
>>                       ("mhe" :follow org-mhe-open :store org-mhe-store-link)
>>                       ("irc" :follow org-irc-visit :store org-irc-store-link :export
>>                        org-irc-export)
>>                       ("info" :follow org-info-open :export org-info-export :store
>>                        org-info-store-link)
>>                       ("gnus" :follow org-gnus-open :store org-gnus-store-link)
>>                       ("docview" :follow org-docview-open :export org-docview-export
>>                        :store org-docview-store-link)
>>                       ("bibtex" :follow org-bibtex-open :store org-bibtex-store-link)
>>                       ("bbdb" :follow org-bbdb-open :export org-bbdb-export :complete
>>                        org-bbdb-complete-link :store org-bbdb-store-link)
>>                       ("w3m" :store org-w3m-store-link) ("id" :follow org-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 bold))
>> org-capture-after-finalize-hook '(#[0
>>                                     "\300 \210\301\302\303\304 !\"A\305\232\205\306 \207"
>>                                     [org-save-all-org-buffers assoc name
>>                                      frame-parameters selected-frame "remember"
>>                                      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 "") (alltodo "")))
>>                              ("X" "Agenda" ((agenda "") (alltodo))
>>                               ((org-agenda-ndays 10) (org-agenda-start-on-weekday nil)
>>                                (org-agenda-start-day "-1d")
>>                                (org-agenda-start-with-log-mode t))
>>                               )
>>                              )
>> org-directory “/path/to/org/"
>> org-default-notes-file “/path/to/org/my_notes.org"
>> )
>> 
> 
> -- 
> Ihor Radchenko,
> PhD,
> Center for Advancing Materials Performance from the Nanoscale (CAMP-nano)
> State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong University, Xi'an, China
> Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg
> 


[-- Attachment #2: Type: text/html, Size: 38534 bytes --]

  reply	other threads:[~2020-02-03  4:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-02  4:15 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/)] Bram Adams
2020-02-03  3:38 ` Ihor Radchenko
2020-02-03  4:35   ` Bram Adams [this message]
2020-02-03 12:13     ` Bastien
2020-02-03 15:08       ` Bram Adams
2020-02-03 15:45         ` Bastien
2020-02-03 16:23           ` Bram Adams
2020-02-03 17:33             ` Bastien
2020-02-03 18:18               ` Bram Adams
2020-04-08 15:50       ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E655F861-183D-4BF4-917D-64456D574397@polymtl.ca \
    --to=bram.adams@polymtl.ca \
    --cc=emacs-orgmode@gnu.org \
    --cc=yantar92@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).