From 3aecf0ab7c394aa8ba67cf7bea28327f9433aa6f Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Sat, 21 Dec 2024 17:27:37 +0100 Subject: [PATCH] update color-identifiers-mode Signed-off-by: Andreas Gerler --- .../color-identifiers-mode-pkg.el | 15 ----- .../color-identifiers-mode-autoloads.el | 52 +++++++-------- .../color-identifiers-mode-pkg.el | 11 ++++ .../color-identifiers-mode.el | 66 +++++++++++++------ elpa/color-identifiers-mode-readme.txt | 6 -- 5 files changed, 79 insertions(+), 71 deletions(-) delete mode 100644 elpa/color-identifiers-mode-20230405.527/color-identifiers-mode-pkg.el rename elpa/{color-identifiers-mode-20230405.527 => color-identifiers-mode-20241023.2217}/color-identifiers-mode-autoloads.el (71%) create mode 100644 elpa/color-identifiers-mode-20241023.2217/color-identifiers-mode-pkg.el rename elpa/{color-identifiers-mode-20230405.527 => color-identifiers-mode-20241023.2217}/color-identifiers-mode.el (93%) delete mode 100644 elpa/color-identifiers-mode-readme.txt diff --git a/elpa/color-identifiers-mode-20230405.527/color-identifiers-mode-pkg.el b/elpa/color-identifiers-mode-20230405.527/color-identifiers-mode-pkg.el deleted file mode 100644 index 30724578..00000000 --- a/elpa/color-identifiers-mode-20230405.527/color-identifiers-mode-pkg.el +++ /dev/null @@ -1,15 +0,0 @@ -(define-package "color-identifiers-mode" "20230405.527" "Color identifiers based on their names" - '((dash "2.5.0") - (emacs "24")) - :commit "c4060d1bca6fa2acfe449e086171d4efee62863f" :authors - '(("Ankur Dave" . "ankurdave@gmail.com")) - :maintainers - '(("Ankur Dave" . "ankurdave@gmail.com")) - :maintainer - '("Ankur Dave" . "ankurdave@gmail.com") - :keywords - '("faces" "languages") - :url "https://github.com/ankurdave/color-identifiers-mode") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/color-identifiers-mode-20230405.527/color-identifiers-mode-autoloads.el b/elpa/color-identifiers-mode-20241023.2217/color-identifiers-mode-autoloads.el similarity index 71% rename from elpa/color-identifiers-mode-20230405.527/color-identifiers-mode-autoloads.el rename to elpa/color-identifiers-mode-20241023.2217/color-identifiers-mode-autoloads.el index be8f679c..a3627bf7 100644 --- a/elpa/color-identifiers-mode-20230405.527/color-identifiers-mode-autoloads.el +++ b/elpa/color-identifiers-mode-20241023.2217/color-identifiers-mode-autoloads.el @@ -1,37 +1,35 @@ -;;; color-identifiers-mode-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- -;; +;;; color-identifiers-mode-autoloads.el --- automatically extracted autoloads (do not edit) -*- lexical-binding: t -*- +;; Generated by the `loaddefs-generate' function. + +;; This file is part of GNU Emacs. + ;;; Code: -(add-to-list 'load-path (directory-file-name - (or (file-name-directory #$) (car load-path)))) +(add-to-list 'load-path (or (and load-file-name (directory-file-name (file-name-directory load-file-name))) (car load-path))) + -;;;### (autoloads nil "color-identifiers-mode" "color-identifiers-mode.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from color-identifiers-mode.el (autoload 'color-identifiers-mode "color-identifiers-mode" "\ Color the identifiers in the current buffer based on their names. This is a minor mode. If called interactively, toggle the -`Color-Identifiers mode' mode. If the prefix argument is -positive, enable the mode, and if it is zero or negative, disable -the mode. +`Color-Identifiers mode' mode. If the prefix argument is positive, +enable the mode, and if it is zero or negative, disable the mode. -If called from Lisp, toggle the mode if ARG is `toggle'. Enable -the mode if ARG is nil, omitted, or is a positive number. -Disable the mode if ARG is a negative number. +If called from Lisp, toggle the mode if ARG is `toggle'. Enable the +mode if ARG is nil, omitted, or is a positive number. Disable the mode +if ARG is a negative number. To check whether the minor mode is enabled in the current buffer, -evaluate `color-identifiers-mode'. +evaluate the variable `color-identifiers-mode'. -The mode's hook is called both when the mode is enabled and when -it is disabled. - -\(fn &optional ARG)" t nil) +The mode's hook is called both when the mode is enabled and when it is +disabled. +(fn &optional ARG)" t) (put 'global-color-identifiers-mode 'globalized-minor-mode t) - (defvar global-color-identifiers-mode nil "\ Non-nil if Global Color-Identifiers mode is enabled. See the `global-color-identifiers-mode' command @@ -39,9 +37,7 @@ for a description of this minor mode. Setting this variable directly does not take effect; either customize it (see the info node `Easy Customization') or call the function `global-color-identifiers-mode'.") - (custom-autoload 'global-color-identifiers-mode "color-identifiers-mode" nil) - (autoload 'global-color-identifiers-mode "color-identifiers-mode" "\ Toggle Color-Identifiers mode in all buffers. With prefix ARG, enable Global Color-Identifiers mode if ARG is @@ -57,21 +53,19 @@ Color-Identifiers mode is enabled in all buffers where See `color-identifiers-mode' for more information on Color-Identifiers mode. -\(fn &optional ARG)" t nil) - +(fn &optional ARG)" t) (register-definition-prefixes "color-identifiers-mode" '("color-identifiers")) - -;;;*** -;;;### (autoloads nil nil ("color-identifiers-mode-pkg.el") (0 0 -;;;;;; 0 0)) +;;; End of scraped data + +(provide 'color-identifiers-mode-autoloads) -;;;*** - ;; Local Variables: ;; version-control: never ;; no-byte-compile: t ;; no-update-autoloads: t -;; coding: utf-8 +;; no-native-compile: t +;; coding: utf-8-emacs-unix ;; End: + ;;; color-identifiers-mode-autoloads.el ends here diff --git a/elpa/color-identifiers-mode-20241023.2217/color-identifiers-mode-pkg.el b/elpa/color-identifiers-mode-20241023.2217/color-identifiers-mode-pkg.el new file mode 100644 index 00000000..e69cbe9e --- /dev/null +++ b/elpa/color-identifiers-mode-20241023.2217/color-identifiers-mode-pkg.el @@ -0,0 +1,11 @@ +;; -*- no-byte-compile: t; lexical-binding: nil -*- +(define-package "color-identifiers-mode" "20241023.2217" + "Color identifiers based on their names." + '((dash "2.5.0") + (emacs "24.4")) + :url "https://github.com/ankurdave/color-identifiers-mode" + :commit "89343c624ae64f568b5305ceca3db48d65711863" + :revdesc "89343c624ae6" + :keywords '("faces" "languages") + :authors '(("Ankur Dave" . "ankurdave@gmail.com")) + :maintainers '(("Ankur Dave" . "ankurdave@gmail.com"))) diff --git a/elpa/color-identifiers-mode-20230405.527/color-identifiers-mode.el b/elpa/color-identifiers-mode-20241023.2217/color-identifiers-mode.el similarity index 93% rename from elpa/color-identifiers-mode-20230405.527/color-identifiers-mode.el rename to elpa/color-identifiers-mode-20241023.2217/color-identifiers-mode.el index 3653f6ce..001a6b92 100644 --- a/elpa/color-identifiers-mode-20230405.527/color-identifiers-mode.el +++ b/elpa/color-identifiers-mode-20241023.2217/color-identifiers-mode.el @@ -5,9 +5,10 @@ ;; Author: Ankur Dave ;; Url: https://github.com/ankurdave/color-identifiers-mode ;; Created: 24 Jan 2014 -;; Version: 1.1 +;; Package-Version: 20241023.2217 +;; Package-Revision: 89343c624ae6 ;; Keywords: faces, languages -;; Package-Requires: ((dash "2.5.0") (emacs "24")) +;; Package-Requires: ((dash "2.5.0") (emacs "24.4")) ;; This file is not a part of GNU Emacs. @@ -35,7 +36,7 @@ ;;; Code: -(require 'advice) +(require 'nadvice) (require 'color) (require 'dash) (require 'cl-lib) @@ -65,7 +66,7 @@ `color-identifiers:modes-alist' that is relevant to the current major mode") -(defadvice enable-theme (after color-identifiers:regen-on-theme-change) +(defun color-identifiers:regen-on-theme-change(_) "Regenerate colors for color-identifiers-mode on theme change." (color-identifiers:regenerate-colors)) @@ -88,6 +89,13 @@ color should be avoided when generating colors, this can be warning colors, error colors etc." :type '(repeat face)) +(defcustom color-identifiers:extra-face-attributes nil + "Extra face attributes to apply to identifiers. Can be used to make +identifiers bold or italic, but avoid changing `:foreground' +because it is the color determined by the mode." + :type 'plist + :group 'color-identifiers) + (defvar color-identifiers:modes-alist nil "Alist of major modes and the ways to distinguish identifiers in those modes. The value of each cons cell provides four constraints for finding @@ -654,18 +662,26 @@ mode. This variable memoizes the result of the declaration scan function.") (progn (print "Major mode is not supported by color-identifiers, disabling") (color-identifiers-mode -1)) - (color-identifiers:regenerate-colors) + (unless color-identifiers:colors + ;; When GUI emacs is used and additionally terminal-based `emacsclient' + ;; gets launched, that may cause colors for identifiers change globally. + ;; This is not a good user experience. Ideally we should keep two + ;; separate vectors, for graphics and terminal versions of colors. But + ;; it's unclear how that should communicate with theme changes, so unless + ;; there's demand, let's for now just make sure we don't toggle colors + ;; back and forth everywhere. + (color-identifiers:regenerate-colors)) (when (null color-identifiers:color-index-for-identifier) (setq color-identifiers:color-index-for-identifier (make-hash-table :test 'equal))) (color-identifiers:refresh) (add-to-list 'font-lock-extra-managed-props 'color-identifiers:fontified) (font-lock-add-keywords nil '((color-identifiers:colorize . default)) t) (color-identifiers:enable-timer) - (ad-activate 'enable-theme))) + (advice-add 'enable-theme :after #'color-identifiers:regen-on-theme-change))) (when color-identifiers:timer (cancel-timer color-identifiers:timer)) (font-lock-remove-keywords nil '((color-identifiers:colorize . default))) - (ad-deactivate 'enable-theme)) + (advice-remove 'enable-theme #'color-identifiers:regen-on-theme-change)) (color-identifiers:refontify)) ;;;###autoload @@ -731,13 +747,13 @@ major mode, identifiers are saved to ;; `color-identifiers:get-declarations', which returns all identifiers (color-identifiers:get-declarations))) -(defun color-identifiers:refontify () - "Refontify the buffer using font-lock." - (when font-lock-mode - (if (fboundp 'font-lock-flush) - (font-lock-flush) +(defalias 'color-identifiers:refontify + (if (fboundp 'font-lock-flush) + 'font-lock-flush + (lambda () + "Refontify the buffer using font-lock." (with-no-warnings - (font-lock-fontify-buffer))))) + (and font-lock-mode (font-lock-fontify-buffer)))))) (defun color-identifiers:color-identifier (identifier) "Return the hex color for IDENTIFIER, or nil if it should not @@ -777,7 +793,7 @@ evaluates to true." (let ((flface-prop (get-text-property (point) 'font-lock-face))) (and flface-prop (memq flface-prop identifier-faces)))) (if (and (looking-back identifier-context-re (line-beginning-position)) - (or (not identifier-exclusion-re) (not (looking-at identifier-exclusion-re))) + (or (not identifier-exclusion-re) (not (looking-at-p identifier-exclusion-re))) (looking-at identifier-re)) (progn ;; Found an identifier. Run `fn' on it @@ -795,15 +811,23 @@ evaluates to true." (let* ((identifier (buffer-substring-no-properties start end)) (hex (color-identifiers:color-identifier identifier))) (when hex - (put-text-property start end 'face `(:foreground ,hex)) - (put-text-property start end 'color-identifiers:fontified t)))) - limit)) + (let ((face-spec (append `(:foreground ,hex) color-identifiers:extra-face-attributes))) + (put-text-property start end 'face face-spec) + (put-text-property start end 'color-identifiers:fontified t))))) + limit)) (defun color-identifiers-mode-maybe () - "Enable `color-identifiers-mode' in the current buffer if desired. -When `major-mode' is listed in `color-identifiers:modes-alist', then -`color-identifiers-mode' will be enabled." - (when (assoc major-mode color-identifiers:modes-alist) + "Potentially enable `color-identifiers-mode' in the current buffer. + +Specifically, when `major-mode' is listed in +`color-identifiers:modes-alist', and the buffer isn't temporary." + ;; Avoid running in temp buffers created by `with-temp-buffer'. Most notably, + ;; package installation process is known to create one and then enable + ;; `emacs-lisp-mode' for the purpose of parsing autoloads, which in turn triggers + ;; color-identifers-mode for no reason. During a huge upgrade this may add up, + ;; especially given our ad hoc ELisp parsing code isn't the fastest. + (when (and (not (string-prefix-p " *temp" (buffer-name))) + (assoc major-mode color-identifiers:modes-alist)) (color-identifiers-mode 1))) (provide 'color-identifiers-mode) diff --git a/elpa/color-identifiers-mode-readme.txt b/elpa/color-identifiers-mode-readme.txt deleted file mode 100644 index d01cedd7..00000000 --- a/elpa/color-identifiers-mode-readme.txt +++ /dev/null @@ -1,6 +0,0 @@ -Color Identifiers is a minor mode for Emacs that highlights each source code -identifier uniquely based on its name. It is inspired by a post by Evan -Brooks: https://medium.com/p/3a6db2743a1e/ - -Check out the project page, which has screenshots, a demo, and usage -instructions: https://github.com/ankurdave/color-identifiers-mode -- 2.47.3