What did you expect to happen?
When saving my literate config, I expect my point to not move.
What actually happened?
After editing my literate config file when I save, the file is tangled. But then the point jumps back to the beginning of the file.
Additional details:
This was replicated on Doom sandbox (vanilla Doom).
Steps to reproduce:
config.orgSystem information:
emacs version 26.3
features XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS XWIDGETS LIBSYSTEMD LCMS2
build Sep 16, 2019
buildopts (--build=x86_64-linux-gnu --prefix=/usr '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' --sysconfdir=/etc --localstatedir=/var --disable-silent-rules '--libdir=${prefix}/lib/x86_64-linux-gnu' '--libexecdir=${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --sharedstatedir=/var/lib --program-suffix=26 --with-modules --with-file-notification=inotify --with-mailutils --with-x=yes --with-x-toolkit=gtk3 --with-xwidgets --with-lcms2 'CFLAGS=-g -O2 -fdebug-prefix-map=/build/emacs26-TP6iDo/emacs26-26.3~1.git96dd019=. -fstack-protector-strong -Wformat -Werror=format-security -no-pie' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -no-pie')
windowsys x
daemonp server-running
doom version 2.0.9
build HEAD -> develop, origin/develop, origin/HEAD 9ac9deb0f 2020-08-03 18:57:34 -0400
dir ~/Work/Projects/dotfiles/emacs/.config/doom/
system type gnu/linux
config x86_64-pc-linux-gnu
shell /bin/zsh
uname Linux 4.15.0-109-generic #110-Ubuntu SMP Tue Jun 23 02:39:32 UTC 2020 x86_64
path (~/.local/share/texlive/2020/root/bin/x86_64-linux ~/.local/bin /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games /snap/bin /usr/lib/x86_64-linux-gnu/emacs/26.3/x86_64-linux-gnu)
config envfile nil
elc-files 0
modules (:completion company (ivy +icons) :ui doom hl-todo modeline nav-flash ophints vc-gutter vi-tilde-fringe window-select workspaces :editor file-templates fold multiple-cursors rotate-text snippets :emacs (dired +icons) electric ibuffer vc (undo +tree) :term eshell :checkers syntax spell :tools (eval +overlay) (lookup +docsets) magit make :lang (cc +irony +rtags) data emacs-lisp (latex +latexmk) markdown (org +attach +capture +dragndrop +present) python sh :email mu4e :app calendar :config literate (default +bindings +smartparens))
packages ((mu4e-alert) (hungry-delete) (yasnippet-snippets) (edit-server) (org-clock-today) (dired-subtree) (dired-single) (org-super-agenda) (xterm-color) (openwith) (rotate) (smartrep) (origami) (try) (el-patch) (auto-dim-other-buffers))
unpin (n/a)
elpa (n/a)
As of https://github.com/hlissner/doom-emacs/commit/8580b53e8e222a7eb3f7a959f950594a6fe710f8 this issue should be resolved. Let me know if that isn't the case and I'll reopen it. Thanks for bringing it to my attention!
Mmm.. I am not sure but I think this commit introduces an error. When I call doom sync, I get
Before first headline at position 46 in buffer config.org.9cUvcT
(I didn't get this before).
Also, when I save my literate file now, I get the error.
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
looking-at(nil)
org-heading-components()
org-in-commented-heading-p()
org-babel-tangle-collect-blocks(nil nil)
org-babel-tangle(nil "/home/abdo/.config/doom/config.el")
(save-current-buffer (set-buffer (find-file-noselect backup)) (org-export-expand-include-keyword) (org-babel-tangle nil dest) (kill-buffer (current-buffer)))
(progn (copy-file org backup t) (save-current-buffer (set-buffer (find-file-noselect backup)) (org-export-expand-include-keyword) (org-babel-tangle nil dest) (kill-buffer (current-buffer))) t)
(let ((org-mode-hook nil)) (progn (copy-file org backup t) (save-current-buffer (set-buffer (find-file-noselect backup)) (org-export-expand-include-keyword) (org-babel-tangle nil dest) (kill-buffer (current-buffer))) t))
(progn (fset (function message) vnew) (ignore message) (let ((org-mode-hook nil)) (progn (copy-file org backup t) (save-current-buffer (set-buffer (find-file-noselect backup)) (org-export-expand-include-keyword) (org-babel-tangle nil dest) (kill-buffer (current-buffer))) t)))
(unwind-protect (progn (fset (function message) vnew) (ignore message) (let ((org-mode-hook nil)) (progn (copy-file org backup t) (save-current-buffer (set-buffer (find-file-noselect backup)) (org-export-expand-include-keyword) (org-babel-tangle nil dest) (kill-buffer (current-buffer))) t))) (fset (function message) old))
(let* ((vnew (function (lambda (msg &rest args) (if msg (progn (doom--print ...)))))) (old (symbol-function (function message)))) (unwind-protect (progn (fset (function message) vnew) (ignore message) (let ((org-mode-hook nil)) (progn (copy-file org backup t) (save-current-buffer (set-buffer (find-file-noselect backup)) (org-export-expand-include-keyword) (org-babel-tangle nil dest) (kill-buffer (current-buffer))) t))) (fset (function message) old)))
(let ((message (symbol-function (function message)))) (let* ((vnew (function (lambda (msg &rest args) (if msg (progn ...))))) (old (symbol-function (function message)))) (unwind-protect (progn (fset (function message) vnew) (ignore message) (let ((org-mode-hook nil)) (progn (copy-file org backup t) (save-current-buffer (set-buffer ...) (org-export-expand-include-keyword) (org-babel-tangle nil dest) (kill-buffer ...)) t))) (fset (function message) old))))
(and (require (quote ox)) (require (quote ob-tangle)) (let ((message (symbol-function (function message)))) (let* ((vnew (function (lambda (msg &rest args) (if msg ...)))) (old (symbol-function (function message)))) (unwind-protect (progn (fset (function message) vnew) (ignore message) (let ((org-mode-hook nil)) (progn (copy-file org backup t) (save-current-buffer ... ... ... ...) t))) (fset (function message) old)))) (let ((temp-file +literate-config-cache-file) (temp-buffer (get-buffer-create (generate-new-buffer-name " *temp file*")))) (unwind-protect (prog1 (save-current-buffer (set-buffer temp-buffer)) (save-current-buffer (set-buffer temp-buffer) (write-region nil nil temp-file nil 0))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))
(unwind-protect (and (require (quote ox)) (require (quote ob-tangle)) (let ((message (symbol-function (function message)))) (let* ((vnew (function (lambda ... ...))) (old (symbol-function (function message)))) (unwind-protect (progn (fset (function message) vnew) (ignore message) (let (...) (progn ... ... t))) (fset (function message) old)))) (let ((temp-file +literate-config-cache-file) (temp-buffer (get-buffer-create (generate-new-buffer-name " *temp file*")))) (unwind-protect (prog1 (save-current-buffer (set-buffer temp-buffer)) (save-current-buffer (set-buffer temp-buffer) (write-region nil nil temp-file nil 0))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) (condition-case nil (progn (delete-file backup)) (error nil)))
(let* ((default-directory doom-private-dir) (org (expand-file-name +literate-config-file)) (dest (concat (file-name-sans-extension +literate-config-file) ".el")) (backup (make-temp-file (concat (file-name-nondirectory org) ".")))) (unwind-protect (and (require (quote ox)) (require (quote ob-tangle)) (let ((message (symbol-function (function message)))) (let* ((vnew (function ...)) (old (symbol-function ...))) (unwind-protect (progn (fset ... vnew) (ignore message) (let ... ...)) (fset (function message) old)))) (let ((temp-file +literate-config-cache-file) (temp-buffer (get-buffer-create (generate-new-buffer-name " *temp file*")))) (unwind-protect (prog1 (save-current-buffer (set-buffer temp-buffer)) (save-current-buffer (set-buffer temp-buffer) (write-region nil nil temp-file nil 0))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) (condition-case nil (progn (delete-file backup)) (error nil))))
(let ((doom-output-indent (+ doom-output-indent-increment doom-output-indent))) (let* ((default-directory doom-private-dir) (org (expand-file-name +literate-config-file)) (dest (concat (file-name-sans-extension +literate-config-file) ".el")) (backup (make-temp-file (concat (file-name-nondirectory org) ".")))) (unwind-protect (and (require (quote ox)) (require (quote ob-tangle)) (let ((message (symbol-function ...))) (let* ((vnew ...) (old ...)) (unwind-protect (progn ... ... ...) (fset ... old)))) (let ((temp-file +literate-config-cache-file) (temp-buffer (get-buffer-create ...))) (unwind-protect (prog1 (save-current-buffer ...) (save-current-buffer ... ...)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) (condition-case nil (progn (delete-file backup)) (error nil)))))
+literate-tangle-h()
(progn (+literate-tangle-h))
(if (file-in-directory-p buffer-file-name doom-private-dir) (progn (+literate-tangle-h)))
+literate-recompile-maybe-h()
run-hooks(after-save-hook)
basic-save-buffer(t)
save-buffer(1)
funcall-interactively(save-buffer 1)
call-interactively(save-buffer nil nil)
command-execute(save-buffer)
@hlissner This was fixed in recent commit.
Testing this feature, it is somewhat inconvenient that a temporary file is created IMO. This is because I tend to edit/save my config.org file a lot and this method pollutes my list of recent files. I am going to investigate what changed exactly, because this used to work (without temporary files and without pointer jumping) until recently.
@haji-ali I've since changed the method to use a temp buffer, which shouldn't create an entry in your recent files (nor does it leave any buffers open or left-over files). Please update and let me know if this isn't the case.
@hlissner, I am still seeing the temporary files in my recent files with the most recent commit (bf90423), although you are right about buffers not being left open now.
@haji-ali As of d2bc2ff it should no longer produce recent-files entries. Let me know if that works for you.