branch: elpa/logview commit 43f475a56d8824d3f9ed05734e78a43dfb866506 Author: Paul Pogonyshev <pogonys...@gmail.com> Commit: Paul Pogonyshev <pogonys...@gmail.com>
Fix several errors in commit 75c4945. --- logview.el | 35 +++++++++++++++++++---------------- test/logview.el | 6 +++--- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/logview.el b/logview.el index d6c2cd53f1..6edf9735d9 100644 --- a/logview.el +++ b/logview.el @@ -920,22 +920,25 @@ 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)) - (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))) + `(logview--do-temporarily-widening (lambda () ,@body))) + +;; Used so that `(fboundp 'without-restriction)' is not evaluated at compilation time. +(defun logview--do-temporarily-widening (body) + (save-restriction + (if (fboundp 'without-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) + (funcall body))) + (logview--do-widen) + (funcall body)))) (defun logview--do-widen () (widen) diff --git a/test/logview.el b/test/logview.el index 573988df38..b315e640e2 100644 --- a/test/logview.el +++ b/test/logview.el @@ -28,7 +28,8 @@ (defmacro logview--test-with-restriction (start end locking-label &rest body) - (if (boundp 'with-restriction) + (declare (indent 3)) + (if (fboundp 'with-restriction) `(with-restriction ,start ,end :label ,locking-label ,@body) @@ -48,8 +49,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)) - (logview--test-with-restriction 5 8 - :label tag + (logview--test-with-restriction 5 8 tag (should (string= (buffer-string) "bar")) (logview--temporarily-widening (should (string= (buffer-string) "foo bar baz")))))))