From: Eli Zaretskii Date: Sat, 12 Dec 2015 11:51:21 +0000 (+0200) Subject: Document new features of Prettify Mode X-Git-Tag: emacs-25.0.90~491 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3e14bdab52d648afb32f7453740de43179a5157c;p=emacs.git Document new features of Prettify Mode * doc/emacs/programs.texi (Misc for Programs): Document 'prettify-symbols-compose-predicate' and 'prettify-symbols-unprettify-at-point'. * lisp/progmodes/prog-mode.el (prettify-symbols-alist) (prettify-symbols-default-compose-p) (prettify-symbols-compose-predicate) (prettify-symbols--compose-symbol): Doc fixes. --- diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index f9d9a27e8e2..bfc991b84c3 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -1498,14 +1498,21 @@ with the Foldout package (@pxref{Foldout}). @findex prettify-symbols-mode Prettify Symbols mode is a buffer-local minor mode that replaces -certain strings with more attractive versions for display -purposes. For example, in Emacs Lisp mode, it replaces the string -@samp{lambda} with the Greek lambda character @samp{λ}. You may wish -to use this -in non-programming modes as well. You can customize the mode by -adding more entries to @code{prettify-symbols-alist}. There is also a -global version, @code{global-prettify-symbols-mode}, which enables the -mode in all buffers that support it. +certain strings with more attractive versions for display purposes. +For example, in Emacs Lisp mode, it replaces the string @samp{lambda} +with the Greek lambda character @samp{λ}. You may wish to use this in +non-programming modes as well. You can customize the mode by adding +more entries to @code{prettify-symbols-alist}. More elaborate +customization is available via customizing +@code{prettify-symbols-compose-predicate} if its default value +@code{prettify-symbols-default-compose-p} is not appropriate. There +is also a global version, @code{global-prettify-symbols-mode}, which +enables the mode in all buffers that support it. + + The symbol at point can be shown in its original form. This is +controlled by the variable @code{prettify-symbols-unprettify-at-point}: +if non-@code{nil}, the original form of symbol at point will be +restored for as long as point is at it. @node C Modes diff --git a/etc/NEWS b/etc/NEWS index 246ee37a848..84a63f8a441 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -335,13 +335,15 @@ provide indentation should use `prog-widen' instead of `widen' and ** 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 +specify in which contexts a symbol may be displayed as 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 can be unprettified while point is inside them. New variable `prettify-symbols-unprettify-at-point' configures this. diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index d05e6369b86..9702880771c 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -136,15 +136,15 @@ Each element looks like (SYMBOL . CHARACTER), where the symbol matching SYMBOL (a string, not a regexp) will be shown as CHARACTER instead. -CHARACTER can be a character or it can be a list or vector, in +CHARACTER can be a character, or it can be a list or vector, in which case it will be used to compose the new symbol as per the third argument of `compose-region'.") (defun prettify-symbols-default-compose-p (start end _match) "Return true iff the symbol MATCH should be composed. The symbol starts at position START and ends at position END. -This is default `prettify-symbols-compose-predicate' which is -suitable for most programming languages such as C or Lisp." +This is the default for `prettify-symbols-compose-predicate' +which is suitable for most programming languages such as C or Lisp." ;; Check that the chars should really be composed into a symbol. (let* ((syntaxes-beg (if (memq (char-syntax (char-after start)) '(?w ?_)) '(?w ?_) '(?. ?\\))) @@ -156,14 +156,14 @@ suitable for most programming languages such as C or Lisp." (defvar-local prettify-symbols-compose-predicate #'prettify-symbols-default-compose-p - "A predicate deciding if the currently matched symbol is to be composed. + "A predicate for deciding if the currently matched symbol is to be composed. The matched symbol is the car of one entry in `prettify-symbols-alist'. -The predicate receives the match's start and end position as well +The predicate receives the match's start and end positions as well as the match-string as arguments.") (defun prettify-symbols--compose-symbol (alist) "Compose a sequence of characters into a symbol. -Regexp match data 0 points to the chars." +Regexp match data 0 specifies the characters to be composed." ;; Check that the chars should really be composed into a symbol. (let ((start (match-beginning 0)) (end (match-end 0))