From: Ted Zlatanov Date: Wed, 5 Jun 2013 17:48:50 +0000 (-0400) Subject: Introduce and use prog-prettify-install. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2026^2~68 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8fc57765e8baaf917734997b6bd3ca014613ad65;p=emacs.git Introduce and use prog-prettify-install. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 006bb9d9fe6..1338475b8b5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,21 @@ +2013-06-05 Teodor Zlatanov + + * simple.el (prog-prettify-symbols): Add version. + (prog-prettify-install): Add convenience function to prettify symbols. + + * progmodes/perl-mode.el (perl--augmented-font-lock-keywords) + (perl--augmented-font-lock-keywords-1) + (perl--augmented-font-lock-keywords-2, perl-mode): Remove unneeded + variables and use it. + + * progmodes/cfengine.el (cfengine3--augmented-font-lock-keywords) + (cfengine3-mode): Remove unneeded variable and use it. + + * emacs-lisp/lisp-mode.el (lisp--augmented-font-lock-keywords) + (lisp--augmented-font-lock-keywords-1) + (lisp--augmented-font-lock-keywords-2, lisp-mode-variables): + Remove unneeded variables and use it. + 2013-06-05 Teodor Zlatanov * net/tls.el (open-tls-stream): Remove unneeded buffer contents up diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 6e1f8291771..4267b9f45b9 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -187,11 +187,6 @@ It has `lisp-mode-abbrev-table' as its parent." font-lock-string-face)))) font-lock-comment-face)) -;; Temporary variables used to add font-lock keywords dynamically. -(defvar lisp--augmented-font-lock-keywords) -(defvar lisp--augmented-font-lock-keywords-1) -(defvar lisp--augmented-font-lock-keywords-2) - (defun lisp-mode-variables (&optional lisp-syntax keywords-case-insensitive) "Common initialization routine for lisp modes. The LISP-SYNTAX argument is used by code in inf-lisp.el and is @@ -228,20 +223,11 @@ font-lock keywords will not be case sensitive." (setq-local imenu-generic-expression lisp-imenu-generic-expression) (setq-local multibyte-syntax-as-symbol t) (setq-local syntax-begin-function 'beginning-of-defun) - (setq-local prog-prettify-symbols-alist lisp--prettify-symbols-alist) - (setq lisp--augmented-font-lock-keywords - (append lisp-font-lock-keywords - (prog-prettify-font-lock-symbols-keywords))) - (setq lisp--augmented-font-lock-keywords-1 - (append lisp-font-lock-keywords-1 - (prog-prettify-font-lock-symbols-keywords))) - (setq lisp--augmented-font-lock-keywords-2 - (append lisp-font-lock-keywords-2 - (prog-prettify-font-lock-symbols-keywords))) + (prog-prettify-install lisp--prettify-symbols-alist) (setq font-lock-defaults - `((lisp--augmented-font-lock-keywords - lisp--augmented-font-lock-keywords-1 - lisp--augmented-font-lock-keywords-2) + `((lisp-font-lock-keywords + lisp-font-lock-keywords-1 + lisp-font-lock-keywords-2) nil ,keywords-case-insensitive nil nil (font-lock-mark-block-function . mark-defun) (font-lock-syntactic-face-function diff --git a/lisp/progmodes/cfengine.el b/lisp/progmodes/cfengine.el index 88177a8db10..01b5faef5b3 100644 --- a/lisp/progmodes/cfengine.el +++ b/lisp/progmodes/cfengine.el @@ -532,8 +532,6 @@ Intended as the value of `indent-line-function'." ("=>" . ?⇒) ("::" . ?∷))) -(defvar cfengine3--augmented-font-lock-keywords) - ;;;###autoload (define-derived-mode cfengine3-mode prog-mode "CFE3" "Major mode for editing CFEngine3 input. @@ -546,17 +544,10 @@ to the action header." (set (make-local-variable 'indent-line-function) #'cfengine3-indent-line) - ;; Define the symbols to be prettified - (setq-local prog-prettify-symbols-alist cfengine3--prettify-symbols-alist) - - ;; Tell font-lock.el how to handle cfengine3 keywords.. - (setq cfengine3--augmented-font-lock-keywords - (append cfengine3-font-lock-keywords - (prog-prettify-font-lock-symbols-keywords))) - (setq font-lock-defaults - '(cfengine3--augmented-font-lock-keywords + '(cfengine3-font-lock-keywords nil nil nil beginning-of-defun)) + (prog-prettify-install cfengine3--prettify-symbols-alist) ;; Use defuns as the essential syntax block. (set (make-local-variable 'beginning-of-defun-function) diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el index fb3839a5fbc..1d5052bede4 100644 --- a/lisp/progmodes/perl-mode.el +++ b/lisp/progmodes/perl-mode.el @@ -215,11 +215,6 @@ (defvar perl-font-lock-keywords perl-font-lock-keywords-1 "Default expressions to highlight in Perl mode.") -;; Temporary variables used to add font-lock keywords dynamically. -(defvar perl--augmented-font-lock-keywords) -(defvar perl--augmented-font-lock-keywords-1) -(defvar perl--augmented-font-lock-keywords-2) - (defvar perl-quote-like-pairs '((?\( . ?\)) (?\[ . ?\]) (?\{ . ?\}) (?\< . ?\>))) @@ -656,26 +651,14 @@ Turning on Perl mode runs the normal hook `perl-mode-hook'." (setq-local comment-indent-function #'perl-comment-indent) (setq-local parse-sexp-ignore-comments t) - ;; Define the symbols to be prettified. - (setq-local prog-prettify-symbols-alist perl--prettify-symbols-alist) - ;; Tell font-lock.el how to handle Perl. - (setq perl--augmented-font-lock-keywords - (append perl-font-lock-keywords - (prog-prettify-font-lock-symbols-keywords))) - (setq perl--augmented-font-lock-keywords-1 - (append perl-font-lock-keywords-1 - (prog-prettify-font-lock-symbols-keywords))) - (setq perl--augmented-font-lock-keywords-2 - (append perl-font-lock-keywords-2 - (prog-prettify-font-lock-symbols-keywords))) - - (setq font-lock-defaults '((perl--augmented-font-lock-keywords - perl--augmented-font-lock-keywords-1 - perl--augmented-font-lock-keywords-2) + (setq font-lock-defaults '((perl-font-lock-keywords + perl-font-lock-keywords-1 + perl-font-lock-keywords-2) nil nil ((?\_ . "w")) nil (font-lock-syntactic-face-function . perl-font-lock-syntactic-face-function))) + (prog-prettify-install perl--prettify-symbols-alist) (setq-local syntax-propertize-function #'perl-syntax-propertize-function) (add-hook 'syntax-propertize-extend-region-functions #'syntax-propertize-multiline 'append 'local) diff --git a/lisp/simple.el b/lisp/simple.el index 2564645e42c..e173a32878f 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -412,6 +412,7 @@ augment the mode's native prettify alist." (const :tag "Mode defaults" t) (alist :tag "Mode defaults augmented with your own list" :key-type string :value-type character)) + :version "24.4" :group 'languages) (defun prog--prettify-font-lock-compose-symbol (alist) @@ -442,6 +443,10 @@ Regexp match data 0 points to the chars." `((,(regexp-opt (mapcar 'car alist) t) (0 (prog--prettify-font-lock-compose-symbol ',alist))))))) +(defun prog-prettify-install (alist) + (setq-local prog-prettify-symbols-alist alist) + (font-lock-add-keywords nil (prog-prettify-font-lock-symbols-keywords))) + ;; Making and deleting lines. (defvar hard-newline (propertize "\n" 'hard t 'rear-nonsticky '(hard))