=== modified file 'lisp/progmodes/perl-mode.el' --- lisp/progmodes/perl-mode.el 2013-05-07 18:06:13 +0000 +++ lisp/progmodes/perl-mode.el 2013-06-01 13:28:52 +0000 @@ -163,39 +163,7 @@ :version "24.4" :type 'boolean) -(defconst perl--prettify-symbols-alist - '(;;("andalso" . ?∧) ("orelse" . ?∨) ("as" . ?≡)("not" . ?¬) - ;;("div" . ?÷) ("*" . ?×) ("o" . ?○) - ("->" . ?→) - ("=>" . ?⇒) - ;;("<-" . ?←) ("<>" . ?≠) (">=" . ?≥) ("<=" . ?≤) ("..." . ?⋯) - ("::" . ?∷) - )) - -(defun perl--font-lock-compose-symbol () - "Compose a sequence of ascii chars into a symbol. -Regexp match data 0 points to the chars." - ;; Check that the chars should really be composed into a symbol. - (let* ((start (match-beginning 0)) - (end (match-end 0)) - (syntaxes (if (eq (char-syntax (char-after start)) ?w) - '(?w) '(?. ?\\)))) - (if (or (memq (char-syntax (or (char-before start) ?\ )) syntaxes) - (memq (char-syntax (or (char-after end) ?\ )) syntaxes) - (nth 8 (syntax-ppss))) - ;; No composition for you. Let's actually remove any composition - ;; we may have added earlier and which is now incorrect. - (remove-text-properties start end '(composition)) - ;; That's a symbol alright, so add the composition. - (compose-region start end (cdr (assoc (match-string 0) - perl--prettify-symbols-alist))))) - ;; Return nil because we're not adding any face property. - nil) - -(defun perl--font-lock-symbols-keywords () - (when perl-prettify-symbols - `((,(regexp-opt (mapcar 'car perl--prettify-symbols-alist) t) - (0 (perl--font-lock-compose-symbol)))))) +(make-obsolete-variable 'perl-prettify-symbols 'prog-prettify-symbols "24.4") (defconst perl-font-lock-keywords-1 '(;; What is this for? @@ -244,7 +212,7 @@ ("\\<\\(continue\\|goto\\|last\\|next\\|redo\\)\\>[ \t]*\\(\\sw+\\)?" (1 font-lock-keyword-face) (2 font-lock-constant-face nil t)) ("^[ \t]*\\(\\sw+\\)[ \t]*:[^:]" 1 font-lock-constant-face) - ,@(perl--font-lock-symbols-keywords))) + ,@(prog--font-lock-symbols-keywords))) "Gaudy level highlighting for Perl mode.") (defvar perl-font-lock-keywords perl-font-lock-keywords-1 === modified file 'lisp/simple.el' --- lisp/simple.el 2013-05-25 02:21:49 +0000 +++ lisp/simple.el 2013-06-01 13:23:00 +0000 @@ -400,6 +400,55 @@ ;; Any programming language is always written left to right. (setq bidi-paragraph-direction 'left-to-right)) +(defconst prog--prettify-symbols-alist-basic + '(("->" . ?→) + ("=>" . ?⇒) + ("::" . ?∷) + ) + "Basic list of symbols to prettify, useful in most languages.") + +(defconst prog--prettify-symbols-alist-extended + (append prog--prettify-symbols-alist-basic + '(("andalso" . ?∧) ("orelse" . ?∨) ("as" . ?≡)("not" . ?¬) + ("div" . ?÷) ("*" . ?×) ("o" . ?○) + ("<-" . ?←) ("<>" . ?≠) (">=" . ?≥) ("<=" . ?≤) ("..." . ?⋯) + )) + "Extended list of symbols to prettify.") + +(defcustom prog-prettify-symbols nil + "Which symbols should be prettified. +Set to an alist in the form `((\"->\" . ?→) ...)'." + :type `(choice + (const :tag "Basic list: -> => ::" ,prog--prettify-symbols-alist-basic) + (const :tag "Extended list: basic plus much more" ,prog--prettify-symbols-alist-extended) + (alist :tag "Define your own list" :key-type string :value-type character)) + :group 'languages) + +(defun prog--font-lock-compose-symbol () + "Compose a sequence of ascii chars into a symbol. +Regexp match data 0 points to the chars." + ;; Check that the chars should really be composed into a symbol. + (let* ((start (match-beginning 0)) + (end (match-end 0)) + (syntaxes (if (eq (char-syntax (char-after start)) ?w) + '(?w) '(?. ?\\)))) + (if (or (memq (char-syntax (or (char-before start) ?\ )) syntaxes) + (memq (char-syntax (or (char-after end) ?\ )) syntaxes) + (nth 8 (syntax-ppss))) + ;; No composition for you. Let's actually remove any composition + ;; we may have added earlier and which is now incorrect. + (remove-text-properties start end '(composition)) + ;; That's a symbol alright, so add the composition. + (compose-region start end (cdr (assoc (match-string 0) + prog--prettify-symbols-alist))))) + ;; Return nil because we're not adding any face property. + nil) + +(defun prog--font-lock-symbols-keywords () + (when prog-prettify-symbols + `((,(regexp-opt (mapcar 'car prog-prettify-symbols) t) + (0 (prog--font-lock-compose-symbol)))))) + ;; Making and deleting lines. (defvar hard-newline (propertize "\n" 'hard t 'rear-nonsticky '(hard))