branch: externals/svg-tag-mode commit 7a4e0df952121d9385735174857a60d7822eb0b8 Author: Nicolas P. Rougier <nicolas.roug...@inria.fr> Commit: Nicolas P. Rougier <nicolas.roug...@inria.fr>
Added org-mode example --- example.el => example-1.el | 33 +++++++++++++------- example-2.el | 78 ++++++++++++++++++++++++++++++++++++++++++++++ svg-tag-mode.el | 7 +++-- 3 files changed, 104 insertions(+), 14 deletions(-) diff --git a/example.el b/example-1.el similarity index 64% rename from example.el rename to example-1.el index bb3572bc73..7942c3ea4a 100644 --- a/example.el +++ b/example-1.el @@ -13,7 +13,7 @@ ;; ;; 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" @@ -25,11 +25,16 @@ :family "Roboto Mono" :weight light :height 120)) "Face for keyboard bindings tag" :group nil) +(defface svg-tag-org-face + '((t :foreground "#333333" :background "#fffff0" :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)) + (svg-tag-make "NOTE" 'svg-tag-note-face 2 0 2)) (defun svg-tag-round (text) (svg-tag-make (substring text 1 -1) 'svg-tag-note-face 1 1 12)) @@ -40,12 +45,16 @@ (defun svg-tag-keyboard (text) (svg-tag-make (substring text 1 -1) 'svg-tag-keyboard-face 1 1 2)) +(defun svg-tag-org (text) + (svg-tag-make (substring text 1 -1) 'svg-tag-org-face 1 1 2)) + (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))) + '(("@[0-9a-zA-Z]+:" . svg-tag-org) + (":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) @@ -59,11 +68,11 @@ ;; More examples: ;; -------------- ;; -;; Save ................. |C-x|+|C-s| Help ............... |C-h| -;; Save as .............. |C-x|+|C-w| Cancel ............. |C-g| -;; Open a new file ...... |C-x|+|C-f| Undo ............... |C-z| -;; Open recent .......... |C-x|+|C-r| Close buffer ....... |C-x|+|k| -;; Browse directory ......|C-x|+|d| Quit ............... |C-x|+|C-c| +;; Save ................. |C-x||C-s| Help ............... |C-h| +;; Save as .............. |C-x||C-w| Cancel ............. |C-g| +;; Open a new file ...... |C-x||C-f| Undo ............... |C-z| +;; Open recent .......... |C-x||C-r| Close buffer ....... |C-x||k| +;; Browse directory ......|C-x||d| Quit ............... |C-x||C-c| ;; ;; ------------------------------------------------------------------------ ;; (1)(2)(3)(4)(5)(Z)(W)(12)(99) diff --git a/example-2.el b/example-2.el new file mode 100644 index 0000000000..69e91ff0ba --- /dev/null +++ b/example-2.el @@ -0,0 +1,78 @@ +;; Copyright (C) 2020 Nicolas P. Rougier +;; This file is not part of GNU Emacs. +;; +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. +;; +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; For a full copy of the GNU General Public License +;; see <http://www.gnu.org/licenses/>. +(require 'svg-tag-mode) + +(defface svg-tag-todo-face + '((t :foreground "#ffffff" :background "#FFAB91" :box "#FFAB91" + :family "Roboto Mono" :weight light :height 120)) + "Face for TODO svg tag" :group nil) + +(defface svg-tag-next-face + '((t :foreground "white" :background "#673AB7" :box "#673AB7" + :family "Roboto Mono" :weight light :height 120)) + "Face for NEXT svg tag" :group nil) + +(defface svg-tag-done-face + '((t :foreground "white" :background "#B0BEC5" :box "#B0BEC5" + :family "Roboto Mono" :weight light :height 120)) + "Face for DONE svg tag" :group nil) + +(defface svg-tag-date-face + '((t :foreground "white" :background "#B0BEC5" :box "#B0BEC5" + :family "Roboto Mono" :weight light :height 120)) + "Face for date svg tag" :group nil) + +(defface svg-tag-org-face + '((t :foreground "black" :background "white" :box "black" + :family "Roboto Mono" :weight light :height 120)) + "Default face for svg tag" :group nil) + +(setq radius 2) + +(setq svg-tag-org-todo (svg-tag-make "TODO" 'svg-tag-todo-face 1 1 radius)) +(setq svg-tag-org-done (svg-tag-make "DONE" 'svg-tag-done-face 1 1 radius)) +(setq svg-tag-org-hold (svg-tag-make "HOLD" 'svg-tag-done-face 1 1 radius)) +(setq svg-tag-org-next (svg-tag-make "NEXT" 'svg-tag-next-face 1 1 radius)) +(setq svg-tag-org-note (svg-tag-make "NOTE" 'svg-tag-org-face 1 1 radius)) + +(defun svg-tag-make-org-todo (text) + (svg-tag-make (substring text 1 -1) 'svg-tag-done-face 1 1 radius)) +(defun svg-tag-make-org-tag (text) + (svg-tag-make (substring text 1 -1) 'svg-tag-org-face 1 1 radius)) +(defun svg-tag-make-org-priority (text) + (svg-tag-make (substring text 2 -1) 'svg-tag-org-face 1 0 radius)) +(defun svg-tag-make-org-date (text) + (svg-tag-make (substring text 1 -1) 'svg-tag-date-face 0 0 radius)) + +(setq svg-tag-tags + '(("@[0-9a-zA-Z]+:" . svg-tag-make-org-tag) + ("\\[#[ABC]\\]" . svg-tag-make-org-priority) + (" TODO " . svg-tag-org-todo) + (" DONE " . svg-tag-org-done) + (" NEXT " . svg-tag-org-next) + (" HOLD " . svg-tag-org-hold) + (" NOTE " . svg-tag-org-note) + ("<[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [A-Za-z]\\{3\\}>" + . svg-tag-make-org-date))) + +(svg-tag-mode 1) + +;; To do: TODO NEXT HOLD DONE +;; Tags: @MEETING:@NOTE: +;; Priorities: [#A] [#B] [#C] +;; Date: <2020-11-07 Sat> + + diff --git a/svg-tag-mode.el b/svg-tag-mode.el index df07b4ac9d..29c5d1358b 100644 --- a/svg-tag-mode.el +++ b/svg-tag-mode.el @@ -37,7 +37,7 @@ ;; (svg-tag-mode) ;; ;; -;; 2. Replace any letter betwen @ with a circle +;; 2. Replace any letter between () with a circle ;; ;; (defun svg-tag-round (text) ;; (svg-tag-make (substring text 1 -1) nil 1 1 12)) @@ -113,6 +113,7 @@ allows to create dynamic tags." (defun svg-tag-make (text &optional face inner-padding outer-padding radius) + "Create a SVG image displaying text in a rounded box" (let* ((face (or face 'svg-tag-default-face)) (foreground (face-attribute face :foreground)) (background (face-attribute face :background)) @@ -165,6 +166,7 @@ allows to create dynamic tags." (defun tag-svg--build-keywords (item) + "Internal, build the list of keywords" (let ((pattern (format "\\(%s\\)" (car item))) (tag (cdr item))) (when (and (symbolp tag) (fboundp tag)) @@ -172,8 +174,8 @@ allows to create dynamic tags." (setq tag ``(face nil display ,,tag)) `(,pattern 1 ,tag))) - (defun svg-tag-mode-on () + "Activate SVG tag mode" (add-to-list 'font-lock-extra-managed-props 'display) (when svg-tag-tags--active (font-lock-remove-keywords nil @@ -185,6 +187,7 @@ allows to create dynamic tags." (message "SVG tag mode on")) (defun svg-tag-mode-off () + "Deactivate SVG tag mode" (when svg-tag-tags--active (font-lock-remove-keywords nil (mapcar 'tag-svg--build-keywords svg-tag-tags--active)))