* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
@ 2022-11-26 14:42 Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-26 19:58 ` Eli Zaretskii
0 siblings, 1 reply; 26+ messages in thread
From: Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-11-26 14:42 UTC (permalink / raw)
To: 59618
Afternoon,
If attempting to capture something while global-whitespace-mode is on,
a second capture will fail with "Marker does not point anywhere". The
first capture attempt presumably succeeds since whitespace-mode didn't
touch the buffer yet at time of searching. Reproduction steps:
1. emacs -Q --execute '(global-whitespace-mode)'
2. M-x org-capture RET t C-c C-c
2. M-x org-capture RET t
Note that while I'm reporting this from the mu4e-headers mode, I
reproduced it in other modes before.
In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.34, cairo version 1.17.6) of 2022-11-22 built on localhost
Repository revision: 368d2531bec84c2e75b2fd2f32bb59fc2e7ee520
Repository branch: master
System Description: Gentoo Linux
Configured using:
'configure --prefix=/usr --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu --mandir=/usr/share/man
--infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc
--localstatedir=/var/lib --datarootdir=/usr/share
--disable-silent-rules --docdir=/usr/share/doc/emacs-29.0.9999
--htmldir=/usr/share/doc/emacs-29.0.9999/html --libdir=/usr/lib64
--program-suffix=-emacs-29-vcs --includedir=/usr/include/emacs-29-vcs
--infodir=/usr/share/info/emacs-29-vcs --localstatedir=/var
--enable-locallisppath=/etc/emacs:/usr/share/emacs/site-lisp
--without-compress-install --without-hesiod --without-pop
--with-file-notification=inotify --with-pdumper --enable-acl
--with-dbus --with-modules --with-gameuser=:gamestat --with-libgmp
--with-gpm --with-native-compilation=aot --with-json --without-kerberos
--without-kerberos5 --with-lcms2 --with-xml2 --without-mailutils
--without-selinux --with-sqlite3 --with-gnutls --with-libsystemd
--with-threads --without-wide-int --with-sound=alsa --with-zlib
--with-pgtk --without-x --without-ns --with-toolkit-scroll-bars
--without-gconf --without-gsettings --with-harfbuzz --with-libotf
--with-m17n-flt --with-xwidgets --with-gif --with-jpeg --with-png
--with-rsvg --with-tiff --without-webp --with-imagemagick
--with-dumping=pdumper 'CFLAGS=-O2 -pipe
-Werror=implicit-function-declaration -Werror=implicit-int'
'LDFLAGS=-Wl,-O1 -Wl,--as-needed''
Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM HARFBUZZ IMAGEMAGICK
JPEG JSON LCMS2 LIBOTF LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER XIM XWIDGETS GTK3 ZLIB
Important settings:
value of $LC_TIME: en_GB.UTF-8
value of $LANG: en_US.utf8
locale-coding-system: utf-8-unix
Major mode: mu4e-headers
Minor modes in effect:
global-git-commit-mode: t
magit-auto-revert-mode: t
shell-dirtrack-mode: t
server-mode: t
mu4e-search-minor-mode: t
hl-line-mode: t
mu4e-update-minor-mode: t
mu4e-context-minor-mode: t
override-global-mode: t
global-display-fill-column-indicator-mode: t
global-display-line-numbers-mode: t
display-line-numbers-mode: t
yas-global-mode: t
yas-minor-mode: t
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tab-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
buffer-read-only: t
column-number-mode: t
line-number-mode: t
indent-tabs-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
Load-path shadows:
~/.config/emacs/lp/poke-mode hides /usr/share/emacs/site-lisp/poke-mode
/usr/share/emacs/site-lisp/cmake-mode hides /usr/share/emacs/site-lisp/cmake/cmake-mode
/home/arsen/.config/emacs/elpa/dash-2.19.1/dash-functional hides /usr/share/emacs/site-lisp/dash/dash-functional
/home/arsen/.config/emacs/elpa/dash-2.19.1/dash hides /usr/share/emacs/site-lisp/dash/dash
/usr/share/emacs/site-lisp/desktop-entry-mode hides /usr/share/emacs/site-lisp/desktop-file-utils/desktop-entry-mode
/home/arsen/.config/emacs/elpa/with-editor-3.2.0/with-editor hides /usr/share/emacs/site-lisp/with-editor/with-editor
/home/arsen/.config/emacs/elpa/transient-0.3.7/transient hides /usr/share/emacs/29.0.50/lisp/transient
Features:
(shadow emacsbug term/tmux term/xterm xterm cl-print doctor cal-move
vc-dir magit-patch magit-subtree magit-gitignore magit-ediff ediff
ediff-merg ediff-mult ediff-wind ediff-diff ediff-help ediff-init
ediff-util gnus-msg autoconf-mode dired-aux po-mode calc-undo calccomp
calc-incom calc-misc bug-reference magit-extras magit-bookmark
magit-submodule magit-obsolete magit-blame magit-stash magit-reflog
magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote
magit-commit magit-sequence magit-notes magit-worktree magit-tag
magit-merge magit-branch magit-reset magit-files magit-refs magit-status
magit magit-repos magit-apply magit-wip magit-log which-func edebug
magit-diff git-commit log-edit magit-core magit-autorevert autorevert
magit-margin magit-transient magit-process with-editor magit-mode
transient magit-git magit-section magit-utils crm c-ts-mode term ehelp
cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs tramp-cmds tramp-cache time-stamp tramp-sh tramp
tramp-loaddefs trampver tramp-integration files-x tramp-compat shell
ls-lisp shortdoc tabify org-capture org-refile calc-alg calc-ext
calc-menu calc calc-loaddefs calc-macs novice url-http url-auth url-gw
eudc-capf eudc cus-edit cus-start cus-load eudc-vars smerge-mode diff
shr-color org-element avl-tree generator ol-eww eww xdg url-queue mm-url
ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect ol-docview doc-view
jka-compr image-mode exif ol-bibtex ol-bbdb ol-w3m ol-doi org-link-doi
gnus-score score-mode epa-file network-stream nsm mailalias rect
face-remap add-log make-mode emacs-news-mode mm-archive sort smiley
gnus-cite mail-extr textsec uni-scripts idna-mapping ucs-normalize
uni-confusable textsec-check qp misearch multi-isearch ebuild-mode
skeleton sh-script smie treesit executable vc-hg vc-git diff-mode vc-bzr
vc-src vc-sccs vc-svn vc-cvs vc-rcs log-view pcvs-util vc vc-dispatcher
server comp comp-cstr flyspell ispell gruvbox-dark-medium-theme gruvbox
autothemer color lisp-mnt dash mu4e mu4e-org mu4e-main mu4e-view
gnus-art mm-uu mml2015 mm-view mml-smime smime gnutls dig gnus-sum
gnus-group gnus-undo gnus-start gnus-dbus dbus gnus-cloud nnimap nnmail
mail-source utf7 nnoo parse-time gnus-spec gnus-int gnus-range gnus-win
gnus nnheader range wid-edit mu4e-headers mu4e-compose mu4e-draft
mu4e-actions smtpmail mu4e-search mu4e-lists mu4e-bookmarks mu4e-mark
mu4e-message shr pixel-fill kinsoku url-file svg xml dom flow-fill
mule-util hl-line mu4e-contacts mu4e-update mu4e-folders mu4e-server
mu4e-context mu4e-vars mu4e-helpers mu4e-config bookmark ido message
sendmail yank-media puny dired dired-loaddefs rfc822 mml mml-sec epa
derived epg rfc6068 epg-config gnus-util mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr
mailabbrev mail-utils gmm-utils mailheader auth-source-pass edmacro
kmacro use-package-bind-key bind-key use-package-ensure use-package-core
easy-mmode display-fill-column-indicator disp-table cl-extra
display-line-numbers yasnippet org ob ob-tangle ob-ref ob-lob ob-table
ob-exp org-macro org-footnote org-src ob-comint org-pcomplete pcomplete
org-list org-faces org-entities noutline outline org-version
ob-emacs-lisp ob-core ob-eval org-table oc-basic bibtex iso8601
time-date ol rx org-keys oc org-compat advice org-macs org-loaddefs
format-spec cal-menu calendar cal-loaddefs whitespace eglot array
filenotify jsonrpc ert pp ewoc debug backtrace find-func xref
flymake-proc flymake thingatpt warnings icons compile
text-property-search comint ansi-osc ansi-color pcase project imenu
site-gentoo magit-autoloads org-roam-autoloads magit-section-autoloads
emacsql-sqlite-autoloads yasnippet-autoloads git-commit-autoloads
use-package-autoloads bind-key-autoloads oauth2-autoloads
emacsql-autoloads gruvbox-theme-autoloads autothemer-autoloads
dash-autoloads with-editor-autoloads geiser-guile-autoloads geiser-impl
help-fns radix-tree help-mode geiser-custom geiser-base ring
geiser-autoloads info transient-autoloads package browse-url url
url-proxy url-privacy url-expand url-methods url-history url-cookie
generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs password-cache json subr-x
map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib rmc
iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-win
term/common-win pgtk-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads xwidget-internal dbusbind inotify dynamic-setting
font-render-setting cairo gtk pgtk lcms2 multi-tty make-network-process
native-compile emacs)
Memory information:
((conses 16 965984 412328)
(symbols 48 59263 39)
(strings 32 208039 25577)
(string-bytes 1 5924998)
(vectors 16 115323)
(vector-slots 8 2651886 744218)
(floats 8 704 1556)
(intervals 56 39870 6787)
(buffers 992 59))
<#secure method=pgpmime mode=sign>
Have a most wonderful day,
--
Arsen Arsenović
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-11-26 14:42 bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere" Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-11-26 19:58 ` Eli Zaretskii
2022-11-26 20:11 ` Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors
` (2 more replies)
0 siblings, 3 replies; 26+ messages in thread
From: Eli Zaretskii @ 2022-11-26 19:58 UTC (permalink / raw)
To: Arsen Arsenović; +Cc: 59618
> Date: Sat, 26 Nov 2022 15:42:27 +0100
> From: Arsen Arsenović via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>
> If attempting to capture something while global-whitespace-mode is on,
> a second capture will fail with "Marker does not point anywhere". The
> first capture attempt presumably succeeds since whitespace-mode didn't
> touch the buffer yet at time of searching. Reproduction steps:
>
> 1. emacs -Q --execute '(global-whitespace-mode)'
> 2. M-x org-capture RET t C-c C-c
> 2. M-x org-capture RET t
Isn't this a problem with org-capture? Did you try reporting this to the
Org developers first?
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-11-26 19:58 ` Eli Zaretskii
@ 2022-11-26 20:11 ` Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-27 0:27 ` Ihor Radchenko
2022-11-27 0:28 ` Ihor Radchenko
2 siblings, 0 replies; 26+ messages in thread
From: Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-11-26 20:11 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 59618
[-- Attachment #1: Type: text/plain, Size: 402 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
> Isn't this a problem with org-capture? Did you try reporting this to the
> Org developers first?
Oh, apologies. I failed to realize the bugs for each were tracked
separately.
I'll file a report there (and refer to this one in case it spills over
into Emacs too).
Have a wonderful evening, and again, sorry about the fuss.
--
Arsen Arsenović
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 381 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-11-26 19:58 ` Eli Zaretskii
2022-11-26 20:11 ` Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-11-27 0:27 ` Ihor Radchenko
2022-11-27 6:13 ` Stefan Kangas
2022-11-27 0:28 ` Ihor Radchenko
2 siblings, 1 reply; 26+ messages in thread
From: Ihor Radchenko @ 2022-11-27 0:27 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 59618, Arsen Arsenović
Eli Zaretskii <eliz@gnu.org> writes:
>> Date: Sat, 26 Nov 2022 15:42:27 +0100
>> From: Arsen Arsenović via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>>
>> If attempting to capture something while global-whitespace-mode is on,
>> a second capture will fail with "Marker does not point anywhere". The
>> first capture attempt presumably succeeds since whitespace-mode didn't
>> touch the buffer yet at time of searching. Reproduction steps:
>>
>> 1. emacs -Q --execute '(global-whitespace-mode)'
>> 2. M-x org-capture RET t C-c C-c
>> 2. M-x org-capture RET t
>
> Isn't this a problem with org-capture? Did you try reporting this to the
> Org developers first?
The error is thrown by global-whitespace-mode. Not by Org. Org just
intercepts the error in condition-case.
After following the above steps, please
4. Switch to .notes buffer
5. Select the last heading in the buffer
6. Kill it.
7. Observe the following backtrace
Debugger entered--Lisp error: (error "Marker does not point anywhere")
whitespace--update-bob-eob(37 37 30)
delete-and-extract-region(37 67)
#f(compiled-function (beg end delete) #<bytecode 0x153349b8bed5a7f1>)(37 67 delete)
apply(#f(compiled-function (beg end delete) #<bytecode 0x153349b8bed5a7f1>) (37 67 delete))
#f(compiled-function (funs global args) #<bytecode -0xf0b0e52c36c522>)(nil nil (37 67 delete))
buffer-substring--filter(37 67 delete)
(let ((return-string (buffer-substring--filter beg end delete)) props-list) (if (or (string= "" return-string) (<= end beg) (eq org-fold-core-style 'overlays)) nil (let ((tail (org-fold-core-folding-spec-list))) (while tail (let ((spec (car tail))) (if (and (org-fold-core-region-folded-p beg end spec) (org-region-invisible-p beg end)) (progn (setq props-list ...))) (setq tail (cdr tail))))) (let ((tail (if (fboundp 'object-intervals) (object-intervals return-string) (seq-partition (cdr ...) 3)))) (while tail (let ((plist (car tail))) (let* ((start ...) (fin ...) (plist ...)) (if (listp plist) (progn ...))) (setq tail (cdr tail))))) (remove-text-properties 0 (length return-string) props-list return-string)) return-string)
org-fold-core--buffer-substring-filter(37 67 delete)
filter-buffer-substring(37 67 delete)
#f(compiled-function (method) #<bytecode -0x2fea4bde9514e6c>)(delete)
kill-region(37 67 region)
funcall-interactively(kill-region 37 67 region)
command-execute(kill-region)
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-11-26 19:58 ` Eli Zaretskii
2022-11-26 20:11 ` Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-27 0:27 ` Ihor Radchenko
@ 2022-11-27 0:28 ` Ihor Radchenko
2 siblings, 0 replies; 26+ messages in thread
From: Ihor Radchenko @ 2022-11-27 0:28 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 59618, Arsen Arsenović
Eli Zaretskii <eliz@gnu.org> writes:
> Isn't this a problem with org-capture? Did you try reporting this to the
> Org developers first?
Another note: I can only reproduce using Emacs 29. Emacs 28 does not err.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-11-27 0:27 ` Ihor Radchenko
@ 2022-11-27 6:13 ` Stefan Kangas
2022-11-27 6:20 ` Ihor Radchenko
0 siblings, 1 reply; 26+ messages in thread
From: Stefan Kangas @ 2022-11-27 6:13 UTC (permalink / raw)
To: Ihor Radchenko, Eli Zaretskii; +Cc: 59618, Arsen Arsenović
Ihor Radchenko <yantar92@posteo.net> writes:
>>> 1. emacs -Q --execute '(global-whitespace-mode)'
>>> 2. M-x org-capture RET t C-c C-c
>>> 2. M-x org-capture RET t
>
> After following the above steps, please
>
> 4. Switch to .notes buffer
> 5. Select the last heading in the buffer
> 6. Kill it.
> 7. Observe the following backtrace
I fail to reproduce this bug using this recipe.
Could you please clarify what exactly you did in step 5 and 6?
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-11-27 6:13 ` Stefan Kangas
@ 2022-11-27 6:20 ` Ihor Radchenko
2022-11-27 6:54 ` Stefan Kangas
0 siblings, 1 reply; 26+ messages in thread
From: Ihor Radchenko @ 2022-11-27 6:20 UTC (permalink / raw)
To: Stefan Kangas; +Cc: 59618, Eli Zaretskii, Arsen Arsenović
Stefan Kangas <stefankangas@gmail.com> writes:
> I fail to reproduce this bug using this recipe.
>
> Could you please clarify what exactly you did in step 5 and 6?
Let me provide the detailed recipe I used:
1. rm ~/.notes (this is the default capture target)
2. emacs-29-vcs -Q --execute '(global-whitespace-mode)'
3. M-x org-capture <RET> t C-c C-c
4. M-x org-capture <RET> t
5. M-x toggle-debug-on-error
6. C-x b .notes
7. C-s %? <RET>
8. C-a
9. C-<SPC> M-> C-w
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-11-27 6:20 ` Ihor Radchenko
@ 2022-11-27 6:54 ` Stefan Kangas
2022-12-01 12:06 ` Eli Zaretskii
0 siblings, 1 reply; 26+ messages in thread
From: Stefan Kangas @ 2022-11-27 6:54 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: 59618, Eli Zaretskii, Arsen Arsenović, Richard Hansen
Ihor Radchenko <yantar92@posteo.net> writes:
> Stefan Kangas <stefankangas@gmail.com> writes:
>
>> I fail to reproduce this bug using this recipe.
>>
>> Could you please clarify what exactly you did in step 5 and 6?
>
> Let me provide the detailed recipe I used:
>
> 1. rm ~/.notes (this is the default capture target)
> 2. emacs-29-vcs -Q --execute '(global-whitespace-mode)'
> 3. M-x org-capture <RET> t C-c C-c
> 4. M-x org-capture <RET> t
> 5. M-x toggle-debug-on-error
> 6. C-x b .notes
> 7. C-s %? <RET>
> 8. C-a
> 9. C-<SPC> M-> C-w
Thanks, I can reproduce the backtrace now.
Stepping through `whitespace--update-bob-eob' with edebug shows that the
`goto-char' in this fragment fails, because `whitespace-bob-marker' is
nil:
(save-excursion
(goto-char whitespace-bob-marker)
;; Any change in the first non-`empty'
;; line, even if it's not the first
;; character in the line, can potentially
;; cause subsequent lines to become
;; classified as `empty' (e.g., delete the
;; "x" from " x").
(forward-line 1)
(point))
The `whitespace--update-bob-eob' function is new in Emacs 29 and was
added in commit f47a5324f44e by Richard Hansen (in Cc).
Here is the backtrace again, for reference:
Debugger entered--Lisp error: (error "Marker does not point anywhere")
whitespace--update-bob-eob(37 37 29)
delete-and-extract-region(37 66)
#f(compiled-function (beg end delete) #<bytecode
0x15337359c91d96f1>)(37 66 delete)
apply(#f(compiled-function (beg end delete) #<bytecode
0x15337359c91d96f1>) (37 66 delete))
#f(compiled-function (funs global args) #<bytecode
-0xf6c557b8176d62>)(nil nil (37 66 delete))
buffer-substring--filter(37 66 delete)
filter-buffer-substring(37 66 delete)
#f(compiled-function (method) #<bytecode -0x2fb4b4ebabaf02c>)(delete)
kill-region(37 66 region)
funcall-interactively(kill-region 37 66 region)
command-execute(kill-region)
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-11-27 6:54 ` Stefan Kangas
@ 2022-12-01 12:06 ` Eli Zaretskii
2022-12-01 15:02 ` Stefan Kangas
2022-12-13 6:25 ` Richard Hansen
0 siblings, 2 replies; 26+ messages in thread
From: Eli Zaretskii @ 2022-12-01 12:06 UTC (permalink / raw)
To: Stefan Kangas, rhansen; +Cc: 59618, yantar92, arsen
> From: Stefan Kangas <stefankangas@gmail.com>
> Date: Sat, 26 Nov 2022 22:54:25 -0800
> Cc: Eli Zaretskii <eliz@gnu.org>, 59618@debbugs.gnu.org,
> Arsen Arsenović <arsen@aarsen.me>,
> Richard Hansen <rhansen@rhansen.org>
>
> Stepping through `whitespace--update-bob-eob' with edebug shows that the
> `goto-char' in this fragment fails, because `whitespace-bob-marker' is
> nil:
Is it really nil or is it a marker that "points nowhere"?
This part:
> Here is the backtrace again, for reference:
>
> Debugger entered--Lisp error: (error "Marker does not point anywhere")
> whitespace--update-bob-eob(37 37 29)
seems to indicate the latter.
Anyway, it sounds like the changes in f47a5324f44e caused the two markers,
whitespace-bob-marker and whitespace-eob-marker to sometimes "point
nowhere". The band-aid patch below avoids the error reported in this bug,
but redisplay still complains in *Messsages*:
Error during redisplay: (jit-lock-function 45) signaled (error "Marker does not point anywhere")
Richard, please chime in.
Here's the band-aid patch I promised:
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index 25ea07e..bed2a82 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -2315,7 +2315,11 @@ whitespace-post-command-hook
(unless (and (eq whitespace-point (point))
(not whitespace-buffer-changed))
(when (and (not whitespace-buffer-changed)
- (memq 'empty whitespace-active-style))
+ (memq 'empty whitespace-active-style)
+ (markerp whitespace-bob-marker)
+ (bufferp (marker-buffer whitespace-bob-marker))
+ (markerp whitespace-eob-marker)
+ (bufferp (marker-buffer whitespace-eob-marker)))
;; No need to handle the `whitespace-buffer-changed' case here
;; because that is taken care of by the `font-lock-multiline'
;; text property.
@@ -2422,6 +2426,8 @@ whitespace--update-bob-eob
(widen)
(let ((inhibit-read-only t))
(when (or (null beg)
+ (and (markerp whitespace-bob-marker)
+ (bufferp (marker-buffer whitespace-bob-marker))
(<= beg (save-excursion
(goto-char whitespace-bob-marker)
;; Any change in the first non-`empty'
@@ -2431,7 +2437,7 @@ whitespace--update-bob-eob
;; classified as `empty' (e.g., delete the
;; "x" from " x").
(forward-line 1)
- (point))))
+ (point)))))
(goto-char 1)
(set-marker whitespace-bob-marker (point))
(save-match-data
@@ -2440,11 +2446,13 @@ whitespace--update-bob-eob
(put-text-property (match-beginning 1) (match-end 1)
'font-lock-multiline t))))
(when (or (null end)
+ (and (markerp whitespace-eob-marker)
+ (bufferp (marker-buffer whitespace-eob-marker))
(>= end (save-excursion
(goto-char whitespace-eob-marker)
;; See above comment for the BoB case.
(forward-line -1)
- (point))))
+ (point)))))
(goto-char (1+ (buffer-size)))
(set-marker whitespace-eob-marker (point))
(save-match-data
^ permalink raw reply related [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-12-01 12:06 ` Eli Zaretskii
@ 2022-12-01 15:02 ` Stefan Kangas
2022-12-13 6:25 ` Richard Hansen
1 sibling, 0 replies; 26+ messages in thread
From: Stefan Kangas @ 2022-12-01 15:02 UTC (permalink / raw)
To: Eli Zaretskii, rhansen; +Cc: 59618, yantar92, arsen
Eli Zaretskii <eliz@gnu.org> writes:
>> Stepping through `whitespace--update-bob-eob' with edebug shows that the
>> `goto-char' in this fragment fails, because `whitespace-bob-marker' is
>> nil:
>
> Is it really nil or is it a marker that "points nowhere"?
I think it is the latter, yes. Sorry for the confusion.
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-12-01 12:06 ` Eli Zaretskii
2022-12-01 15:02 ` Stefan Kangas
@ 2022-12-13 6:25 ` Richard Hansen
2022-12-13 6:34 ` Ihor Radchenko
1 sibling, 1 reply; 26+ messages in thread
From: Richard Hansen @ 2022-12-13 6:25 UTC (permalink / raw)
To: Eli Zaretskii, Stefan Kangas; +Cc: 59618, yantar92, arsen
[-- Attachment #1.1: Type: text/plain, Size: 994 bytes --]
I believe this is caused by an interaction between indirect buffers and
after-change-functions. In the buffer with the error,
whitespace--update-bob-eob is in after-change-functions even though
whitespace-color-on (which is the only place that hook is registered) is
never called on the buffer. whitespace-color-on sets up state that
whitespace--update-bob-eob depends on, which is why the error occurs.
I see no mention of after-change-functions in the documentation for
indirect buffers, and no mention of indirect buffers in the
documentation for after-change-functions. I'm not sure how they're
supposed to interact, so I'm not sure if this is a bug in whitespace,
indirect buffers, or even org. We could slap a bandaid on whitespace.el
to work around this issue, but I'd rather fix this the right way. I'm
not sure what the right way is; if someone who understands indirect
buffers could give me some tips I'd appreciate it.
bug#46982 might be related.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-12-13 6:25 ` Richard Hansen
@ 2022-12-13 6:34 ` Ihor Radchenko
2022-12-13 6:38 ` Richard Hansen
0 siblings, 1 reply; 26+ messages in thread
From: Ihor Radchenko @ 2022-12-13 6:34 UTC (permalink / raw)
To: Richard Hansen; +Cc: 59618, Eli Zaretskii, arsen, Stefan Kangas
Richard Hansen <rhansen@rhansen.org> writes:
> I believe this is caused by an interaction between indirect buffers and
> after-change-functions. In the buffer with the error,
> whitespace--update-bob-eob is in after-change-functions even though
> whitespace-color-on (which is the only place that hook is registered) is
> never called on the buffer. whitespace-color-on sets up state that
> whitespace--update-bob-eob depends on, which is why the error occurs.
Org's capture buffer is created by calling `make-indirect-buffer' with
CLONE argument. This makes Emacs clone buffer local variables,
including `after-change-functions'.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-12-13 6:34 ` Ihor Radchenko
@ 2022-12-13 6:38 ` Richard Hansen
2022-12-13 6:48 ` Ihor Radchenko
0 siblings, 1 reply; 26+ messages in thread
From: Richard Hansen @ 2022-12-13 6:38 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: 59618, Eli Zaretskii, arsen, Stefan Kangas
[-- Attachment #1.1: Type: text/plain, Size: 337 bytes --]
On 12/13/22 01:34, Ihor Radchenko wrote:
> Org's capture buffer is created by calling `make-indirect-buffer' with
> CLONE argument. This makes Emacs clone buffer local variables,
> including `after-change-functions'.
Sounds like setting CLONE to t does not clone markers. That sounds like
a bug in `make-indirect-buffer', no?
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-12-13 6:38 ` Richard Hansen
@ 2022-12-13 6:48 ` Ihor Radchenko
2022-12-14 2:42 ` Richard Hansen
0 siblings, 1 reply; 26+ messages in thread
From: Ihor Radchenko @ 2022-12-13 6:48 UTC (permalink / raw)
To: Richard Hansen; +Cc: 59618, Eli Zaretskii, arsen, Stefan Kangas
Richard Hansen <rhansen@rhansen.org> writes:
> On 12/13/22 01:34, Ihor Radchenko wrote:
>> Org's capture buffer is created by calling `make-indirect-buffer' with
>> CLONE argument. This makes Emacs clone buffer local variables,
>> including `after-change-functions'.
>
> Sounds like setting CLONE to t does not clone markers. That sounds like
> a bug in `make-indirect-buffer', no?
AFAIK, it does clone markers. Also changing marker buffer appropriately.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-12-13 6:48 ` Ihor Radchenko
@ 2022-12-14 2:42 ` Richard Hansen
2022-12-14 12:09 ` Eli Zaretskii
0 siblings, 1 reply; 26+ messages in thread
From: Richard Hansen @ 2022-12-14 2:42 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: 59618, Eli Zaretskii, arsen, Stefan Kangas
[-- Attachment #1.1: Type: text/plain, Size: 603 bytes --]
On 12/13/22 01:48, Ihor Radchenko wrote:
> Richard Hansen <rhansen@rhansen.org> writes:
>> Sounds like setting CLONE to t does not clone markers. That sounds like
>> a bug in `make-indirect-buffer', no?
>
> AFAIK, it does clone markers. Also changing marker buffer appropriately.
Hmm, maybe not. The following fails:
emacs -Q
(progn
(whitespace-mode 1)
(with-current-buffer (clone-indirect-buffer "foo" nil)
(cl-assert (eq (current-buffer)
(marker-buffer whitespace-bob-marker)))))
C-x C-e
I don't know if this is working as intended or a bug.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-12-14 2:42 ` Richard Hansen
@ 2022-12-14 12:09 ` Eli Zaretskii
2022-12-14 14:15 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 26+ messages in thread
From: Eli Zaretskii @ 2022-12-14 12:09 UTC (permalink / raw)
To: Richard Hansen, Stefan Monnier; +Cc: 59618, yantar92, arsen, stefankangas
> Date: Tue, 13 Dec 2022 21:42:35 -0500
> Cc: Eli Zaretskii <eliz@gnu.org>, Stefan Kangas <stefankangas@gmail.com>,
> 59618@debbugs.gnu.org, arsen@aarsen.me
> From: Richard Hansen <rhansen@rhansen.org>
>
> On 12/13/22 01:48, Ihor Radchenko wrote:
> > Richard Hansen <rhansen@rhansen.org> writes:
> >> Sounds like setting CLONE to t does not clone markers. That sounds like
> >> a bug in `make-indirect-buffer', no?
> >
> > AFAIK, it does clone markers. Also changing marker buffer appropriately.
>
> Hmm, maybe not. The following fails:
>
> emacs -Q
>
> (progn
> (whitespace-mode 1)
> (with-current-buffer (clone-indirect-buffer "foo" nil)
> (cl-assert (eq (current-buffer)
> (marker-buffer whitespace-bob-marker)))))
>
> C-x C-e
>
> I don't know if this is working as intended or a bug.
Adding Stefan, in case he has comments.
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-12-14 12:09 ` Eli Zaretskii
@ 2022-12-14 14:15 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-14 15:08 ` Ihor Radchenko
0 siblings, 1 reply; 26+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-14 14:15 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 59618, yantar92, arsen, stefankangas, Richard Hansen
>> >> Sounds like setting CLONE to t does not clone markers. That sounds like
>> >> a bug in `make-indirect-buffer', no?
>> >
>> > AFAIK, it does clone markers. Also changing marker buffer appropriately.
>>
>> Hmm, maybe not. The following fails:
>>
>> emacs -Q
>>
>> (progn
>> (whitespace-mode 1)
>> (with-current-buffer (clone-indirect-buffer "foo" nil)
>> (cl-assert (eq (current-buffer)
>> (marker-buffer whitespace-bob-marker)))))
the buffer cloning code can't know that a given marker is stored in a variable.
So when it clones the variables, both buffers's `whitespace-bob-marker`
variable will point to the same marker.
While we could try and solve it for this specific case by looking for
buffer-local variables that contains markers, the problem is much more
general (think of the case where the buffer var contains a list of
markers, or a hash-table containing markers, or ...), so `clone-buffer`
does not try to solve it.
Instead modes that use such variables are responsable to setup
a `clone-buffer-hook` that does the necessary work.
Stefan
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-12-14 14:15 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-12-14 15:08 ` Ihor Radchenko
2022-12-14 17:40 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 26+ messages in thread
From: Ihor Radchenko @ 2022-12-14 15:08 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 59618, Eli Zaretskii, arsen, stefankangas, Richard Hansen
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> Instead modes that use such variables are responsable to setup
> a `clone-buffer-hook` that does the necessary work.
*clone-indirect-buffer-hook
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-12-14 15:08 ` Ihor Radchenko
@ 2022-12-14 17:40 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-14 17:48 ` Ihor Radchenko
0 siblings, 1 reply; 26+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-14 17:40 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: 59618, Eli Zaretskii, arsen, stefankangas, Richard Hansen
Ihor Radchenko [2022-12-14 15:08:34] wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> Instead modes that use such variables are responsable to setup
>> a `clone-buffer-hook` that does the necessary work.
>
> *clone-indirect-buffer-hook
For indirect clones, yes. The original motivation for this infrastructure
was Info where we use `clone-buffer` and hence `clone-buffer-hook`.
Stefan
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-12-14 17:40 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-12-14 17:48 ` Ihor Radchenko
2022-12-14 20:10 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 26+ messages in thread
From: Ihor Radchenko @ 2022-12-14 17:48 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 59618, Eli Zaretskii, arsen, stefankangas, Richard Hansen
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> Ihor Radchenko [2022-12-14 15:08:34] wrote:
>> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> Instead modes that use such variables are responsable to setup
>>> a `clone-buffer-hook` that does the necessary work.
>>
>> *clone-indirect-buffer-hook
>
> For indirect clones, yes. The original motivation for this infrastructure
> was Info where we use `clone-buffer` and hence `clone-buffer-hook`.
I see. Though `clone-indirect-buffer-hook' is probably more appropriate
to be used in the context of this bug report.
Side note: Org implements something similar to `clone-buffer', but for
file visiting buffers (`org-export-copy-buffer`). Would it be something
of interest for Emacs?
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-12-14 17:48 ` Ihor Radchenko
@ 2022-12-14 20:10 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-18 9:24 ` bug#59618: [PATCH] " Richard Hansen
0 siblings, 1 reply; 26+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-14 20:10 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: 59618, Eli Zaretskii, arsen, stefankangas, Richard Hansen
>> For indirect clones, yes. The original motivation for this infrastructure
>> was Info where we use `clone-buffer` and hence `clone-buffer-hook`.
> I see. Though `clone-indirect-buffer-hook' is probably more appropriate
> to be used in the context of this bug report.
If `org-capture` uses an indirect buffer, indeed.
Modes which can be used with both should setup both hooks.
> Side note: Org implements something similar to `clone-buffer', but for
> file visiting buffers (`org-export-copy-buffer`). Would it be something
> of interest for Emacs?
There seems to be a lot of overlap with `clone-buffer`, so it would make
sense to try and merge them, yes. I don't think we want to
support/encourage situations where we have multiple buffers with the
same `buffer-file-name` like `org-export-copy-buffer` creates, but we
could provide some alternative where the clone has `buffer-file-name`
set to nil but the old value (or the origin bugger) is recorded in
another buffer-local var.
Stefan
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: [PATCH] Re: bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-12-14 20:10 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-12-18 9:24 ` Richard Hansen
2022-12-20 0:41 ` bug#59618: [PATCH] " Richard Hansen
0 siblings, 1 reply; 26+ messages in thread
From: Richard Hansen @ 2022-12-18 9:24 UTC (permalink / raw)
To: Stefan Monnier, Ihor Radchenko; +Cc: 59618, Eli Zaretskii, arsen, stefankangas
[-- Attachment #1.1.1: Type: text/plain, Size: 171 bytes --]
Attached is a patch that should fix this issue. I have some other
`whitespace-mode' fixes in progress; I'll open new issues (or reply to
existing issues) for those.
[-- Attachment #1.1.2: 0001-whitespace-Avoid-mutating-original-buffer-s-markers-.patch --]
[-- Type: text/x-patch, Size: 6859 bytes --]
From c22833b22cb0a1cb631bfc1fe04881d7ee9bf3d1 Mon Sep 17 00:00:00 2001
From: Richard Hansen <rhansen@rhansen.org>
Date: Tue, 13 Dec 2022 01:33:43 -0500
Subject: [PATCH] whitespace: Avoid mutating original buffer's markers in
clones
* lisp/whitespace.el (whitespace--clone): New hook function that is
run after cloning a buffer that copies `whitespace-bob-marker' and
`whitespace-eob-marker' and changes the copies to point to the new
buffer (Bug#59618).
(whitespace-color-on): Register the hook function.
(whitespace-color-off): Unregister the hook function.
---
lisp/whitespace.el | 15 +++++++
test/lisp/whitespace-tests.el | 75 +++++++++++++++++++++++++++++++++++
2 files changed, 90 insertions(+)
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index 25ea07e9db..2c1520ec6a 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -2093,6 +2093,17 @@ whitespace-style-face-p
t))
+(defun whitespace--clone ()
+ "Hook function run after `make-indirect-buffer' and `clone-buffer'."
+ (when (whitespace-style-face-p)
+ (setq-local whitespace-bob-marker
+ (copy-marker (marker-position whitespace-bob-marker)
+ (marker-insertion-type whitespace-bob-marker)))
+ (setq-local whitespace-eob-marker
+ (copy-marker (marker-position whitespace-eob-marker)
+ (marker-insertion-type whitespace-eob-marker)))))
+
+
(defun whitespace-color-on ()
"Turn on color visualization."
(when (whitespace-style-face-p)
@@ -2111,6 +2122,8 @@ whitespace-color-on
;; The -1 ensures that it runs before any
;; `font-lock-mode' hook functions.
-1 t)
+ (add-hook 'clone-buffer-hook #'whitespace--clone nil t)
+ (add-hook 'clone-indirect-buffer-hook #'whitespace--clone nil t)
;; Add whitespace-mode color into font lock.
(setq
whitespace-font-lock-keywords
@@ -2204,6 +2217,8 @@ whitespace-color-off
(remove-hook 'before-change-functions #'whitespace-buffer-changed t)
(remove-hook 'after-change-functions #'whitespace--update-bob-eob
t)
+ (remove-hook 'clone-buffer-hook #'whitespace--clone t)
+ (remove-hook 'clone-indirect-buffer-hook #'whitespace--clone t)
(font-lock-remove-keywords nil whitespace-font-lock-keywords)
(font-lock-flush)))
diff --git a/test/lisp/whitespace-tests.el b/test/lisp/whitespace-tests.el
index fb53543c9e..330fc335ea 100644
--- a/test/lisp/whitespace-tests.el
+++ b/test/lisp/whitespace-tests.el
@@ -42,6 +42,13 @@ whitespace-tests--with-test-buffer
'(whitespace-mode 1))
,@body)))
+(defmacro whitespace--with-buffer-selected (buffer-or-name &rest body)
+ (declare (debug (form body)) (indent 1))
+ `(save-window-excursion
+ (with-current-buffer (or ,buffer-or-name (current-buffer))
+ (with-selected-window (display-buffer (current-buffer))
+ ,@body))))
+
(defun whitespace-tests--faceup (&rest lines)
"Convenience wrapper around `faceup-test-font-lock-buffer'.
Returns non-nil if the concatenated LINES match the current
@@ -327,6 +334,74 @@ whitespace-tests--empty-bob-eob-read-only-buffer
"«:whitespace-empty:\n"
"»")))))
+(ert-deftest whitespace-tests--indirect-clone-breaks-base-markers ()
+ "Specific regression test for Bug#59618."
+ (whitespace-tests--with-test-buffer '(face empty)
+ (insert "\nx\n\n")
+ (let ((base (current-buffer))
+ ;; `unwind-protect' is not used to clean up `indirect'
+ ;; because the buffer should only be killed on success.
+ (indirect (clone-indirect-buffer (buffer-name) nil)))
+ (should (eq (marker-buffer whitespace-bob-marker) base))
+ (should (eq (marker-buffer whitespace-eob-marker) base))
+ (whitespace--with-buffer-selected indirect
+ ;; Mutate the indirect buffer to update its bob/eob markers.
+ (execute-kbd-macro (kbd "z RET M-< a")))
+ ;; With Bug#59618, the above mutation would cause the base
+ ;; buffer's markers to point inside the indirect buffer because
+ ;; the indirect buffer erroneously shared marker objects with
+ ;; the base buffer. Killing the indirect buffer would then
+ ;; invalidate those markers (make them point nowhere).
+ (kill-buffer indirect)
+ (should (eq (marker-buffer whitespace-bob-marker) base))
+ (should (eq (marker-buffer whitespace-eob-marker) base)))))
+
+(defun whitespace-tests--check-markers (buf bpos epos)
+ (with-current-buffer buf
+ (should (eq (marker-buffer whitespace-bob-marker) buf))
+ (should (eq (marker-position whitespace-bob-marker) bpos))
+ (should (eq (marker-buffer whitespace-eob-marker) buf))
+ (should (eq (marker-position whitespace-eob-marker) epos))))
+
+(ert-deftest whitespace-tests--indirect-clone-markers ()
+ "Test `whitespace--clone' on indirect clones."
+ (whitespace-tests--with-test-buffer '(face empty)
+ (insert "\nx\n\n")
+ (let ((base (current-buffer))
+ ;; `unwind-protect' is not used to clean up `indirect'
+ ;; because the buffer should only be killed on success.
+ (indirect (clone-indirect-buffer nil nil)))
+ (whitespace-tests--check-markers base 2 4)
+ (whitespace--with-buffer-selected indirect
+ (whitespace-tests--check-markers indirect 2 4)
+ ;; Mutate the buffer to trigger `after-change-functions' and
+ ;; thus `whitespace--update-bob-eob'.
+ (execute-kbd-macro (kbd "z RET M-< a"))
+ (whitespace-tests--check-markers indirect 1 8))
+ (kill-buffer indirect)
+ ;; When the buffer was modified above, the new "a" character at
+ ;; the beginning moved the base buffer's markers by one. Emacs
+ ;; did not run the base buffer's `after-change-functions' after
+ ;; the indirect buffer was edited (Bug#46982), so the end result
+ ;; is just the shift by one.
+ (whitespace-tests--check-markers base 3 5))))
+
+(ert-deftest whitespace-tests--regular-clone-markers ()
+ "Test `whitespace--clone' on regular clones."
+ (whitespace-tests--with-test-buffer '(face empty)
+ (insert "\nx\n\n")
+ (let ((orig (current-buffer))
+ ;; `unwind-protect' is not used to clean up `clone' because
+ ;; the buffer should only be killed on success.
+ (clone (clone-buffer)))
+ (whitespace-tests--check-markers orig 2 4)
+ (whitespace--with-buffer-selected clone
+ (whitespace-tests--check-markers clone 2 4)
+ (execute-kbd-macro (kbd "z RET M-< a"))
+ (whitespace-tests--check-markers clone 1 8))
+ (kill-buffer clone)
+ (whitespace-tests--check-markers orig 2 4))))
+
(provide 'whitespace-tests)
;;; whitespace-tests.el ends here
--
2.39.0
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related [flat|nested] 26+ messages in thread
* bug#59618: [PATCH] bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-12-18 9:24 ` bug#59618: [PATCH] " Richard Hansen
@ 2022-12-20 0:41 ` Richard Hansen
2022-12-20 13:52 ` Eli Zaretskii
0 siblings, 1 reply; 26+ messages in thread
From: Richard Hansen @ 2022-12-20 0:41 UTC (permalink / raw)
To: Stefan Monnier, Ihor Radchenko; +Cc: 59618, Eli Zaretskii, arsen, stefankangas
[-- Attachment #1.1.1: Type: text/plain, Size: 130 bytes --]
Attached is a new version of the patch. The only change is that it was rebased onto latest emacs-29 so that it applies cleanly.
[-- Attachment #1.1.2: 0001-whitespace-Avoid-mutating-original-buffer-s-markers-.patch --]
[-- Type: text/x-patch, Size: 6806 bytes --]
From 41b0e596f32769f9601bcb3cc1f91cc2cb36641e Mon Sep 17 00:00:00 2001
From: Richard Hansen <rhansen@rhansen.org>
Date: Tue, 13 Dec 2022 01:33:43 -0500
Subject: [PATCH] whitespace: Avoid mutating original buffer's markers in
clones
* lisp/whitespace.el (whitespace--clone): New hook function that is
run after cloning a buffer that copies `whitespace-bob-marker' and
`whitespace-eob-marker' and changes the copies to point to the new
buffer (Bug#59618).
(whitespace-color-on): Register the hook function.
(whitespace-color-off): Unregister the hook function.
---
lisp/whitespace.el | 15 +++++++
test/lisp/whitespace-tests.el | 75 +++++++++++++++++++++++++++++++++++
2 files changed, 90 insertions(+)
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index 9bc6ad9db4..558be1841a 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -2093,6 +2093,17 @@ whitespace-style-face-p
t))
+(defun whitespace--clone ()
+ "Hook function run after `make-indirect-buffer' and `clone-buffer'."
+ (when (whitespace-style-face-p)
+ (setq-local whitespace-bob-marker
+ (copy-marker (marker-position whitespace-bob-marker)
+ (marker-insertion-type whitespace-bob-marker)))
+ (setq-local whitespace-eob-marker
+ (copy-marker (marker-position whitespace-eob-marker)
+ (marker-insertion-type whitespace-eob-marker)))))
+
+
(defun whitespace-color-on ()
"Turn on color visualization."
(when (whitespace-style-face-p)
@@ -2111,6 +2122,8 @@ whitespace-color-on
;; The -1 ensures that it runs before any
;; `font-lock-mode' hook functions.
-1 t)
+ (add-hook 'clone-buffer-hook #'whitespace--clone nil t)
+ (add-hook 'clone-indirect-buffer-hook #'whitespace--clone nil t)
;; Add whitespace-mode color into font lock.
(setq
whitespace-font-lock-keywords
@@ -2204,6 +2217,8 @@ whitespace-color-off
(remove-hook 'before-change-functions #'whitespace-buffer-changed t)
(remove-hook 'after-change-functions #'whitespace--update-bob-eob
t)
+ (remove-hook 'clone-buffer-hook #'whitespace--clone t)
+ (remove-hook 'clone-indirect-buffer-hook #'whitespace--clone t)
(font-lock-remove-keywords nil whitespace-font-lock-keywords)
(font-lock-flush)))
diff --git a/test/lisp/whitespace-tests.el b/test/lisp/whitespace-tests.el
index 3e94d7e921..12f6cb99a2 100644
--- a/test/lisp/whitespace-tests.el
+++ b/test/lisp/whitespace-tests.el
@@ -42,6 +42,13 @@ whitespace-tests--with-test-buffer
'(whitespace-mode 1))
,@body)))
+(defmacro whitespace--with-buffer-selected (buffer-or-name &rest body)
+ (declare (debug (form body)) (indent 1))
+ `(save-window-excursion
+ (with-current-buffer (or ,buffer-or-name (current-buffer))
+ (with-selected-window (display-buffer (current-buffer))
+ ,@body))))
+
(defun whitespace-tests--faceup (&rest lines)
"Convenience wrapper around `faceup-test-font-lock-buffer'.
Returns non-nil if the concatenated LINES match the current
@@ -337,6 +344,74 @@ whitespace-tests--empty-bob-eob-modified
(whitespace-mode 1)
(should (not (buffer-modified-p))))))
+(ert-deftest whitespace-tests--indirect-clone-breaks-base-markers ()
+ "Specific regression test for Bug#59618."
+ (whitespace-tests--with-test-buffer '(face empty)
+ (insert "\nx\n\n")
+ (let ((base (current-buffer))
+ ;; `unwind-protect' is not used to clean up `indirect'
+ ;; because the buffer should only be killed on success.
+ (indirect (clone-indirect-buffer (buffer-name) nil)))
+ (should (eq (marker-buffer whitespace-bob-marker) base))
+ (should (eq (marker-buffer whitespace-eob-marker) base))
+ (whitespace--with-buffer-selected indirect
+ ;; Mutate the indirect buffer to update its bob/eob markers.
+ (execute-kbd-macro (kbd "z RET M-< a")))
+ ;; With Bug#59618, the above mutation would cause the base
+ ;; buffer's markers to point inside the indirect buffer because
+ ;; the indirect buffer erroneously shared marker objects with
+ ;; the base buffer. Killing the indirect buffer would then
+ ;; invalidate those markers (make them point nowhere).
+ (kill-buffer indirect)
+ (should (eq (marker-buffer whitespace-bob-marker) base))
+ (should (eq (marker-buffer whitespace-eob-marker) base)))))
+
+(defun whitespace-tests--check-markers (buf bpos epos)
+ (with-current-buffer buf
+ (should (eq (marker-buffer whitespace-bob-marker) buf))
+ (should (eq (marker-position whitespace-bob-marker) bpos))
+ (should (eq (marker-buffer whitespace-eob-marker) buf))
+ (should (eq (marker-position whitespace-eob-marker) epos))))
+
+(ert-deftest whitespace-tests--indirect-clone-markers ()
+ "Test `whitespace--clone' on indirect clones."
+ (whitespace-tests--with-test-buffer '(face empty)
+ (insert "\nx\n\n")
+ (let ((base (current-buffer))
+ ;; `unwind-protect' is not used to clean up `indirect'
+ ;; because the buffer should only be killed on success.
+ (indirect (clone-indirect-buffer nil nil)))
+ (whitespace-tests--check-markers base 2 4)
+ (whitespace--with-buffer-selected indirect
+ (whitespace-tests--check-markers indirect 2 4)
+ ;; Mutate the buffer to trigger `after-change-functions' and
+ ;; thus `whitespace--update-bob-eob'.
+ (execute-kbd-macro (kbd "z RET M-< a"))
+ (whitespace-tests--check-markers indirect 1 8))
+ (kill-buffer indirect)
+ ;; When the buffer was modified above, the new "a" character at
+ ;; the beginning moved the base buffer's markers by one. Emacs
+ ;; did not run the base buffer's `after-change-functions' after
+ ;; the indirect buffer was edited (Bug#46982), so the end result
+ ;; is just the shift by one.
+ (whitespace-tests--check-markers base 3 5))))
+
+(ert-deftest whitespace-tests--regular-clone-markers ()
+ "Test `whitespace--clone' on regular clones."
+ (whitespace-tests--with-test-buffer '(face empty)
+ (insert "\nx\n\n")
+ (let ((orig (current-buffer))
+ ;; `unwind-protect' is not used to clean up `clone' because
+ ;; the buffer should only be killed on success.
+ (clone (clone-buffer)))
+ (whitespace-tests--check-markers orig 2 4)
+ (whitespace--with-buffer-selected clone
+ (whitespace-tests--check-markers clone 2 4)
+ (execute-kbd-macro (kbd "z RET M-< a"))
+ (whitespace-tests--check-markers clone 1 8))
+ (kill-buffer clone)
+ (whitespace-tests--check-markers orig 2 4))))
+
(provide 'whitespace-tests)
;;; whitespace-tests.el ends here
--
2.39.0
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related [flat|nested] 26+ messages in thread
* bug#59618: [PATCH] bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-12-20 0:41 ` bug#59618: [PATCH] " Richard Hansen
@ 2022-12-20 13:52 ` Eli Zaretskii
2022-12-21 13:34 ` Ihor Radchenko
0 siblings, 1 reply; 26+ messages in thread
From: Eli Zaretskii @ 2022-12-20 13:52 UTC (permalink / raw)
To: Richard Hansen, yantar92; +Cc: 59618, arsen, monnier, stefankangas
> Date: Mon, 19 Dec 2022 19:41:31 -0500
> From: Richard Hansen <rhansen@rhansen.org>
> Cc: Eli Zaretskii <eliz@gnu.org>, stefankangas@gmail.com,
> 59618@debbugs.gnu.org, arsen@aarsen.me
> Attached is a new version of the patch. The only change is that it was rebased onto latest emacs-29 so that it applies cleanly.
Thanks.
Ihor, would you please see if this fixes the problem, so that we could
install it?
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: [PATCH] bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-12-20 13:52 ` Eli Zaretskii
@ 2022-12-21 13:34 ` Ihor Radchenko
2022-12-21 14:03 ` Eli Zaretskii
0 siblings, 1 reply; 26+ messages in thread
From: Ihor Radchenko @ 2022-12-21 13:34 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 59618, arsen, stefankangas, monnier, Richard Hansen
Eli Zaretskii <eliz@gnu.org> writes:
>> Date: Mon, 19 Dec 2022 19:41:31 -0500
>> From: Richard Hansen <rhansen@rhansen.org>
>> Cc: Eli Zaretskii <eliz@gnu.org>, stefankangas@gmail.com,
>> 59618@debbugs.gnu.org, arsen@aarsen.me
>> Attached is a new version of the patch. The only change is that it was rebased onto latest emacs-29 so that it applies cleanly.
>
> Thanks.
>
> Ihor, would you please see if this fixes the problem, so that we could
> install it?
I can no longer reproduce the problem following the given recipe after
applying the patch.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 26+ messages in thread
* bug#59618: [PATCH] bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere"
2022-12-21 13:34 ` Ihor Radchenko
@ 2022-12-21 14:03 ` Eli Zaretskii
0 siblings, 0 replies; 26+ messages in thread
From: Eli Zaretskii @ 2022-12-21 14:03 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: 59618-done, arsen, stefankangas, monnier, rhansen
> From: Ihor Radchenko <yantar92@posteo.net>
> Cc: Richard Hansen <rhansen@rhansen.org>, monnier@iro.umontreal.ca,
> stefankangas@gmail.com, 59618@debbugs.gnu.org, arsen@aarsen.me
> Date: Wed, 21 Dec 2022 13:34:47 +0000
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> > Ihor, would you please see if this fixes the problem, so that we could
> > install it?
>
> I can no longer reproduce the problem following the given recipe after
> applying the patch.
Thanks, so I've now installed the patch, and I'm closing the bug.
^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2022-12-21 14:03 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-26 14:42 bug#59618: 29.0.50; global-whitespace-mode + org-capture: "Marker does not point anywhere" Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-26 19:58 ` Eli Zaretskii
2022-11-26 20:11 ` Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-27 0:27 ` Ihor Radchenko
2022-11-27 6:13 ` Stefan Kangas
2022-11-27 6:20 ` Ihor Radchenko
2022-11-27 6:54 ` Stefan Kangas
2022-12-01 12:06 ` Eli Zaretskii
2022-12-01 15:02 ` Stefan Kangas
2022-12-13 6:25 ` Richard Hansen
2022-12-13 6:34 ` Ihor Radchenko
2022-12-13 6:38 ` Richard Hansen
2022-12-13 6:48 ` Ihor Radchenko
2022-12-14 2:42 ` Richard Hansen
2022-12-14 12:09 ` Eli Zaretskii
2022-12-14 14:15 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-14 15:08 ` Ihor Radchenko
2022-12-14 17:40 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-14 17:48 ` Ihor Radchenko
2022-12-14 20:10 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-18 9:24 ` bug#59618: [PATCH] " Richard Hansen
2022-12-20 0:41 ` bug#59618: [PATCH] " Richard Hansen
2022-12-20 13:52 ` Eli Zaretskii
2022-12-21 13:34 ` Ihor Radchenko
2022-12-21 14:03 ` Eli Zaretskii
2022-11-27 0:28 ` Ihor Radchenko
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.