| 1195 | | ;(defun remove-single-text-property (start end prop value &optional object) |
|---|
| 1196 | | ; "Remove a specific property value from text from START to END. |
|---|
| 1197 | | ;Arguments PROP and VALUE specify the property and value to remove. The |
|---|
| 1198 | | ;resulting property values are not equal to VALUE nor lists containing VALUE. |
|---|
| 1199 | | ;Optional argument OBJECT is the string or buffer containing the text." |
|---|
| 1200 | | ; (let ((start (text-property-not-all start end prop nil object)) next prev) |
|---|
| 1201 | | ; (while start |
|---|
| 1202 | | ; (setq next (next-single-property-change start prop object end) |
|---|
| 1203 | | ; prev (get-text-property start prop object)) |
|---|
| 1204 | | ; (cond ((and (symbolp prev) (eq value prev)) |
|---|
| 1205 | | ; (remove-text-property start next prop object)) |
|---|
| 1206 | | ; ((and (listp prev) (memq value prev)) |
|---|
| 1207 | | ; (let ((new (delq value prev))) |
|---|
| 1208 | | ; (cond ((null new) |
|---|
| 1209 | | ; (remove-text-property start next prop object)) |
|---|
| 1210 | | ; ((= (length new) 1) |
|---|
| 1211 | | ; (put-text-property start next prop (car new) object)) |
|---|
| 1212 | | ; (t |
|---|
| 1213 | | ; (put-text-property start next prop new object)))))) |
|---|
| 1214 | | ; (setq start (text-property-not-all next end prop nil object))))) |
|---|
| | 1189 | ;;(defun remove-single-text-property (start end prop value &optional object) |
|---|
| | 1190 | ;; "Remove a specific property value from text from START to END. |
|---|
| | 1191 | ;;Arguments PROP and VALUE specify the property and value to remove. The |
|---|
| | 1192 | ;;resulting property values are not equal to VALUE nor lists containing VALUE. |
|---|
| | 1193 | ;;Optional argument OBJECT is the string or buffer containing the text." |
|---|
| | 1194 | ;; (let ((start (text-property-not-all start end prop nil object)) next prev) |
|---|
| | 1195 | ;; (while start |
|---|
| | 1196 | ;; (setq next (next-single-property-change start prop object end) |
|---|
| | 1197 | ;; prev (get-text-property start prop object)) |
|---|
| | 1198 | ;; (cond ((and (symbolp prev) (eq value prev)) |
|---|
| | 1199 | ;; (remove-text-property start next prop object)) |
|---|
| | 1200 | ;; ((and (listp prev) (memq value prev)) |
|---|
| | 1201 | ;; (let ((new (delq value prev))) |
|---|
| | 1202 | ;; (cond ((null new) |
|---|
| | 1203 | ;; (remove-text-property start next prop object)) |
|---|
| | 1204 | ;; ((= (length new) 1) |
|---|
| | 1205 | ;; (put-text-property start next prop (car new) object)) |
|---|
| | 1206 | ;; (t |
|---|
| | 1207 | ;; (put-text-property start next prop new object)))))) |
|---|
| | 1208 | ;; (setq start (text-property-not-all next end prop nil object))))) |
|---|
| 1856 | | ;;;;###autoload |
|---|
| 1857 | | ;(progn |
|---|
| 1858 | | ; ;; Make the Font Lock menu. |
|---|
| 1859 | | ; (defvar font-lock-menu (make-sparse-keymap "Syntax Highlighting")) |
|---|
| 1860 | | ; ;; Add the menu items in reverse order. |
|---|
| 1861 | | ; (define-key font-lock-menu [fontify-less] |
|---|
| 1862 | | ; '("Less In Current Buffer" . font-lock-fontify-less)) |
|---|
| 1863 | | ; (define-key font-lock-menu [fontify-more] |
|---|
| 1864 | | ; '("More In Current Buffer" . font-lock-fontify-more)) |
|---|
| 1865 | | ; (define-key font-lock-menu [font-lock-sep] |
|---|
| 1866 | | ; '("--")) |
|---|
| 1867 | | ; (define-key font-lock-menu [font-lock-mode] |
|---|
| 1868 | | ; '("In Current Buffer" . font-lock-mode)) |
|---|
| 1869 | | ; (define-key font-lock-menu [global-font-lock-mode] |
|---|
| 1870 | | ; '("In All Buffers" . global-font-lock-mode))) |
|---|
| 1871 | | ; |
|---|
| 1872 | | ;;;;###autoload |
|---|
| 1873 | | ;(progn |
|---|
| 1874 | | ; ;; We put the appropriate `menu-enable' etc. symbol property values on when |
|---|
| 1875 | | ; ;; font-lock.el is loaded, so we don't need to autoload the three variables. |
|---|
| 1876 | | ; (put 'global-font-lock-mode 'menu-toggle t) |
|---|
| 1877 | | ; (put 'font-lock-mode 'menu-toggle t) |
|---|
| 1878 | | ; (put 'font-lock-fontify-more 'menu-enable '(identity)) |
|---|
| 1879 | | ; (put 'font-lock-fontify-less 'menu-enable '(identity))) |
|---|
| 1880 | | ; |
|---|
| 1881 | | ; ;; Put the appropriate symbol property values on now. See above. |
|---|
| 1882 | | ;(put 'global-font-lock-mode 'menu-selected 'global-font-lock-mode) |
|---|
| 1883 | | ;(put 'font-lock-mode 'menu-selected 'font-lock-mode) |
|---|
| 1884 | | ;(put 'font-lock-fontify-more 'menu-enable '(nth 2 font-lock-fontify-level)) |
|---|
| 1885 | | ;(put 'font-lock-fontify-less 'menu-enable '(nth 1 font-lock-fontify-level)) |
|---|
| 1886 | | ; |
|---|
| 1887 | | ;(defvar font-lock-fontify-level nil) ; For less/more fontification. |
|---|
| 1888 | | ; |
|---|
| 1889 | | ;(defun font-lock-fontify-level (level) |
|---|
| 1890 | | ; (let ((font-lock-maximum-decoration level)) |
|---|
| 1891 | | ; (when font-lock-mode |
|---|
| 1892 | | ; (font-lock-mode)) |
|---|
| 1893 | | ; (font-lock-mode) |
|---|
| 1894 | | ; (when font-lock-verbose |
|---|
| 1895 | | ; (message "Fontifying %s... level %d" (buffer-name) level)))) |
|---|
| 1896 | | ; |
|---|
| 1897 | | ;(defun font-lock-fontify-less () |
|---|
| 1898 | | ; "Fontify the current buffer with less decoration. |
|---|
| 1899 | | ;See `font-lock-maximum-decoration'." |
|---|
| 1900 | | ; (interactive) |
|---|
| 1901 | | ; ;; Check in case we get called interactively. |
|---|
| 1902 | | ; (if (nth 1 font-lock-fontify-level) |
|---|
| 1903 | | ; (font-lock-fontify-level (1- (car font-lock-fontify-level))) |
|---|
| 1904 | | ; (error "No less decoration"))) |
|---|
| 1905 | | ; |
|---|
| 1906 | | ;(defun font-lock-fontify-more () |
|---|
| 1907 | | ; "Fontify the current buffer with more decoration. |
|---|
| 1908 | | ;See `font-lock-maximum-decoration'." |
|---|
| 1909 | | ; (interactive) |
|---|
| 1910 | | ; ;; Check in case we get called interactively. |
|---|
| 1911 | | ; (if (nth 2 font-lock-fontify-level) |
|---|
| 1912 | | ; (font-lock-fontify-level (1+ (car font-lock-fontify-level))) |
|---|
| 1913 | | ; (error "No more decoration"))) |
|---|
| 1914 | | ; |
|---|
| 1915 | | ; ;; This should be called by `font-lock-set-defaults'. |
|---|
| 1916 | | ;(defun font-lock-set-menu () |
|---|
| 1917 | | ; ;; Activate less/more fontification entries if there are multiple levels for |
|---|
| 1918 | | ; ;; the current buffer. Sets `font-lock-fontify-level' to be of the form |
|---|
| 1919 | | ; ;; (CURRENT-LEVEL IS-LOWER-LEVEL-P IS-HIGHER-LEVEL-P) for menu activation. |
|---|
| 1920 | | ; (let ((keywords (or (nth 0 font-lock-defaults) |
|---|
| 1921 | | ; (nth 1 (assq major-mode font-lock-defaults-alist)))) |
|---|
| 1922 | | ; (level (font-lock-value-in-major-mode font-lock-maximum-decoration))) |
|---|
| 1923 | | ; (make-local-variable 'font-lock-fontify-level) |
|---|
| 1924 | | ; (if (or (symbolp keywords) (= (length keywords) 1)) |
|---|
| 1925 | | ; (font-lock-unset-menu) |
|---|
| 1926 | | ; (cond ((eq level t) |
|---|
| 1927 | | ; (setq level (1- (length keywords)))) |
|---|
| 1928 | | ; ((or (null level) (zerop level)) |
|---|
| 1929 | | ; ;; The default level is usually, but not necessarily, level 1. |
|---|
| 1930 | | ; (setq level (- (length keywords) |
|---|
| 1931 | | ; (length (member (eval (car keywords)) |
|---|
| 1932 | | ; (mapcar 'eval (cdr keywords)))))))) |
|---|
| 1933 | | ; (setq font-lock-fontify-level (list level (> level 1) |
|---|
| 1934 | | ; (< level (1- (length keywords)))))))) |
|---|
| 1935 | | ; |
|---|
| 1936 | | ; ;; This should be called by `font-lock-unset-defaults'. |
|---|
| 1937 | | ;(defun font-lock-unset-menu () |
|---|
| 1938 | | ; ;; Deactivate less/more fontification entries. |
|---|
| 1939 | | ; (setq font-lock-fontify-level nil)) |
|---|
| | 1851 | ;;;;;###autoload |
|---|
| | 1852 | ;;(progn |
|---|
| | 1853 | ;; ;; Make the Font Lock menu. |
|---|
| | 1854 | ;; (defvar font-lock-menu (make-sparse-keymap "Syntax Highlighting")) |
|---|
| | 1855 | ;; ;; Add the menu items in reverse order. |
|---|
| | 1856 | ;; (define-key font-lock-menu [fontify-less] |
|---|
| | 1857 | ;; '("Less In Current Buffer" . font-lock-fontify-less)) |
|---|
| | 1858 | ;; (define-key font-lock-menu [fontify-more] |
|---|
| | 1859 | ;; '("More In Current Buffer" . font-lock-fontify-more)) |
|---|
| | 1860 | ;; (define-key font-lock-menu [font-lock-sep] |
|---|
| | 1861 | ;; '("--")) |
|---|
| | 1862 | ;; (define-key font-lock-menu [font-lock-mode] |
|---|
| | 1863 | ;; '("In Current Buffer" . font-lock-mode)) |
|---|
| | 1864 | ;; (define-key font-lock-menu [global-font-lock-mode] |
|---|
| | 1865 | ;; '("In All Buffers" . global-font-lock-mode))) |
|---|
| | 1866 | ;; |
|---|
| | 1867 | ;;;;;###autoload |
|---|
| | 1868 | ;;(progn |
|---|
| | 1869 | ;; ;; We put the appropriate `menu-enable' etc. symbol property values on when |
|---|
| | 1870 | ;; ;; font-lock.el is loaded, so we don't need to autoload the three variables. |
|---|
| | 1871 | ;; (put 'global-font-lock-mode 'menu-toggle t) |
|---|
| | 1872 | ;; (put 'font-lock-mode 'menu-toggle t) |
|---|
| | 1873 | ;; (put 'font-lock-fontify-more 'menu-enable '(identity)) |
|---|
| | 1874 | ;; (put 'font-lock-fontify-less 'menu-enable '(identity))) |
|---|
| | 1875 | ;; |
|---|
| | 1876 | ;; ;; Put the appropriate symbol property values on now. See above. |
|---|
| | 1877 | ;;(put 'global-font-lock-mode 'menu-selected 'global-font-lock-mode) |
|---|
| | 1878 | ;;(put 'font-lock-mode 'menu-selected 'font-lock-mode) |
|---|
| | 1879 | ;;(put 'font-lock-fontify-more 'menu-enable '(nth 2 font-lock-fontify-level)) |
|---|
| | 1880 | ;;(put 'font-lock-fontify-less 'menu-enable '(nth 1 font-lock-fontify-level)) |
|---|
| | 1881 | ;; |
|---|
| | 1882 | ;;(defvar font-lock-fontify-level nil) ; For less/more fontification. |
|---|
| | 1883 | ;; |
|---|
| | 1884 | ;;(defun font-lock-fontify-level (level) |
|---|
| | 1885 | ;; (let ((font-lock-maximum-decoration level)) |
|---|
| | 1886 | ;; (when font-lock-mode |
|---|
| | 1887 | ;; (font-lock-mode)) |
|---|
| | 1888 | ;; (font-lock-mode) |
|---|
| | 1889 | ;; (when font-lock-verbose |
|---|
| | 1890 | ;; (message "Fontifying %s... level %d" (buffer-name) level)))) |
|---|
| | 1891 | ;; |
|---|
| | 1892 | ;;(defun font-lock-fontify-less () |
|---|
| | 1893 | ;; "Fontify the current buffer with less decoration. |
|---|
| | 1894 | ;;See `font-lock-maximum-decoration'." |
|---|
| | 1895 | ;; (interactive) |
|---|
| | 1896 | ;; ;; Check in case we get called interactively. |
|---|
| | 1897 | ;; (if (nth 1 font-lock-fontify-level) |
|---|
| | 1898 | ;; (font-lock-fontify-level (1- (car font-lock-fontify-level))) |
|---|
| | 1899 | ;; (error "No less decoration"))) |
|---|
| | 1900 | ;; |
|---|
| | 1901 | ;;(defun font-lock-fontify-more () |
|---|
| | 1902 | ;; "Fontify the current buffer with more decoration. |
|---|
| | 1903 | ;;See `font-lock-maximum-decoration'." |
|---|
| | 1904 | ;; (interactive) |
|---|
| | 1905 | ;; ;; Check in case we get called interactively. |
|---|
| | 1906 | ;; (if (nth 2 font-lock-fontify-level) |
|---|
| | 1907 | ;; (font-lock-fontify-level (1+ (car font-lock-fontify-level))) |
|---|
| | 1908 | ;; (error "No more decoration"))) |
|---|
| | 1909 | ;; |
|---|
| | 1910 | ;; ;; This should be called by `font-lock-set-defaults'. |
|---|
| | 1911 | ;;(defun font-lock-set-menu () |
|---|
| | 1912 | ;; ;; Activate less/more fontification entries if there are multiple levels for |
|---|
| | 1913 | ;; ;; the current buffer. Sets `font-lock-fontify-level' to be of the form |
|---|
| | 1914 | ;; ;; (CURRENT-LEVEL IS-LOWER-LEVEL-P IS-HIGHER-LEVEL-P) for menu activation. |
|---|
| | 1915 | ;; (let ((keywords (or (nth 0 font-lock-defaults) |
|---|
| | 1916 | ;; (nth 1 (assq major-mode font-lock-defaults-alist)))) |
|---|
| | 1917 | ;; (level (font-lock-value-in-major-mode font-lock-maximum-decoration))) |
|---|
| | 1918 | ;; (make-local-variable 'font-lock-fontify-level) |
|---|
| | 1919 | ;; (if (or (symbolp keywords) (= (length keywords) 1)) |
|---|
| | 1920 | ;; (font-lock-unset-menu) |
|---|
| | 1921 | ;; (cond ((eq level t) |
|---|
| | 1922 | ;; (setq level (1- (length keywords)))) |
|---|
| | 1923 | ;; ((or (null level) (zerop level)) |
|---|
| | 1924 | ;; ;; The default level is usually, but not necessarily, level 1. |
|---|
| | 1925 | ;; (setq level (- (length keywords) |
|---|
| | 1926 | ;; (length (member (eval (car keywords)) |
|---|
| | 1927 | ;; (mapcar 'eval (cdr keywords)))))))) |
|---|
| | 1928 | ;; (setq font-lock-fontify-level (list level (> level 1) |
|---|
| | 1929 | ;; (< level (1- (length keywords)))))))) |
|---|
| | 1930 | ;; |
|---|
| | 1931 | ;; ;; This should be called by `font-lock-unset-defaults'. |
|---|
| | 1932 | ;;(defun font-lock-unset-menu () |
|---|
| | 1933 | ;; ;; Deactivate less/more fontification entries. |
|---|
| | 1934 | ;; (setq font-lock-fontify-level nil)) |
|---|