\f
;; Font Lock mode.
-(eval-when-compile
- ;;
- ;; We use this to preserve or protect things when modifying text properties.
- (defmacro save-buffer-state (&rest body)
- "Bind variables according to VARLIST and eval BODY restoring buffer state."
- (declare (indent 0) (debug t))
- `(let ((inhibit-point-motion-hooks t))
- (with-silent-modifications
- ,@body))))
-
(defvar-local font-lock-set-defaults nil) ; Whether we have set up defaults.
(defun font-lock-specified-p (mode)
(defun font-lock-unfontify-region (beg end)
"Unfontify the text between BEG and END.
This works by calling `font-lock-unfontify-region-function'."
- (save-buffer-state
+ (with-silent-modifications
(funcall font-lock-unfontify-region-function beg end)))
(defvar font-lock-flush-function #'font-lock-after-change-function
"Fontify the text between BEG and END.
If LOUDLY is non-nil, print status messages while fontifying.
This function is the default `font-lock-fontify-region-function'."
- (save-buffer-state
+ (with-silent-modifications
;; Use the fontification syntax table, if any.
(with-syntax-table (or font-lock-syntax-table (syntax-table))
;; Extend the region to fontify so that it starts and ends at
;; Called when any modification is made to buffer text.
(defun font-lock-after-change-function (beg end &optional old-len)
(save-excursion
- (let ((inhibit-point-motion-hooks t)
- (inhibit-quit t)
+ (let ((inhibit-quit t)
(region (if font-lock-extend-after-change-region-function
(funcall font-lock-extend-after-change-region-function
beg end old-len))))
If `font-lock-mark-block-function' non-nil and no ARG is given, it is used to
delimit the region to fontify."
(interactive "P")
- (let ((inhibit-point-motion-hooks t)
- deactivate-mark)
+ (let (deactivate-mark)
;; Make sure we have the right `font-lock-keywords' etc.
(if (not font-lock-mode) (font-lock-set-defaults))
(save-mark-and-excursion
(if (get-text-property (match-beginning 0) 'hfy-quoteme)
(replace-match (hfy-html-quote (match-string 1))) )) ))
-;; Borrowed from font-lock.el
-(defmacro hfy-save-buffer-state (varlist &rest body)
- "Bind variables according to VARLIST and eval BODY restoring buffer state.
-Do not record undo information during evaluation of BODY."
- (declare (indent 1) (debug let))
- (let ((modified (make-symbol "modified")))
- `(let* ,(append varlist
- `((,modified (buffer-modified-p))
- (buffer-undo-list t)
- (inhibit-read-only t)
- (inhibit-point-motion-hooks t)
- (inhibit-modification-hooks t)
- deactivate-mark
- buffer-file-name
- buffer-file-truename))
- (progn
- ,@body)
- (unless ,modified
- (restore-buffer-modified-p nil)))))
-
(defun hfy-mark-trailing-whitespace ()
"Tag trailing whitespace with a hfy property if it is currently highlighted."
(when show-trailing-whitespace
(let ((inhibit-read-only t))
(save-excursion
(goto-char (point-min))
- (hfy-save-buffer-state nil
+ (with-silent-modifications
(while (re-search-forward "[ \t]+$" nil t)
(put-text-property (match-beginning 0) (match-end 0)
'hfy-show-trailing-whitespace t)))))))
(defun hfy-unmark-trailing-whitespace ()
"Undo the effect of `hfy-mark-trailing-whitespace'."
(when show-trailing-whitespace
- (hfy-save-buffer-state nil
+ (with-silent-modifications
(remove-text-properties (point-min) (point-max)
'(hfy-show-trailing-whitespace nil)))))
;;; Code:
-
-(eval-when-compile
- (defmacro with-buffer-prepared-for-jit-lock (&rest body)
- "Execute BODY in current buffer, overriding several variables.
-Preserves the `buffer-modified-p' state of the current buffer."
- (declare (debug t))
- `(let ((inhibit-point-motion-hooks t))
- (with-silent-modifications
- ,@body))))
-\f
;;; Customization.
(defgroup jit-lock nil
(when (buffer-live-p buffer)
(with-current-buffer buffer
;; (message "Jit-Debug %s" (buffer-name))
- (with-buffer-prepared-for-jit-lock
+ (with-silent-modifications
(let ((pos (point-min)))
(while
(progn
(defun jit-lock-refontify (&optional beg end)
"Force refontification of the region BEG..END (default whole buffer)."
- (with-buffer-prepared-for-jit-lock
+ (with-silent-modifications
(save-restriction
(widen)
(put-text-property (or beg (point-min)) (or end (point-max))
(push (current-buffer) jit-lock-defer-buffers))
;; Mark the area as defer-fontified so that the redisplay engine
;; is happy and so that the idle timer can find the places to fontify.
- (with-buffer-prepared-for-jit-lock
+ (with-silent-modifications
(put-text-property start
(next-single-property-change
start 'fontified nil
(defun jit-lock-fontify-now (&optional start end)
"Fontify current buffer from START to END.
Defaults to the whole buffer. END can be out of bounds."
- (with-buffer-prepared-for-jit-lock
+ (with-silent-modifications
(save-excursion
(unless start (setq start (point-min)))
(setq end (if end (min end (point-max)) (point-max)))
This applies to the buffer associated with marker START."
(when (marker-buffer start)
(with-current-buffer (marker-buffer start)
- (with-buffer-prepared-for-jit-lock
+ (with-silent-modifications
(when (> end (point-max))
(setq end (point-max) start (min start end)))
(when (< start (point-min))
(when (buffer-live-p buffer)
(with-current-buffer buffer
;; (message "Jit-Defer %s" (buffer-name))
- (with-buffer-prepared-for-jit-lock
+ (with-silent-modifications
(let ((pos (point-min)))
(while
(progn
jit-lock-context-unfontify-pos
'jit-lock-defer-multiline)
(point-min))))
- (with-buffer-prepared-for-jit-lock
+ (with-silent-modifications
;; Force contextual refontification.
(remove-text-properties
jit-lock-context-unfontify-pos (point-max)
(when (and jit-lock-mode (not memory-full))
(let ((jit-lock-start start)
(jit-lock-end end))
- (with-buffer-prepared-for-jit-lock
+ (with-silent-modifications
(run-hook-with-args 'jit-lock-after-change-extend-region-functions
start end old-len)
;; Make sure we change at least one char (in case of deletions).
(require 'easymenu))
(require 'cc-mode)
-;; More compile-time-macros
-(eval-when-compile
- (defmacro save-buffer-state-x (&rest body) ; similar to EMACS/lazy-lock.el
- (declare (debug t) (indent 0))
- `(let ((inhibit-point-motion-hooks t))
- (with-silent-modifications
- ,@body))))
-
(defvar outline-level)
(defvar imenu-use-markers)
(defvar imenu-create-index-function)
Display a message unless optional argument SILENT is non-nil."
(interactive "p")
- (save-buffer-state-x
+ (with-silent-modifications
(if (> arg 0)
(let ((regexp (if (= arg 1) "[]}]" "}"))
(diff (and antlr-action-visibility
;; Copyright (C) 1994-2022 Free Software Foundation, Inc.
;; Author: Thien-Thi Nguyen <ttn@gnu.org>
-;; Dan Nicolaescu <dann@ics.uci.edu>
+;; Dan Nicolaescu <dann@gnu.org>
;; Keywords: C C++ java lisp tools editing comments blocks hiding outlines
;; Maintainer-Version: 5.65.2.2
;; Time-of-Day-Author-Most-Likely-to-be-Recalcitrant: early morning
;;;###autoload
(defvar hs-special-modes-alist
- (mapcar 'purecopy
+ (mapcar #'purecopy
'((c-mode "{" "}" "/[*/]" nil nil)
(c++-mode "{" "}" "/[*/]" nil nil)
(bibtex-mode ("@\\S(*\\(\\s(\\)" 1))
(defvar hs-minor-mode-map
(let ((map (make-sparse-keymap)))
;; These bindings roughly imitate those used by Outline mode.
- (define-key map "\C-c@\C-h" 'hs-hide-block)
- (define-key map "\C-c@\C-s" 'hs-show-block)
- (define-key map "\C-c@\C-\M-h" 'hs-hide-all)
- (define-key map "\C-c@\C-\M-s" 'hs-show-all)
- (define-key map "\C-c@\C-l" 'hs-hide-level)
- (define-key map "\C-c@\C-c" 'hs-toggle-hiding)
- (define-key map "\C-c@\C-a" 'hs-show-all)
- (define-key map "\C-c@\C-t" 'hs-hide-all)
- (define-key map "\C-c@\C-d" 'hs-hide-block)
- (define-key map "\C-c@\C-e" 'hs-toggle-hiding)
- (define-key map [(shift mouse-2)] 'hs-toggle-hiding)
+ (define-key map "\C-c@\C-h" #'hs-hide-block)
+ (define-key map "\C-c@\C-s" #'hs-show-block)
+ (define-key map "\C-c@\C-\M-h" #'hs-hide-all)
+ (define-key map "\C-c@\C-\M-s" #'hs-show-all)
+ (define-key map "\C-c@\C-l" #'hs-hide-level)
+ (define-key map "\C-c@\C-c" #'hs-toggle-hiding)
+ (define-key map "\C-c@\C-a" #'hs-show-all)
+ (define-key map "\C-c@\C-t" #'hs-hide-all)
+ (define-key map "\C-c@\C-d" #'hs-hide-block)
+ (define-key map "\C-c@\C-e" #'hs-toggle-hiding)
+ (define-key map [(shift mouse-2)] #'hs-toggle-hiding)
map)
"Keymap for hideshow minor mode.")
(defmacro hs-life-goes-on (&rest body)
"Evaluate BODY forms if variable `hs-minor-mode' is non-nil.
-In the dynamic context of this macro, `inhibit-point-motion-hooks'
-and `case-fold-search' are both t."
+In the dynamic context of this macro, `case-fold-search' is t."
(declare (debug t))
`(when hs-minor-mode
- (let ((inhibit-point-motion-hooks t)
- (case-fold-search t))
+ (let ((case-fold-search t))
,@body)))
(defun hs-find-block-beginning-match ()