Commit 8fc57765 authored by Ted Zlatanov's avatar Ted Zlatanov
Browse files

Introduce and use prog-prettify-install.

parent f019a684
2013-06-05 Teodor Zlatanov <tzz@lifelogs.com>
* 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 <tzz@lifelogs.com>
 
* net/tls.el (open-tls-stream): Remove unneeded buffer contents up
......@@ -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
......
......@@ -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)
......
......@@ -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)
......
......@@ -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))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment