/[emacs]/emacs/lisp/font-lock.el
ViewVC logotype

Diff of /emacs/lisp/font-lock.el

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

revision 1.276 by rms, Mon Oct 10 03:25:23 2005 UTC revision 1.277 by monnier, Fri Oct 21 06:29:52 2005 UTC
# Line 1184  Optional argument OBJECT is the string o Line 1184  Optional argument OBJECT is the string o
1184    
1185  ;; For completeness: this is to `remove-text-properties' as `put-text-property'  ;; For completeness: this is to `remove-text-properties' as `put-text-property'
1186  ;; is to `add-text-properties', etc.  ;; is to `add-text-properties', etc.
1187  ;(defun remove-text-property (start end property &optional object)  ;;(defun remove-text-property (start end property &optional object)
1188  ;  "Remove a property from text from START to END.  ;;  "Remove a property from text from START to END.
1189  ;Argument PROPERTY is the property to remove.  ;;Argument PROPERTY is the property to remove.
1190  ;Optional argument OBJECT is the string or buffer containing the text.  ;;Optional argument OBJECT is the string or buffer containing the text.
1191  ;Return t if the property was actually removed, nil otherwise."  ;;Return t if the property was actually removed, nil otherwise."
1192  ;  (remove-text-properties start end (list property) object))  ;;  (remove-text-properties start end (list property) object))
1193    
1194  ;; For consistency: maybe this should be called `remove-single-property' like  ;; For consistency: maybe this should be called `remove-single-property' like
1195  ;; `next-single-property-change' (not `next-single-text-property-change'), etc.  ;; `next-single-property-change' (not `next-single-text-property-change'), etc.
1196  ;(defun remove-single-text-property (start end prop value &optional object)  ;;(defun remove-single-text-property (start end prop value &optional object)
1197  ;  "Remove a specific property value from text from START to END.  ;;  "Remove a specific property value from text from START to END.
1198  ;Arguments PROP and VALUE specify the property and value to remove.  The  ;;Arguments PROP and VALUE specify the property and value to remove.  The
1199  ;resulting property values are not equal to VALUE nor lists containing VALUE.  ;;resulting property values are not equal to VALUE nor lists containing VALUE.
1200  ;Optional argument OBJECT is the string or buffer containing the text."  ;;Optional argument OBJECT is the string or buffer containing the text."
1201  ;  (let ((start (text-property-not-all start end prop nil object)) next prev)  ;;  (let ((start (text-property-not-all start end prop nil object)) next prev)
1202  ;    (while start  ;;    (while start
1203  ;      (setq next (next-single-property-change start prop object end)  ;;      (setq next (next-single-property-change start prop object end)
1204  ;           prev (get-text-property start prop object))  ;;          prev (get-text-property start prop object))
1205  ;      (cond ((and (symbolp prev) (eq value prev))  ;;      (cond ((and (symbolp prev) (eq value prev))
1206  ;            (remove-text-property start next prop object))  ;;           (remove-text-property start next prop object))
1207  ;           ((and (listp prev) (memq value prev))  ;;          ((and (listp prev) (memq value prev))
1208  ;            (let ((new (delq value prev)))  ;;           (let ((new (delq value prev)))
1209  ;              (cond ((null new)  ;;             (cond ((null new)
1210  ;                     (remove-text-property start next prop object))  ;;                    (remove-text-property start next prop object))
1211  ;                    ((= (length new) 1)  ;;                   ((= (length new) 1)
1212  ;                     (put-text-property start next prop (car new) object))  ;;                    (put-text-property start next prop (car new) object))
1213  ;                    (t  ;;                   (t
1214  ;                     (put-text-property start next prop new object))))))  ;;                    (put-text-property start next prop new object))))))
1215  ;      (setq start (text-property-not-all next end prop nil object)))))  ;;      (setq start (text-property-not-all next end prop nil object)))))
1216    
1217  ;;; End of Additional text property functions.  ;;; End of Additional text property functions.
1218    
# Line 1534  If REGEXP is non-nil, it means these key Line 1534  If REGEXP is non-nil, it means these key
1534                     (if (memq (get-text-property (match-beginning 0) 'face)                     (if (memq (get-text-property (match-beginning 0) 'face)
1535                               '(font-lock-string-face font-lock-doc-face                               '(font-lock-string-face font-lock-doc-face
1536                                 font-lock-comment-face))                                 font-lock-comment-face))
1537                         font-lock-warning-face)                         (list 'face font-lock-warning-face
1538                                 'help-echo "Looks like a toplevel defun: escape the parenthesis"))
1539                     prepend)))))                     prepend)))))
1540      keywords))      keywords))
1541    
# Line 1602  Sets various variables using `font-lock- Line 1603  Sets various variables using `font-lock-
1603      (let* ((defaults (or font-lock-defaults      (let* ((defaults (or font-lock-defaults
1604                           (cdr (assq major-mode                           (cdr (assq major-mode
1605                                      (with-no-warnings                                      (with-no-warnings
1606                                       font-lock-defaults-alist)))))                                        font-lock-defaults-alist)))))
1607             (keywords             (keywords
1608              (font-lock-choose-keywords (nth 0 defaults)              (font-lock-choose-keywords (nth 0 defaults)
1609                                         (font-lock-value-in-major-mode font-lock-maximum-decoration)))                                         (font-lock-value-in-major-mode font-lock-maximum-decoration)))
# Line 1854  Sets various variables using `font-lock- Line 1855  Sets various variables using `font-lock-
1855  ;; buttons and when they are on or off needs tweaking.  I have assumed that the  ;; buttons and when they are on or off needs tweaking.  I have assumed that the
1856  ;; mechanism is via `menu-toggle' and `menu-selected' symbol properties.  sm.  ;; mechanism is via `menu-toggle' and `menu-selected' symbol properties.  sm.
1857    
1858  ;;;;###autoload  ;;;;;###autoload
1859  ;(progn  ;;(progn
1860  ;  ;; Make the Font Lock menu.  ;;  ;; Make the Font Lock menu.
1861  ;  (defvar font-lock-menu (make-sparse-keymap "Syntax Highlighting"))  ;;  (defvar font-lock-menu (make-sparse-keymap "Syntax Highlighting"))
1862  ;  ;; Add the menu items in reverse order.  ;;  ;; Add the menu items in reverse order.
1863  ;  (define-key font-lock-menu [fontify-less]  ;;  (define-key font-lock-menu [fontify-less]
1864  ;    '("Less In Current Buffer" . font-lock-fontify-less))  ;;    '("Less In Current Buffer" . font-lock-fontify-less))
1865  ;  (define-key font-lock-menu [fontify-more]  ;;  (define-key font-lock-menu [fontify-more]
1866  ;    '("More In Current Buffer" . font-lock-fontify-more))  ;;    '("More In Current Buffer" . font-lock-fontify-more))
1867  ;  (define-key font-lock-menu [font-lock-sep]  ;;  (define-key font-lock-menu [font-lock-sep]
1868  ;    '("--"))  ;;    '("--"))
1869  ;  (define-key font-lock-menu [font-lock-mode]  ;;  (define-key font-lock-menu [font-lock-mode]
1870  ;    '("In Current Buffer" . font-lock-mode))  ;;    '("In Current Buffer" . font-lock-mode))
1871  ;  (define-key font-lock-menu [global-font-lock-mode]  ;;  (define-key font-lock-menu [global-font-lock-mode]
1872  ;    '("In All Buffers" . global-font-lock-mode)))  ;;    '("In All Buffers" . global-font-lock-mode)))
1873  ;  ;;
1874  ;;;;###autoload  ;;;;;###autoload
1875  ;(progn  ;;(progn
1876  ;  ;; We put the appropriate `menu-enable' etc. symbol property values on when  ;;  ;; We put the appropriate `menu-enable' etc. symbol property values on when
1877  ;  ;; font-lock.el is loaded, so we don't need to autoload the three variables.  ;;  ;; font-lock.el is loaded, so we don't need to autoload the three variables.
1878  ;  (put 'global-font-lock-mode 'menu-toggle t)  ;;  (put 'global-font-lock-mode 'menu-toggle t)
1879  ;  (put 'font-lock-mode 'menu-toggle t)  ;;  (put 'font-lock-mode 'menu-toggle t)
1880  ;  (put 'font-lock-fontify-more 'menu-enable '(identity))  ;;  (put 'font-lock-fontify-more 'menu-enable '(identity))
1881  ;  (put 'font-lock-fontify-less 'menu-enable '(identity)))  ;;  (put 'font-lock-fontify-less 'menu-enable '(identity)))
1882  ;  ;;
1883  ; ;; Put the appropriate symbol property values on now.  See above.  ;; ;; Put the appropriate symbol property values on now.  See above.
1884  ;(put 'global-font-lock-mode 'menu-selected 'global-font-lock-mode)  ;;(put 'global-font-lock-mode 'menu-selected 'global-font-lock-mode)
1885  ;(put 'font-lock-mode 'menu-selected 'font-lock-mode)  ;;(put 'font-lock-mode 'menu-selected 'font-lock-mode)
1886  ;(put 'font-lock-fontify-more 'menu-enable '(nth 2 font-lock-fontify-level))  ;;(put 'font-lock-fontify-more 'menu-enable '(nth 2 font-lock-fontify-level))
1887  ;(put 'font-lock-fontify-less 'menu-enable '(nth 1 font-lock-fontify-level))  ;;(put 'font-lock-fontify-less 'menu-enable '(nth 1 font-lock-fontify-level))
1888  ;  ;;
1889  ;(defvar font-lock-fontify-level nil)   ; For less/more fontification.  ;;(defvar font-lock-fontify-level nil)  ; For less/more fontification.
1890  ;  ;;
1891  ;(defun font-lock-fontify-level (level)  ;;(defun font-lock-fontify-level (level)
1892  ;  (let ((font-lock-maximum-decoration level))  ;;  (let ((font-lock-maximum-decoration level))
1893  ;    (when font-lock-mode  ;;    (when font-lock-mode
1894  ;      (font-lock-mode))  ;;      (font-lock-mode))
1895  ;    (font-lock-mode)  ;;    (font-lock-mode)
1896  ;    (when font-lock-verbose  ;;    (when font-lock-verbose
1897  ;      (message "Fontifying %s... level %d" (buffer-name) level))))  ;;      (message "Fontifying %s... level %d" (buffer-name) level))))
1898  ;  ;;
1899  ;(defun font-lock-fontify-less ()  ;;(defun font-lock-fontify-less ()
1900  ;  "Fontify the current buffer with less decoration.  ;;  "Fontify the current buffer with less decoration.
1901  ;See `font-lock-maximum-decoration'."  ;;See `font-lock-maximum-decoration'."
1902  ;  (interactive)  ;;  (interactive)
1903  ;  ;; Check in case we get called interactively.  ;;  ;; Check in case we get called interactively.
1904  ;  (if (nth 1 font-lock-fontify-level)  ;;  (if (nth 1 font-lock-fontify-level)
1905  ;      (font-lock-fontify-level (1- (car font-lock-fontify-level)))  ;;      (font-lock-fontify-level (1- (car font-lock-fontify-level)))
1906  ;    (error "No less decoration")))  ;;    (error "No less decoration")))
1907  ;  ;;
1908  ;(defun font-lock-fontify-more ()  ;;(defun font-lock-fontify-more ()
1909  ;  "Fontify the current buffer with more decoration.  ;;  "Fontify the current buffer with more decoration.
1910  ;See `font-lock-maximum-decoration'."  ;;See `font-lock-maximum-decoration'."
1911  ;  (interactive)  ;;  (interactive)
1912  ;  ;; Check in case we get called interactively.  ;;  ;; Check in case we get called interactively.
1913  ;  (if (nth 2 font-lock-fontify-level)  ;;  (if (nth 2 font-lock-fontify-level)
1914  ;      (font-lock-fontify-level (1+ (car font-lock-fontify-level)))  ;;      (font-lock-fontify-level (1+ (car font-lock-fontify-level)))
1915  ;    (error "No more decoration")))  ;;    (error "No more decoration")))
1916  ;  ;;
1917  ; ;; This should be called by `font-lock-set-defaults'.  ;; ;; This should be called by `font-lock-set-defaults'.
1918  ;(defun font-lock-set-menu ()  ;;(defun font-lock-set-menu ()
1919  ;  ;; Activate less/more fontification entries if there are multiple levels for  ;;  ;; Activate less/more fontification entries if there are multiple levels for
1920  ;  ;; the current buffer.  Sets `font-lock-fontify-level' to be of the form  ;;  ;; the current buffer.  Sets `font-lock-fontify-level' to be of the form
1921  ;  ;; (CURRENT-LEVEL IS-LOWER-LEVEL-P IS-HIGHER-LEVEL-P) for menu activation.  ;;  ;; (CURRENT-LEVEL IS-LOWER-LEVEL-P IS-HIGHER-LEVEL-P) for menu activation.
1922  ;  (let ((keywords (or (nth 0 font-lock-defaults)  ;;  (let ((keywords (or (nth 0 font-lock-defaults)
1923  ;                     (nth 1 (assq major-mode font-lock-defaults-alist))))  ;;                    (nth 1 (assq major-mode font-lock-defaults-alist))))
1924  ;       (level (font-lock-value-in-major-mode font-lock-maximum-decoration)))  ;;      (level (font-lock-value-in-major-mode font-lock-maximum-decoration)))
1925  ;    (make-local-variable 'font-lock-fontify-level)  ;;    (make-local-variable 'font-lock-fontify-level)
1926  ;    (if (or (symbolp keywords) (= (length keywords) 1))  ;;    (if (or (symbolp keywords) (= (length keywords) 1))
1927  ;       (font-lock-unset-menu)  ;;      (font-lock-unset-menu)
1928  ;      (cond ((eq level t)  ;;      (cond ((eq level t)
1929  ;            (setq level (1- (length keywords))))  ;;           (setq level (1- (length keywords))))
1930  ;           ((or (null level) (zerop level))  ;;          ((or (null level) (zerop level))
1931  ;            ;; The default level is usually, but not necessarily, level 1.  ;;           ;; The default level is usually, but not necessarily, level 1.
1932  ;            (setq level (- (length keywords)  ;;           (setq level (- (length keywords)
1933  ;                           (length (member (eval (car keywords))  ;;                          (length (member (eval (car keywords))
1934  ;                                           (mapcar 'eval (cdr keywords))))))))  ;;                                          (mapcar 'eval (cdr keywords))))))))
1935  ;      (setq font-lock-fontify-level (list level (> level 1)  ;;      (setq font-lock-fontify-level (list level (> level 1)
1936  ;                                         (< level (1- (length keywords))))))))  ;;                                        (< level (1- (length keywords))))))))
1937  ;  ;;
1938  ; ;; This should be called by `font-lock-unset-defaults'.  ;; ;; This should be called by `font-lock-unset-defaults'.
1939  ;(defun font-lock-unset-menu ()  ;;(defun font-lock-unset-menu ()
1940  ;  ;; Deactivate less/more fontification entries.  ;;  ;; Deactivate less/more fontification entries.
1941  ;  (setq font-lock-fontify-level nil))  ;;  (setq font-lock-fontify-level nil))
1942    
1943  ;;; End of Menu support.  ;;; End of Menu support.
1944    
1945  ;;; Various regexp information shared by several modes.  ;;; Various regexp information shared by several modes.
1946  ; ;; Information specific to a single mode should go in its load library.  ;; ;; Information specific to a single mode should go in its load library.
1947    
1948  ;; Font Lock support for C, C++, Objective-C and Java modes is now in  ;; Font Lock support for C, C++, Objective-C and Java modes is now in
1949  ;; cc-fonts.el (and required by cc-mode.el).  However, the below function  ;; cc-fonts.el (and required by cc-mode.el).  However, the below function

Legend:
Removed from v.1.276  
changed lines
  Added in v.1.277

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