/[auctex]/auctex/font-latex.el
ViewVC logotype

Diff of /auctex/font-latex.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 5.121 by angeli, Sun Jun 5 13:59:10 2005 UTC revision 5.122 by angeli, Sun Jun 5 14:05:11 2005 UTC
# Line 347  macros of the form \"\\foo[bar]{baz}\", Line 347  macros of the form \"\\foo[bar]{baz}\",
347  list but puts a conditional into the keyword highlighter which  list but puts a conditional into the keyword highlighter which
348  tests for `font-latex-fontify-sectioning'.")  tests for `font-latex-fontify-sectioning'.")
349    
350    (defcustom font-latex-deactivated-keyword-classes nil
351      "List of strings for built-in keyword classes to be deactivated.
352    
353    Valid entries are \"warning\", \"variable\", \"reference\",
354    \"function\" , \"sectioning-0\", \"sectioning-1\", \"sectioning-2\",
355    \"sectioning-3\", \"sectioning-4\", \"sectioning-5\", \"textual\",
356    \"bold-command\", \"italic-command\", \"math-command\", \"type-command\",
357    \"bold-declaration\", \"italic-declaration\", \"type-declaration\".
358    
359    You have to restart Emacs for a change of this variable to take effect."
360      :group 'font-latex-keywords
361      :type `(set ,@(mapcar
362                     (lambda (spec)
363                       `(const :tag ,(concat
364                                      ;; Name of the keyword class
365                                      (let ((name (split-string (car spec) "-")))
366                                        (setcar name (capitalize (car name)))
367                                        (mapconcat 'identity name " "))
368                                      " keywords in `"
369                                      ;; Name of the face
370                                      (symbol-name (nth 2 spec)) "'.\n"
371                                      ;; List of keywords
372                                      (with-temp-buffer
373                                        (insert "  Keywords: "
374                                                ;; Better idea than `s-q-a' for
375                                                ;; preserving "\\" and "\\*"?
376                                                (mapconcat 'shell-quote-argument
377                                                           (nth 1 spec) ", "))
378                                        (fill-paragraph nil)
379                                        (buffer-substring-no-properties
380                                         (point-min) (point-max))))
381                               ,(car spec)))
382                     font-latex-built-in-keyword-classes)))
383    
384  (defun font-latex-make-match-defun (prefix name type)  (defun font-latex-make-match-defun (prefix name type)
385    "Return a function definition for keyword matching.    "Return a function definition for keyword matching.
386  The variable holding the keywords to match are determined by the  The variable holding the keywords to match are determined by the
# Line 419  use." Line 453  use."
453    
454  (defun font-latex-make-built-in-keywords ()  (defun font-latex-make-built-in-keywords ()
455    "Build defuns, defvars and defcustoms for built-in keyword fontification."    "Build defuns, defvars and defcustoms for built-in keyword fontification."
456    (let ((keyword-specs font-latex-built-in-keyword-classes))    (dolist (item font-latex-built-in-keyword-classes)
457      (dolist (item keyword-specs)      (let ((prefix "font-latex-match-")
458        (let ((prefix "font-latex-match-")            (name (nth 0 item))
459              (name (nth 0 item))            (keywords (nth 1 item))
460              (keywords (nth 1 item))            (face (nth 2 item))
461              (face (nth 2 item))            (level (nth 3 item))
462              (level (nth 3 item))            (type (nth 4 item)))
463              (type (nth 4 item)))  
464          ;; defvar font-latex-match-*-keywords-local
465          ;; defvar font-latex-match-*-keywords-local        (eval `(defvar ,(intern (concat prefix name "-keywords-local"))
466          (eval `(defvar ,(intern (concat prefix name "-keywords-local"))                 ',keywords
467                   ',keywords                 ,(concat "Buffer-local keywords to add to `"
468                   ,(concat "Buffer-local keywords to add to `"                          prefix name "-keywords'.
                           prefix name "-keywords'.  
469  This must be a list of keyword strings \(not regular expressions\) omitting  This must be a list of keyword strings \(not regular expressions\) omitting
470  the leading backslash.  It will get transformed into a regexp using  the leading backslash.  It will get transformed into a regexp using
471  `" prefix name "-make'.  This variable is not for end users; they  `" prefix name "-make'.  This variable is not for end users; they
# Line 445  fontification regexp like so: Line 478  fontification regexp like so:
478   (" prefix name "-make)   (" prefix name "-make)
479    
480  Generated by `font-latex-make-built-in-keywords'.")))  Generated by `font-latex-make-built-in-keywords'.")))
481          (eval `(make-variable-buffer-local        (eval `(make-variable-buffer-local
482                  ',(intern (concat prefix name "-keywords-local"))))                ',(intern (concat prefix name "-keywords-local"))))
483    
484          ;; defun font-latex-match-*-make        ;; defun font-latex-match-*-make
485          ;; Note: The functions are byte-compiled at the end of font-latex.el.        ;; Note: The functions are byte-compiled at the end of font-latex.el.
486          (eval `(defun ,(intern (concat prefix name "-make")) ()        (eval `(defun ,(intern (concat prefix name "-make")) ()
487                   ,(concat "Make or remake the variable `" prefix name "'.                 ,(concat "Make or remake the variable `" prefix name "'.
488    
489  Generated by `font-latex-make-built-in-keywords'.")  Generated by `font-latex-make-built-in-keywords'.")
490                   (let ((keywords                 (let ((keywords
491                          (append                        (append
492                           ,(intern (concat prefix name "-keywords-local"))                         (unless (member ,name
493                           ,(intern (concat prefix name "-keywords"))))                                         font-latex-deactivated-keyword-classes)
494                         multi-char-macros single-char-macros)                           ,(intern (concat prefix name "-keywords-local")))
495                     (dolist (elt keywords)                         ,(intern (concat prefix name "-keywords"))))
496                       (if (string-match "^[A-Za-z]" elt)                       multi-char-macros single-char-macros)
497                           (add-to-list 'multi-char-macros elt)                   (dolist (elt keywords)
498                         (add-to-list 'single-char-macros elt)))                     (if (string-match "^[A-Za-z]" elt)
499                           (add-to-list 'multi-char-macros elt)
500                         (add-to-list 'single-char-macros elt)))
501                   (setq ,(intern (concat prefix name))                   (setq ,(intern (concat prefix name))
502                         (concat                         (concat
503                          "\\\\\\("                          "\\\\\\("
# Line 475  Generated by `font-latex-make-built-in-k Line 510  Generated by `font-latex-make-built-in-k
510                             "\\(?:" (regexp-opt single-char-macros) "\\)"))                             "\\(?:" (regexp-opt single-char-macros) "\\)"))
511                          "\\)")))))                          "\\)")))))
512    
513          ;; defcustom font-latex-match-*-keywords        ;; defcustom font-latex-match-*-keywords
514          (eval `(defcustom ,(intern (concat prefix name "-keywords")) nil        (eval `(defcustom ,(intern (concat prefix name "-keywords")) nil
515                   ,(concat "List of keyword strings for " name " face.                 ,(concat "List of keyword strings for " name " face.
516  Each string has to be the name of a macro omitting the leading backslash.  Each string has to be the name of a macro omitting the leading backslash.
517    
518  Setting this variable directly does not take effect;  Setting this variable directly does not take effect;
519  restart Emacs.  restart Emacs.
520    
521  Generated by `font-latex-make-built-in-keywords'.")  Generated by `font-latex-make-built-in-keywords'.")
522                   :type '(repeat (string :tag "Keyword"))                 :type '(repeat (string :tag "Keyword"))
523                   :set (lambda (symbol value)                 :set (lambda (symbol value)
524                          (set-default symbol value)                        (set-default symbol value)
525                          (funcall ',(intern (concat prefix name "-make"))))                        (funcall ',(intern (concat prefix name "-make"))))
526                   :group 'font-latex-keywords))                 :group 'font-latex-keywords))
527    
528          ;; defvar font-latex-match-*        ;; defvar font-latex-match-*
529          (eval `(defvar ,(intern (concat prefix name))        (eval `(defvar ,(intern (concat prefix name))
530                   ,(intern (concat prefix name "-keywords"))))                 ,(intern (concat prefix name "-keywords"))))
531          (eval `(make-variable-buffer-local        (eval `(make-variable-buffer-local
532                  ',(intern (concat prefix name))))                ',(intern (concat prefix name))))
533    
534          ;; defun font-latex-match-*        ;; defun font-latex-match-*
535          (font-latex-make-match-defun prefix name type)        (font-latex-make-match-defun prefix name type)
536    
537          ;; Add matchers and highlighters to `font-latex-keywords-{1,2}'.        ;; Add matchers and highlighters to `font-latex-keywords-{1,2}'.
538          (let ((keywords-entry (font-latex-keyword-matcher prefix name face        (let ((keywords-entry (font-latex-keyword-matcher
539                                 (if (listp type) (car type) type))))                               prefix name face
540            (add-to-list (intern (concat "font-latex-keywords-"                               (if (listp type) (car type) type))))
541                                         (number-to-string level)))          (add-to-list (intern (concat "font-latex-keywords-"
542                         keywords-entry t)                                       (number-to-string level)))
543            (when (= level 1)                       keywords-entry t)
544              (add-to-list (intern (concat "font-latex-keywords-2"))          (when (= level 1)
545                           keywords-entry t)))))))            (add-to-list (intern (concat "font-latex-keywords-2"))
546                           keywords-entry t))))))
547  (font-latex-make-built-in-keywords)  (font-latex-make-built-in-keywords)
548    
549  (defcustom font-latex-user-keyword-classes nil  (defcustom font-latex-user-keyword-classes nil

Legend:
Removed from v.5.121  
changed lines
  Added in v.5.122

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26