[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/svg-tag-mode 0944bb3bce 14/63: Simplified tag setup and
From: |
ELPA Syncer |
Subject: |
[elpa] externals/svg-tag-mode 0944bb3bce 14/63: Simplified tag setup and added custom variable for tags |
Date: |
Mon, 27 Dec 2021 15:57:56 -0500 (EST) |
branch: externals/svg-tag-mode
commit 0944bb3bce4ba3994ff4796b7e0694f1883e1407
Author: Nicolas P. Rougier <Nicolas.Rougier@inria.fr>
Commit: Nicolas P. Rougier <Nicolas.Rougier@inria.fr>
Simplified tag setup and added custom variable for tags
---
example.el | 28 ++++++++++++++-----------
svg-tag-mode.el | 65 +++++++++++++++++++++++++++------------------------------
2 files changed, 47 insertions(+), 46 deletions(-)
diff --git a/example.el b/example.el
index 813256b852..aa9a2d07dd 100644
--- a/example.el
+++ b/example.el
@@ -13,35 +13,39 @@
;;
;; For a full copy of the GNU General Public License
;; see <http://www.gnu.org/licenses/>.
-(require 'svg-tag-mode)
+;; (require 'svg-tag-mode)
(defface svg-tag-note-face
'((t :foreground "black" :background "white" :box "black"
:family "Roboto Mono" :weight light :height 120))
"Face for note tag" :group nil)
+
(defface svg-tag-keyboard-face
'((t :foreground "#333333" :background "#f9f9f9" :box "#333333"
:family "Roboto Mono" :weight light :height 120))
"Face for keyboard bindings tag" :group nil)
-(setq svg-tag-todo (svg-tag-make "TODO" nil 1 1 2))
-(setq svg-tag-note (svg-tag-make "NOTE" 'svg-tag-note-face 1 1 2))
+(setq svg-tag-todo
+ (svg-tag-make "TODO" nil 1 1 2))
+
+(setq svg-tag-note
+ (svg-tag-make "NOTE" 'svg-tag-note-face 1 1 2))
+
(defun svg-tag-round (text)
(svg-tag-make (substring text 1 -1) 'svg-tag-note-face 1 1 12))
+
(defun svg-tag-quasi-round (text)
(svg-tag-make (substring text 1 -1) 'svg-tag-note-face 1 1 8))
+
(defun svg-tag-keyboard (text)
(svg-tag-make (substring text 1 -1) 'svg-tag-keyboard-face 1 1 2))
-(setq svg-tags
- '(("\\(:TODO:\\)" 1 `(face nil display ,svg-tag-todo))
- ("\\(:NOTE:\\)" 1 `(face nil display ,svg-tag-note))
- ("\\(\([0-9a-zA-Z]\)\\)" 1
- `(face nil display ,(svg-tag-round (match-string 0))))
- ("\\(\([0-9a-zA-Z][0-9a-zA-Z]\)\\)" 1
- `(face nil display ,(svg-tag-quasi-round (match-string 0))))
- ("\\(|[0-9a-zA-Z- ]+?|\\)" 1
- `(face nil display ,(svg-tag-keyboard (match-string 0))))))
+(setq svg-tag-tags
+ '((":TODO:" . svg-tag-todo)
+ (":NOTE:" . svg-tag-note)
+ ("\([0-9a-zA-Z]\)" . svg-tag-round)
+ ("\([0-9a-zA-Z][0-9a-zA-Z]\)" . svg-tag-quasi-round)
+ ("|[0-9a-zA-Z- ]+?|" . svg-tag-keyboard)))
(svg-tag-mode 1)
diff --git a/svg-tag-mode.el b/svg-tag-mode.el
index 4b3bb6e1c6..df07b4ac9d 100644
--- a/svg-tag-mode.el
+++ b/svg-tag-mode.el
@@ -33,37 +33,22 @@
;;
;; 1. Replace :TODO: keyword with default face/padding/radius
;;
-;; (setq svg-tag-todo (svg-tag-make "TODO"))
-;; (setq svg-tag-tags
-;; '(("\\(:TODO:\\)" 1 `(face nil display ,svg-tag-todo))
+;; (setq svg-tag-tags '((":TODO:" (svg-tag-make "TODO")))
;; (svg-tag-mode)
;;
;;
-;; 2. Replace :TODO: keyword with specific face/padding/radius
-;;
-;; (defface svg-tag-todo-face
-;; '((t :foreground "black" :background "white" :box "black"
-;; :family "Roboto Mono" :weight light :height 120))
-;; "Face for note tag" :group nil)
-;; (setq svg-tag-todo (svg-tag-make "TODO" svg-tag-todo-face 1 1 3))
-;; (setq svg-tag-tags
-;; '(("\\(:TODO:\\)" 1 `(face nil display ,svg-tag-todo))
-;; (svg-tag-mode)
-;;
-;; 3. Replace any letter betwen @ with a circle
+;; 2. Replace any letter betwen @ with a circle
;;
;; (defun svg-tag-round (text)
;; (svg-tag-make (substring text 1 -1) nil 1 1 12))
-;; (setq svg-tag-tags
-;; '(("\\(=[0-9a-zA-Z- ]+?=\\)" 1
-;; `(face nil display ,(svg-tag-round (match-string 0))))))
+;; (setq svg-tag-tags '(("([0-9])" svg-tag-round)))
;; (svg-tag-mode)
;;
;;; Code:
(require 'svg)
(eval-when-compile (require 'subr-x))
-(defvar svg-tag-tags nil)
+;; (defvar svg-tag-tags nil)
(defvar svg-tag-tags--active nil)
(defgroup svg-tag nil
@@ -113,19 +98,18 @@ This should be zero for most fonts but some fonts may need
this."
"Default face for tag"
:group 'svg-tag)
-;; (defcustom svg-tag-tags
-;; '((":TODO:" . (svg-tag-make "TODO")))
-;; "An alist mapping keywords to tags used to display them.
+(defcustom svg-tag-tags
+ '((":TODO:" . (svg-tag-make "TODO")))
+ "An alist mapping keywords to tags used to display them.
-;; Each entry has the form (keyword . tag). Keyword is used as part
-;; of a regular expression and tag can be either a svg tag
-;; previously created by svg-tag-make or a function that takes a
-;; string as argument and returns a tag. When tag is a function, this
-;; allows to create dynamic tags."
-
-;; :group 'svg-tag-mode
-;; :type '(repeat (cons (string :tag "Keyword")
-;; (sexp :tag "Tag"))))
+Each entry has the form (keyword . tag). Keyword is used as part
+of a regular expression and tag can be either a svg tag
+previously created by svg-tag-make or a function that takes a
+string as argument and returns a tag. When tag is a function, this
+allows to create dynamic tags."
+ :group 'svg-tag
+ :type '(repeat (cons (string :tag "Keyword")
+ (sexp :tag "Tag"))))
(defun svg-tag-make (text &optional face inner-padding outer-padding radius)
@@ -179,18 +163,31 @@ This should be zero for most fonts but some fonts may
need this."
:y (+ text-y svg-tag-vertical-offset))
(svg-image svg :ascent 'center)))
+
+(defun tag-svg--build-keywords (item)
+ (let ((pattern (format "\\(%s\\)" (car item)))
+ (tag (cdr item)))
+ (when (and (symbolp tag) (fboundp tag))
+ (setq tag `(,tag (match-string 0))))
+ (setq tag ``(face nil display ,,tag))
+ `(,pattern 1 ,tag)))
+
+
(defun svg-tag-mode-on ()
(add-to-list 'font-lock-extra-managed-props 'display)
(when svg-tag-tags--active
- (font-lock-remove-keywords nil svg-tag-tags--active))
+ (font-lock-remove-keywords nil
+ (mapcar 'tag-svg--build-keywords svg-tag-tags--active)))
(when svg-tag-tags
- (font-lock-add-keywords nil svg-tag-tags))
+ (font-lock-add-keywords nil
+ (mapcar 'tag-svg--build-keywords svg-tag-tags)))
(setq svg-tag-tags--active (copy-sequence svg-tag-tags))
(message "SVG tag mode on"))
(defun svg-tag-mode-off ()
(when svg-tag-tags--active
- (font-lock-remove-keywords nil svg-tag-tags--active))
+ (font-lock-remove-keywords nil
+ (mapcar 'tag-svg--build-keywords svg-tag-tags--active)))
(setq svg-tag-tags--active nil)
(message "SVG tag mode off"))
- [elpa] externals/svg-tag-mode 607d05d972 37/63: Fix conflict, (continued)
- [elpa] externals/svg-tag-mode 607d05d972 37/63: Fix conflict, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 60d56f3f41 29/63: Fixed terminal mode error, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 4fb494db21 43/63: Changed style of date, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 3dd9bef838 59/63: Removed `org-plist-delete` dependency., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 60140b7526 62/63: Remove ununsed local variables., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode c78500db2c 60/63: Fix bugs (typos)., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode de9aba3f37 09/63: Fix style and naming, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 90c15ebc07 05/63: Load subr-x for string-trim, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode e9d0df33a6 12/63: Better default, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode a5af3041c4 07/63: Added customizable options, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 0944bb3bce 14/63: Simplified tag setup and added custom variable for tags,
ELPA Syncer <=
- [elpa] externals/svg-tag-mode db4d223352 18/63: Fixed documentation, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 9649055e90 20/63: Trying to fix header, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode cec780a16f 21/63: Added version, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 4fdc7ffbb3 23/63: Fixed font weights, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 609ed7cc32 24/63: Removed free variable, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 0125ceca29 22/63: Fix README, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode a9e8d9e705 27/63: Fixes followign review at https://github.com/melpa/melpa/pull/7217, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 40d7820143 28/63: Moved examples into a directory, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode c0492f9046 30/63: Fixed links, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 78a343f0f3 34/63: Cleanup whitespace, ELPA Syncer, 2021/12/27