summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew Adams <drew.adams@oracle.com>2023-10-18 11:03:42 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2023-10-18 11:03:42 -0400
commitf7e1b641ee8360ddb8bae1711d3978863efa692d (patch)
treea7951a82273973fdcaf71b143ef0884e761b42c0
parent10ebf386d48725fa3af2f8b0c60ad4ffa0ec9653 (diff)
zones.el: Fix oversight in last commitexternals/zones
Forgot to replace all uses of `case` with `cl-case`. Done now. Also, use cl-lib if available regardless of Emacs version. (zz--fringe-remapping): Move declaration to top level to avoid warning about make-variable-buffer-local.
-rw-r--r--zones.el68
1 files changed, 37 insertions, 31 deletions
diff --git a/zones.el b/zones.el
index fb5e156..56c7b24 100644
--- a/zones.el
+++ b/zones.el
@@ -9,9 +9,9 @@
;; Created: Sun Apr 18 12:58:07 2010 (-0700)
;; Version: 2023.06.11
;; Package-Requires: ()
-;; Last-Updated: Tue Oct 17 16:10:36 2023 (-0700)
+;; Last-Updated: Tue Oct 17 22:03:43 2023 (-0700)
;; By: dradams
-;; Update #: 3328
+;; Update #: 3348
;; URL: https://elpa.gnu.org/packages/zones.html
;; URL: https://www.emacswiki.org/emacs/download/zones.el
;; Doc URL: https://www.emacswiki.org/emacs/Zones
@@ -105,7 +105,7 @@
;;
;; Faces defined here:
;;
-;; `zz-fringe-for-narrowing'.
+;; `zz-fringe-for-narrowing' (Emacs 23+).
;;
;; Non-interactive functions defined here:
;;
@@ -132,8 +132,9 @@
;; `zz-remove-empty-izones', `zz-remove-if', `zz-remove-if-not',
;; `zz-remove-izones-w-other-buffer-markers',
;; `zz-remove-zones-w-other-buffer-markers', `zz-repeat-command',
-;; `zz-same-position-p', `zz-set-intersection', `zz-set-union',
-;; `zz-some', `zz-string-match-p', `zz-two-zone-intersection',
+;; `zz-same-position-p', `zz-set-fringe-for-narrowing' (Emacs 23+),
+;; `zz-set-intersection', `zz-set-union', `zz-some',
+;; `zz-string-match-p', `zz-two-zone-intersection',
;; `zz-two-zone-union', `zz-zone-abstract-function-default',
;; `zz-zone-buffer-name', `zz-zone-has-other-buffer-marker-p',
;; `zz-zone-intersection', `zz-zone-intersection-1',
@@ -602,10 +603,11 @@
;;
;;(@* "Change Log")
;;
-;; 2023/09/27 dadams
+;; 2023/10/17 dadams
;; Require cl-lib when available, else defalias cl-case to case.
;; Added declare-function to quiet byte compiler.
;; zz-set-fringe-for-narrowing: Provide required arg for redraw-frame (Emacs 22+).
+;; Moved zz--fringe-remapping to top level to avoid warning about make-variable-buffer-local.
;; 2023/06/11 dadams
;; Advise widen, to update mode-line lighter.
;; zz-narrow-advice: update mode-line lighter.
@@ -969,10 +971,9 @@
;;
;;; Code:
-(eval-when-compile (if (>= emacs-major-version 24)
- (require 'cl-lib)
- (require 'cl)
- (defalias 'cl-case 'case)))
+(eval-when-compile (unless (require 'cl-lib nil t)
+ (require 'cl)
+ (defalias 'cl-case 'case)))
;; Quiet the byte-compiler for Emacs 22..
@@ -987,7 +988,6 @@
(declare-function use-region-p "simple" ())
(declare-function zz-set-fringe-for-narrowing "zones" ())
-
(defvar hlt-last-face) ; In `highlight.el'
(defvar isearchp-dim-outside-search-area-flag) ; In `isearch+.el'
(defvar narrow-map) ; Emacs 23+
@@ -1077,8 +1077,14 @@ The zone corresponds to the new buffer restriction.
`zz-add-zone-anyway-p' to a non-nil value)."
:type 'boolean :group 'zones)
+
+;; Used only for Emacs 23+, but put it at top level to avoid warning about `make-variable-buffer-local'.
+(defvar zz--fringe-remapping nil
+ "Cookie from remapping face `fringe' to `zz-fringe-for-narrowing'.
+Deleted by `face-remap-remove-relative' when buffer is widened.")
+(make-variable-buffer-local 'zz--fringe-remapping)
+
(when (>= emacs-major-version 23) ; Emacs 23.1+
- ;; NOTE: Buffer-local face-remapping of fringe is not handled correctly until Emacs-27 (Emacs bug#33244).
(defface zz-fringe-for-narrowing
'((((background dark)) (:background "#FFFF2429FC15")) ; a dark magenta
@@ -1086,21 +1092,8 @@ The zone corresponds to the new buffer restriction.
"Face used for fringe when buffer is narrowed."
:group 'zones :group 'faces)
- ;; FIXME?: This is really orthogonal to zones.
- (defcustom zz-narrowing-use-fringe-flag nil
- "Non-nil means use fringe face `zz-fringe-for-narrowing' when narrowed."
- :type 'boolean :group 'zones
- :set (lambda (sym defs)
- (custom-set-default sym defs)
- (if (symbol-value sym)
- (add-hook 'post-command-hook #'zz-set-fringe-for-narrowing)
- (remove-hook 'post-command-hook #'zz-set-fringe-for-narrowing))))
-
- (defvar zz--fringe-remapping nil
- "Cookie from remapping face `fringe' to `zz-fringe-for-narrowing'.
-Deleted by `face-remap-remove-relative' when buffer is widened.")
- (with-no-warnings (make-variable-buffer-local 'zz--fringe-remapping))
-
+ ;; NOTE: Buffer-local face-remapping of fringe is not handled correctly until Emacs-27 (Emacs bug#33244).
+ ;;
(defun zz-set-fringe-for-narrowing ()
"Remap face `fringe' to `zz-fringe-for-narrowing' if buffer is narrowed.
Remove remapping if not narrowed."
@@ -1115,6 +1108,19 @@ Remove remapping if not narrowed."
(redraw-frame (selected-frame))
(setq zz--fringe-remapping nil))))
+ ;; FIXME?: This is really orthogonal to zones.
+ ;;
+ (defcustom zz-narrowing-use-fringe-flag nil
+ "Non-nil means use fringe face `zz-fringe-for-narrowing' when narrowed.
+This option has no effect for Emacs releases prior to Emacs 23."
+ :type 'boolean :group 'zones
+ :set (lambda (sym defs)
+ (custom-set-default sym defs)
+ (when (fboundp 'zz-set-fringe-for-narrowing) ; Emacs 23+
+ (if (symbol-value sym)
+ (add-hook 'post-command-hook #'zz-set-fringe-for-narrowing)
+ (remove-hook 'post-command-hook #'zz-set-fringe-for-narrowing)))))
+
)
(defvar zz-lighter-narrowing-part ""
@@ -1718,7 +1724,7 @@ arg, and the parameters when called from Lisp."
(substitute-command-keys
"; `\\[isearchp-remove-dimming]' or \
`\\[isearchp-toggle-dimming-outside-search-area]' removes dimming"))))
- (case num-hits
+ (cl-case num-hits
(1 (message "1 zone added%s" dim-msg))
(t (message "%d zones added or updated%s" num-hits dim-msg)))))
variable))
@@ -1786,7 +1792,7 @@ When called from Lisp:
(setq start (car start-end)
end (cadr start-end))))
(unless face (setq face hlt-last-face))
- (let ((hlt-use-overlays-flag (case overlay/text
+ (let ((hlt-use-overlays-flag (cl-case overlay/text
(text-prop nil) ; Only text property
(overlay 'only) ; Only overlay
(t t))) ; Default: both
@@ -1819,7 +1825,7 @@ When called from Lisp:
(zz-add-zone zone-beg zone-end)
(setq count (1+ count)))))))
(when msgp
- (case count
+ (cl-case count
(0 (message "NO zones added or updated"))
(1 (message "1 zone added or updated"))
(t (message "%s highlighted areas added or updated as zones" count))))))
@@ -2820,7 +2826,7 @@ Optional arg POS-TYPE controls the kind of position used by the zone:
(let* ((beg (overlay-start overlay))
(end (overlay-end overlay))
(props `(:zz-overlay ,@(overlay-properties overlay))))
- (case pos-type
+ (cl-case pos-type
(markers (setq beg (copy-marker beg)
end (copy-marker end)))
(readable-markers (setq beg (zz-readable-marker beg buf)