Skip to content

Commit

Permalink
Add checks for Emacs 29 forgotten in commit 75c4945 before using new …
Browse files Browse the repository at this point in the history
…macros.
  • Loading branch information
doublep committed Mar 27, 2024
1 parent 12a33e0 commit 1d1524f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
28 changes: 16 additions & 12 deletions logview.el
Original file line number Diff line number Diff line change
Expand Up @@ -920,18 +920,22 @@ Original point restrictions, if any, will not be possible to find
inside BODY. In most cases (also if not sure) you should use
macro `logview--std-temporarily-widening' instead."
(declare (indent 0) (debug t))
`(save-restriction
;; {LOCKED-NARROWING}
;; "Hurr-durr, mah security, you cannot unlock without knowing the tag." Try all
;; tags I could find in Emacs source code. Normally this should be enough, but there
;; is obviously no guarantee as macro `with-restriction' is part of public Elisp
;; interface now.
(without-restriction
:label 'long-line-optimizations-in-fontification-functions
(without-restriction
:label 'long-line-optimizations-in-command-hooks
(logview--do-widen)
,@body))))
(if (boundp 'without-restriction)
`(save-restriction
;; {LOCKED-NARROWING}
;; "Hurr-durr, mah security, you cannot unlock without knowing the tag." Try all
;; tags I could find in Emacs source code. Normally this should be enough, but
;; there is obviously no guarantee as macro `with-restriction' is part of public
;; Elisp interface now.
(without-restriction
:label 'long-line-optimizations-in-fontification-functions
(without-restriction
:label 'long-line-optimizations-in-command-hooks
(logview--do-widen)
,@body)))
`(save-restriction
(logview--do-widen)
,@body)))

(defun logview--do-widen ()
(widen)
Expand Down
11 changes: 10 additions & 1 deletion test/logview.el
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
(defvar inhibit-message)


(defmacro logview--test-with-restriction (start end locking-label &rest body)
(if (boundp 'with-restriction)
`(with-restriction ,start ,end
:label ,locking-label
,@body)
`(progn (narrow-to-region ,start ,end)
,@body)))


(ert-deftest logview--temporarily-widening ()
(with-temp-buffer
(insert "foo bar baz")
Expand All @@ -39,7 +48,7 @@
;; Testing without emulation, with real Emacs-imposed locking seems unfeasible, since
;; relevant font-locking code is not activated in batch mode.
(dolist (tag '(long-line-optimizations-in-fontification-functions long-line-optimizations-in-command-hooks))
(with-restriction 5 8
(logview--test-with-restriction 5 8
:label tag
(should (string= (buffer-string) "bar"))
(logview--temporarily-widening
Expand Down

0 comments on commit 1d1524f

Please sign in to comment.