mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-19 18:13:55 +00:00
* lisp/progmodes/prog-mode.el (prettify-symbols-unprettify-at-point):
Support unprettifying when point is after a symbol. * etc/NEWS: Document `prettify-symbols-unprettify-at-point'
This commit is contained in:
parent
4a6780ea89
commit
cbae4820f9
6
etc/NEWS
6
etc/NEWS
@ -318,13 +318,17 @@ standards.
|
||||
** Prog mode has some support for multi-mode indentation.
|
||||
See `prog-indentation-context' and `prog-widen'.
|
||||
|
||||
** Prettify Symbols mode supports custom composition predicates. By
|
||||
** Prettify Symbols mode
|
||||
*** Prettify Symbols mode supports custom composition predicates. By
|
||||
overriding the default `prettify-symbols-compose-predicate', modes can
|
||||
specify in which contexts a symbol map be composed to some unicode
|
||||
character. `prettify-symbols-default-compose-p' is the default which
|
||||
is suitable for most programming languages such as C or Lisp (but not
|
||||
(La)TeX).
|
||||
|
||||
*** Symbols are not prettified while point is inside them.
|
||||
New variable `prettify-symbols-unprettify-at-point' configures this.
|
||||
|
||||
** New `xterm-screen-extra-capabilities' config.
|
||||
|
||||
** The `save-place' variable is replaced by a `save-place-mode'.
|
||||
|
@ -189,27 +189,42 @@ Regexp match data 0 points to the chars."
|
||||
|
||||
(defvar-local prettify-symbols--current-symbol-bounds nil)
|
||||
|
||||
(defun prettify-symbols--post-command-hook ()
|
||||
(if-let ((c (get-text-property (point) 'composition))
|
||||
(s (get-text-property (point) 'prettify-symbols-start))
|
||||
(e (get-text-property (point) 'prettify-symbols-end)))
|
||||
(with-silent-modifications
|
||||
(setq prettify-symbols--current-symbol-bounds (list s e))
|
||||
(remove-text-properties s e '(composition)))
|
||||
(when (and prettify-symbols--current-symbol-bounds
|
||||
(or (< (point) (car prettify-symbols--current-symbol-bounds))
|
||||
(>= (point) (cadr prettify-symbols--current-symbol-bounds))))
|
||||
(apply #'font-lock-flush prettify-symbols--current-symbol-bounds)
|
||||
(setq prettify-symbols--current-symbol-bounds nil))))
|
||||
|
||||
(defcustom prettify-symbols-unprettify-at-point t
|
||||
"If non-nil, show the non-prettified version of a symbol when point is on it.
|
||||
The prettification will be reapplied as soon as point moves away
|
||||
from the symbol. If set to nil, the prettification persists even
|
||||
when point is on the symbol."
|
||||
:type 'boolean
|
||||
If set to the symbol `right-edge', also unprettify if point
|
||||
is immediately after the symbol. The prettification will be
|
||||
reapplied as soon as point moves away from the symbol. If
|
||||
set to nil, the prettification persists even when point is
|
||||
on the symbol."
|
||||
:type '(choice (const :tag "Never unprettify" nil)
|
||||
(const :tag "Unprettify when point is inside" t)
|
||||
(const :tag "Unprettify when point is inside or at right edge" right-edge))
|
||||
:group 'prog-mode)
|
||||
|
||||
(defun prettify-symbols--post-command-hook ()
|
||||
(cl-labels ((get-prop-as-list
|
||||
(prop)
|
||||
(remove nil
|
||||
(list (get-text-property (point) prop)
|
||||
(when (and (eq prettify-symbols-unprettify-at-point 'right-edge)
|
||||
(not (bobp)))
|
||||
(get-text-property (1- (point)) prop))))))
|
||||
(if-let ((c (get-prop-as-list 'composition))
|
||||
(s (get-prop-as-list 'prettify-symbols-start))
|
||||
(e (get-prop-as-list 'prettify-symbols-end))
|
||||
(s (apply #'min s))
|
||||
(e (apply #'max e)))
|
||||
(with-silent-modifications
|
||||
(setq prettify-symbols--current-symbol-bounds (list s e))
|
||||
(remove-text-properties s e '(composition)))
|
||||
(when (and prettify-symbols--current-symbol-bounds
|
||||
(or (< (point) (car prettify-symbols--current-symbol-bounds))
|
||||
(> (point) (cadr prettify-symbols--current-symbol-bounds))
|
||||
(and (not (eq prettify-symbols-unprettify-at-point 'right-edge))
|
||||
(= (point) (cadr prettify-symbols--current-symbol-bounds)))))
|
||||
(apply #'font-lock-flush prettify-symbols--current-symbol-bounds)
|
||||
(setq prettify-symbols--current-symbol-bounds nil)))))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode prettify-symbols-mode
|
||||
"Toggle Prettify Symbols mode.
|
||||
|
Loading…
Reference in New Issue
Block a user