Giter Club home page Giter Club logo

svg-tag-mode's Introduction

svg-tag-mode

A minor mode to replace keywords or regular expression with SVG tags.

Usage example

You need first to set svg-tag-tags that is a list of item here each item has the form (KEYWORD (TAG COMMAND HELP)) where:

  • KEYWORD is a regular expression including a matched group of the form \\(xxx\\). If this is not the case the whole string will be used a the matched group.
  • TAG is either a SVG image that will be displayed using the 'display property or a function that accepts a unique string argument (match-string 1) and returns an SVG image.
  • COMMAND is a command to be executed when user clicks on the tag. It can be nil if no command is associated with the tag.
  • HELP is a string to be displayed when mouse pointer is over the tag. It can be nil if no command is associated with the tag.

then you can invoke mode with M-x svg-tag-mode. Here are some examples:

  1. Replace any occurrence of :TODO: with a static SVG tag displaying TODO
(setq svg-tag-tags
      '((":TODO:" . ((lambda (tag) (svg-tag-make "TODO"))))))
  1. Replace any occurrence of :HELLO: with a static SVG tag displaying HELLO that can be clicked to execute the specified command. Help message is displayed when the tag is hovered with the pointer.
(setq svg-tag-tags
      '((":HELLO:" .  ((lambda (tag) (svg-tag-make "HELLO"))
                       (lambda () (interactive) (message "Hello world!"))
                       "Print a greeting message"))))
  1. Replace any occurrence of :TODO: with a dynamic SVG tag displaying :TODO:
(setq svg-tag-tags
      '((":TODO:" . ((lambda (tag) (svg-tag-make tag))))))
  1. Replace any occurrence of :TODO: with a dynamic SVG tag displaying TODO
(setq svg-tag-tags
      '((":TODO:" . ((lambda (tag)
                       (svg-tag-make tag :beg 1 :end -1))))))
  1. Replaces any occurrence of :XXX: with a dynamic SVG tag displaying XXX
(setq svg-tag-tags
      '(("\\(:[A-Z]+:\\)" . ((lambda (tag)
                               (svg-tag-make tag :beg 1 :end -1))))))
  1. Replaces any occurrence of :XXX|YYY: with two adjacent dynamic SVG tags displaying XXX and YYY
(setq svg-tag-tags
      '(("\\(:[A-Z]+\\)\|[a-zA-Z#0-9]+:" . ((lambda (tag)
                                           (svg-tag-make tag :beg 1 :inverse t
                                                          :margin 0 :crop-right t))))
        (":[A-Z]+\\(\|[a-zA-Z#0-9]+:\\)" . ((lambda (tag)
                                           (svg-tag-make tag :beg 1 :end -1
                                                         :margin 0 :crop-left t))))))
  1. This replaces any occurrence of :#TAG1:#TAG2:…:$ ($ means end of line) with a dynamic collection of SVG tags. Note the # symbol in front of tags. This is mandatory because Emacs cannot do regex look ahead.
(setq svg-tag-tags
      '(("\\(:#[A-Za-z0-9]+\\)" . ((lambda (tag)
                                     (svg-tag-make tag :beg 2))))
        ("\\(:#[A-Za-z0-9]+:\\)$" . ((lambda (tag)
                                       (svg-tag-make tag :beg 2 :end -1))))))

Known Problems

SVG tags cannot render in org-agenda

As issue #27 mentioned, SVG tags cannot render in org-agenda, because svg-tag-mode uses font-lock-mode to show SVG tags. However, org-agenda does not use font-lock-mode, so it only shows rendered SVG tags in visited buffers. One way to solve this problem is to use overly:

  (defun org-agenda-show-svg ()
    (let* ((case-fold-search nil)
           (keywords (mapcar #'svg-tag--build-keywords svg-tag--active-tags))
           (keyword (car keywords)))
      (while keyword
        (save-excursion
          (while (re-search-forward (nth 0 keyword) nil t)
            (overlay-put (make-overlay
                          (match-beginning 0) (match-end 0))
                         'display  (nth 3 (eval (nth 2 keyword)))) ))
        (pop keywords)
        (setq keyword (car keywords)))))
  (add-hook 'org-agenda-finalize-hook #'org-agenda-show-svg)

svg-tag-mode's People

Contributors

a13 avatar elilif avatar rougier avatar shadowmitia avatar shankar2k avatar tarsius avatar tsuu32 avatar wojnicki avatar xav-ie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

svg-tag-mode's Issues

Strange shift error

Hi

You can notice in attached screen capture that there is a slight vertical shift between the "TITLE" svg
and the following text. This shift appears precisely as soon as I begin to write a non space character after the keyword.

This shift does only append with the #+TITLE: orgmode keyword. As an example, for the #+SUBTITLE: keyword, it is
correctly displayed.

svg-tag-mode-err

But settings in orgmode for both keywords are exaclty the same :

        svg-tag-tags
        `(
          ;;
          ;; File header
          ;;

          ("^\\(#\\+TITLE:[\s-]*\\)" . ((lambda (tag) (local/svg-tag-make-title "TITLE" :margin 0 :face 'svg-title :inverse t :crop-right t))))
          ("^#\\+TITLE:[\s-]*\\([^\s-].*\\)" . ((lambda (tag) (local/svg-tag-make-title tag :margin 0 :face 'svg-title :crop-left t))))

          ("^\\(#\\+SUBTITLE:[\s-]*\\)" . ((lambda (tag) (local/svg-tag-make-headline "SUBTITLE" :margin 0 :face 'svg-title :inverse t :crop-right t))))
          ("^#\\+SUBTITLE:[\s-]*\\([^\s-].*\\)" . ((lambda (tag) (local/svg-tag-make-headline tag :margin 0 :face 'svg-title :crop-left t))))

Do you have a clue about what is happening ?

Regards

Question: How to enable in minibuffer?

Has anyone succeeded to enable this mode in the minibuffer? Even when I turn on the global mode I'm not seeing tags rendered in the minibuffer.

Any help would be appreciated, thanks!

Introduce tag font face

Somewhat related to #5, what do you think about defining a svg-tag-face that inherits from :default but allows users to customize if needed?

Am asking because with my default font setting, the tags are a bit on the larger side:

image

Would like to make them 80% height or so. And my main font is monospaced, but for tags I'd prefer variable width.

(If there are no objections I can also try to add that myself and propose a PR)

Square Brackets not matching Correctly

I'm trying to match Text like this:
[SFSGT]
[ILSBY]
[BFKR]
etc.

With regexp-builder i can match it like this:
\\[[A-Z]\\]
But from a bit of testing with different matches, it seems like svg-tag-mode isn't able to handle the two Square Brackets. The Regex above produces no tags at all. If i match it like this:
[A-Z]\\]
It correctly matches all text and the last Square Bracket
With Capture groups i'm also able to only match the first Square bracket. From your examples with the Priorities, Having any Static Character between the Square Bracket and the Text also seems to work. But having exactly those two Brackets in the regex seems to somehow break.

Only progress bars work

Hello rougier, thanks for the amazing package!

I had svg-tag-mode installed for a while now, got it working perfectly, but now for some reason the only thing that works is the progress count. This happened with no change in my configuration whatsoever.

Here is my config:
https://gist.github.com/KChousos/c1f9cbe7aed3d5bd614c91cb10b06bc9

It is almost exactly the same as the example-2.el file.
Is there any chance that you have any insight on why this config suddenly stopped working? I have tested other configurations as well, and the problem persists, only progress bars render. Thanks for your time.

Add cache for SVG tags?

I noticed that every time a new keyword(such as "TODO") is inserted, svg-tag-make (or similar functions) is called. I think this is unnecessary because the same parameters will always generate the same image. So is it possible to add a cache to use the cached image in the case of the same parameters?

For instance:

(defvar svg-tag-cache nil)

(defun svg-tag-make-with-cache (tag &rest args)
  (unless svg-tag-cache
    (setq svg-tag-cache (make-hash-table :test 'equal)))
  (with-memoization (gethash `(tag ,@args) svg-tag-cache)
    (apply #'svg-tag-make tag args)))

In my case, I found that when using SVG tags in the tab-bar or modeline, using caching significantly reduces resource consumption.

Is it worthwhile to create a PR?

Install error

Tried installing from both gnu and melpa using package-list-packages. In both cases I get:

In end of data: svg-tag-mode.el:324:1:Warning: the function ‘string-trim’ is not known to be defined.

Using emacs 27.2 on Xubuntu with Emacs Prelude configuration.

Minibuffer constantly has "SVG tag mode on", hides other messages

Hello,

I seem to be constantly having the message "SVG tag mode on" printed in the minibuffer, and it seems to happen all the time.
I don't mind having it once, but I'd also like to see the messages it hides!

It seems to happen a lot when trying to display document through eldoc? Like the mode is activated everytime?

I don't know if the messages could be removed? Maybe have a quiet mode?

Progress bar not working

Emacs 29 - windows 11 - mingw64

latest packages to date.

Here is the configuration for progress bar :

        ("\\[\\([0-9]\\{1,3\\}\\)%\\]" . ((lambda (tag) (svg-progress-percent tag))))
        ("\\[\\([0-9]+/[0-9]+\\)\\]" . ((lambda (tag) (svg-progress-count tag))))

The svg-progress-* functions are :

(defun svg-progress-percent (value)
  (svg-image (svg-lib-concat
              (svg-lib-progress-bar (/ (string-to-number value) 100.0)
                                    nil :margin 0 :stroke 2 :radius 3 :padding 2
                                    :foreground (face-foreground 'fixed-pitch nil 'default)
                                    :background (face-background 'fixed-pitch nil 'default)
                                    :width local/svg-bar-width-headline
                                    :height local/svg-height-headline)
              (svg-lib-tag (concat value "%")
                           nil :stroke 0 :margin 0
                           :foreground (face-foreground 'fixed-pitch nil 'default)
                           :background (face-background 'fixed-pitch nil 'default)
                           :width local/svg-tag-width-headline
                           :height local/svg-height-headline
                           :font-family local/svg-font-family
                           :font-size local/svg-font-size-headline))
             :ascent 'center))

(defun svg-progress-count (value)
  (let* ((seq (mapcar #'string-to-number (split-string value "/")))
         (count (float (car seq)))
         (total (float (cadr seq))))
  (svg-image (svg-lib-concat
              (svg-lib-progress-bar (/ count total) nil
                                    :margin 0 :stroke 2 :radius 3 :padding 2
                                    :foreground (face-foreground 'fixed-pitch nil 'default)
                                    :background (face-background 'fixed-pitch nil 'default)
                                    :width local/svg-bar-width-headline
                                    :height local/svg-height-headline)
              (svg-lib-tag value nil
                           :stroke 0 :margin 0
                           :foreground (face-foreground 'fixed-pitch nil 'default)
                           :background (face-background 'fixed-pitch nil 'default)
                           :width local/svg-tag-width-headline
                           :height local/svg-height-headline
                           :font-family local/svg-font-family
                           :font-size local/svg-font-size-headline))
             :ascent 'center)))

I had to rewrite them and also the svg-lib-tag function to account for some size issues I posted here a long time ago.

But it works well, in lisp-interaction-mode :

(dotimes (i 5) (insert-image (svg-progress-percent "10 ")))

does produce correct progress bars.

But in a regular org file, if I write :

* TODO Some heading [%]

as soon as I hit C-c C-c, it breaks the whole (only the line) line rendering, for example, the TODO is also
no more rendered with a svg.

In the "Message" buffer, this error is reported :

Error during redisplay: (jit-lock-function 20) signaled (wrong-type-argument stringp nil) [10 times]

Given that the progress functions seems correct and that svg-tag-mode works nicely for most others tags defined,
I have no clue of what is happening. Do you have an idea ?

Regards

Include a default set of tags

I think it would be worthwhile, as a user onboarding experience, for this package to include a default set of tags bindings that they can enable.

One of the use cases I'm thinking of is If someone downloads this from MELPA, they won't have access to example1.el or example2.el to be able to be able to use at their discretion.

Some tags not rendering in `org-agenda`

asdfasdf

It might just be a configuration issue on my end, but I'm not sure. You can see that the TODO does render in one case, but not in all others. I can remedy this issue by visiting the file the specific TODO is written in, then when getting back into the org-agenda it's rendered as an expected SVG, but this doesn't seem ideal.

Enhancement : implement `org-appear` or `org-fragtog` like functionality

Hi,

First, thanks for bringing svgs to org-mode, I think it opens endless opportunities to make org
files look nicer.

However, it is sometimes practical to see the real text, the one you see when you open org files
with another editor.

As an example, schedules are prettified by svg-tag-mode, I checked that you can modify the
schedule when cursor is above svg, this latter is instantly updated after having modified the
schedule.

However, you cannot see directly the modification. For that, one should disable svg-tag-mode
and re-enable it after. But it is more practical to modify the text when you clearly see it.

To do this, would it be possible to implement an org-appear or org-fragtog like functionality.
You probably already know these packages, the idea of second one is to make equations appear
as text as soon as cursor is within the latex fragment and, display the svg equation otherwise.

Then, svg-tag-mode should replace text by svgs wherever it has to, except when cursor is within
one element (date, priority, tag, ...)

Regards

Does not work if tree-sitter is enabled

I dunno if this bug belongs here or at the tree-sitter repo.
But tree-sitter stops svg-tag-mode from working, if I disable tree-sitter it works for me. Dunno if it swift specific or not.

Last week I could use both at the same time without any problems.

Invalid image type ‘svg’

Hello Nicolas. I'm very interested by this, but, on Windows, with Cygwin Emacs 27, I get the error

Invalid image type ‘svg’

I could launch this

(image-type-available-p 'svg)

and I do have a nil returned. Is it because of Windows?

Is there some way to fix this?

Best regards!

left mouse clicks on svg tags not working as expected (doom emacs / org-mode)

I' m on Doom emacs/org-mode and have the issue that a left-button mouse click on an svg-tags does not work like I would expect it.

Hovering over the tag -> ok, left mouse click on links -> ok, but when I left-click on the svg-tag nothing happens.
I can select the tag by the left mouse click but have to subsequently press 'enter' in order to call a function (e.g. get the buffer evaluated like in notebook-mode)

Is "left click + enter" the required action or should just a left-button mouse click on the svg-tag be sufficient in order to call a specified function.

Unfortunately, I do not know if it's just my misunderstanding, an svg-tag-mode issue or Doom emacs related.

Thanks for your excellent work on svg-tag-mode and for help or a clue in advance.

svg-tag-mode causing issue with src block on Emacs 29

Here is my emacs version:

GNU Emacs 29.1
Development version 28fb02492c24 on master branch; build date 2023-09-23.
Copyright (C) 2023 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

And here is my svg-tag-mode config:

(use-package svg-tag-mode
  :ensure t
  :hook org-mode
  :config
  (defun org-agenda-show-svg ()
    (let* ((case-fold-search nil)
	   (keywords (mapcar #'svg-tag--build-keywords svg-tag--active-tags))
	   (keyword (car keywords)))
      (while keyword
	(save-excursion
	  (while (re-search-forward (nth 0 keyword) nil t)
	    (overlay-put (make-overlay
			  (match-beginning 0) (match-end 0))
			 'display  (nth 3 (eval (nth 2 keyword)))) ))
	(pop keywords)
	(setq keyword (car keywords)))))
  (setq svg-tag-tags
	'(("TODO" . ((lambda (tag) (svg-tag-make tag :face '(:foreground "IndianRed" :weight bold) :inverse t))))
	  ("NEXT" . ((lambda (tag) (svg-tag-make tag :face '(:foreground "#007acc" :weight bold) :inverse t))))
	  ("WAIT" . ((lambda (tag) (svg-tag-make tag :face '(:foreground "GoldenRod" :weight bold) :inverse t))))
	  ("PROJ" . ((lambda (tag) (svg-tag-make tag :face '(:foreground "DarkMagenta" :weight bold) :inverse t))))
	  ("LOOP" . ((lambda (tag) (svg-tag-make tag :face '(:foreground "Salmon" :weight bold) :inverse t))))
	  ("SMDY" . ((lambda (tag) (svg-tag-make tag :face '(:foreground "MediumTurquoise" :weight bold) :inverse t))))
	  ("CANC" . ((lambda (tag) (svg-tag-make tag :face '(:foreground "DarkGrey" :weight bold :strike-through t) :inverse t))))
	  ("DONE" . ((lambda (tag) (svg-tag-make tag :face '(:foreground "DarkSeaGreen" :weight bold :strike-through t) :inverse t))))
	  ("\\[#A\\]" . ((lambda (tag) (svg-tag-make "(󰄿)" :face '(:foreground "IndianRed" :weight bold) :inverse t))))
	  ("\\[#B\\]" . ((lambda (tag) (svg-tag-make "(󰅃)" :face '(:foreground "DarkOrange" :weight bold) :inverse t))))
	  ("\\[#C\\]" . ((lambda (tag) (svg-tag-make "(󰅀)" :face '(:foreground "Grey" :weight bold) :inverse t))))
	  ;; (":\\([@A-Za-z0-9]+\\)" . ((lambda (tag) (svg-tag-make tag))))
	  ;; (":\\([@A-Za-z0-9]+[ \-]\\)" . ((lambda (tag) tag)))
	  ))
  (add-hook 'org-agenda-finalize-hook #'org-agenda-show-svg)
  )

And here is the result:
Screenshot_20231001_114208

Variable containing underscore displayed like subscript.

My current workaround is:

(setq org-use-sub-superscripts "{}")

But seems like this shouldn't happen.

Requires: emacs-27.1, svg-lib-0.3 (not available)

Package svg-tag-mode is incompatible.

     Status: Incompatible because it depends on uninstallable packages.
    Archive: Melpa
    Version: 20211228.1848
     Commit: fcfead5e98e6d8c246d24504a625566b7b62b9f6
    Summary: Replace keywords with SVG tags
   Requires: emacs-27.1, svg-lib-0.3 (not available)
Package svg-lib is available.

     Status: Available from Gnu -- Install
    Archive: Gnu
    Version: 0.2.4
    Summary: SVG tags, progress bars & icons

svg-tag for begin_src destroy the font lock in emacs 29

Hello,

I recently updated to emacs 29.1 (GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.8)) and I noticed that svg-tag seemd to conflict with org font-lock in my config.

Here is a minimal reproduction example:

init.el

(setq straight-use-package-by-default t)

(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 6))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

(setq straight-use-package-by-default t)

(use-package svg-tag-mode)

(setq svg-tag-tags
      `(
         ;; source block from notebook-mode
 ("^#\\+begin_src\\( [a-zA-Z\-]+\\)" .  ((lambda (tag)
                                                  (svg-tag-make (upcase tag)
                                                                :face 'org-meta-line
                                                                :crop-left t))))
)
)

(add-hook 'text-mode-hook 'svg-tag-mode)

And then the file test.org

* Test
#+begin_src emacs-lisp
(message "Hello world")
#+end_src

#+RESULTS:
: Hello world

appears like this with svg-tag:

image

and like this if I have no svg-tag activated (which is equivalent to what I have with emacs -q)

image

This happens only with this src tag that worked well before the update to emacs 29, I also have a TODO svg-tag in my config and this one works well.

This may be linked with #47 as I have the same

Error during redisplay: (jit-lock-function 1) signaled (wrong-type-argument stringp nil)

poping up in the messages buffer.

SVG rendering issue when svg-tag-mode is installed

I am using Emacs 27.2 on Arch Linux with Doom Emacs configuration. Normally Emacs can render SVG just fine for me, Evaluating (image-type-available-p 'svg) returns t. But when I install svg-tag-mode, Emacs seems to be unable to render SVG.

Here is an example when svg-tag-mode is on:
Screenshot_20211231_223758

For comparison, when svg-tag-mode is off:
Screenshot_20211231_223721

With svg-tag-mode installed other SVG images, unrelated to the package, are also not rendered.

Some suggestion

Hi,
thanks for this very nice package!
Using SVG makes Emacs more elegant😍

I tried example.el and found some suggestions.

  1. svg-tag-mode.el should have (require 'subr-x) because of string-trim.
  2. Why making 2 rectangles? :stroke and :stroke-widthcan be used for just 1 rectangle. (or you think this is less elegant?)

Thanks.

Error during redisplay: (jit-lock-function 327) signaled (invalid-function (svg-tag-make "FOO"))

On Emacs 29, I get an error when I try and use any tag configuration that includes a function invocation with arguments:

(setq svg-tag-tags
        '(("TODO" . ((svg-tag-make "FOO")))
        ("DONE" . (svg-tag-make))))

The DONE one works, but I can't get the other one to work.

I can work around it by using lambda:

(setq svg-tag-tags
        '(("TODO" . ((lambda (_) (svg-tag-make "FOO"))))
        ("DONE" . (svg-tag-make))))

How to change SVG Colors

In the screenshots in the README, there are different colors for TODO, MEETING, and DONE. I was curious how one can set the color of their SVG's?

SVG On/Off showing on new buffers

Minor nit, but whenever a buffer is loaded, the mode message that SVG is on/off is displayed. While innocuous, I have a program that loads a file and displays a message from a hydra, and the message is overridden.

Most minor modes don't send such a message, so could we remove it? I'll send a PR.

Provide configuration for multiple tags

First of all, thanks for this very useful package.
Since I'm not well versed with regexp, I'm trying to find a way for svg-tag-mode to render correctly multiple tags side by side, e.g. :foo:bar:. I couldn't figure anything out using the examples.

Thanks again for all your hard work!

[Feature Request] Disable tags inside org src blocks

Hi Nicolas,

Thank you for this amazing package. I really like your work on nano-emacs, and cannot seem to go back to anything else!
I have a feature request:

I save large network dumps under src blocks in org mode.
However, if dumps contain ipv6 addresses, they are are converted to svg because there is a rule for converting org tags to svg in svg-tag-tags:
(":\([A-Za-z0-9]+\)" . ((lambda (tag) (svg-tag-make tag))))

I would like to disable making tags inside src blocks. I think it makes sense in general as well.

Thanks

Feature request: allow tag functions to return several tags at once

Right now the function which is called for the regexp should return at maximum only one tag. I would like to request to make it possible to return it list of tags, so one regexp can produce several tags.

Use case is the following. I want to match the whole org-mode tag regexp and transfer every org-mode tag into svg tag. I can match things inside the ":...:", however this leaves me with the ':' signs there. With one function approach, I can match the whole org-mode tag line and generate just a bunch of tags.

Also I could insert a special treatment for each tag in such function. E.g. different tag colors for different org-mode tags.

Wrong sizes on high resolution screens

The math seems to be off on high resolution screens, 3840x2160 in my case. I believe I have also tried this on a 2560x1440 screen without any issues, but it has been a while since I had that hooked up, so I am not quite sure anymore.

20210226-00:44:00

Emacs does some weird calling for high resolutions. Again, I don't remember any details but for my moody package I got the create-image to stop calling by some unknown number by telling it to scale by 1 instead, using (create-image ... :scale 1).

Note that it's not just the font size that is off, there also appear some pixels to be missing at the bottom of images.

Problem with active/inactive date (from example 2)

I tried to use example 2 to fontify date/times in scheduled/deadline items but I get error messages on loading the configuration.

Happens on Emacs 29.1 in both Windows 10 and Ubuntu 22.04.

My (shortened) setup:

;; use svg-tag-mode
(defconst date-re "[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}")
(defconst time-re "[0-9]\\{2\\}:[0-9]\\{2\\}")
(defconst day-re "[A-Za-z]\\{3\\}")
(defconst day-time-re (format "\\(%s\\)? ?\\(%s\\)?" day-re time-re))
(use-package svg-tag-mode
  :config
  (setq svg-tag-tags
      '(
        ;; Task priority
        ("\\[#[A-Z]\\]" . ( (lambda (tag)
                              (svg-tag-make tag :face 'org-priority 
                                            :beg 2 :end -1 :margin 0
					    :height 0.58 :radius 5))))
	
        ;; Active date (with or without day name, with or without time)
        (,(format "\\(<%s>\\)" date-re) .
         ((lambda (tag)
            (svg-tag-make tag :beg 1 :end -1 :margin 0))))
        (,(format "\\(<%s \\)%s>" date-re day-time-re) .
         ((lambda (tag)
            (svg-tag-make tag :beg 1 :inverse nil :crop-right t :margin 0))))
        (,(format "<%s \\(%s>\\)" date-re day-time-re) .
         ((lambda (tag)
            (svg-tag-make tag :end -1 :inverse t :crop-left t :margin 0))))

        ;; Inactive date  (with or without day name, with or without time)
         (,(format "\\(\\[%s\\]\\)" date-re) .
          ((lambda (tag)
             (svg-tag-make tag :beg 1 :end -1 :margin 0 :face 'org-date))))
         (,(format "\\(\\[%s \\)%s\\]" date-re day-time-re) .
         ((lambda (tag)
             (svg-tag-make tag :beg 1 :inverse nil :crop-right t :margin 0 :face 'org-date))))
         (,(format "\\[%s \\(%s\\]\\)" date-re day-time-re) .
          ((lambda (tag)
             (svg-tag-make tag :end -1 :inverse t :crop-left t :margin 0 :face 'org-date))))

	 ))
  ;; fix agenda view
  (defun org-agenda-show-svg ()
    (let* ((case-fold-search nil)
           (keywords (mapcar #'svg-tag--build-keywords svg-tag--active-tags))
           (keyword (car keywords)))
      (while keyword
        (save-excursion
          (while (re-search-forward (nth 0 keyword) nil t)
            (overlay-put (make-overlay
                          (match-beginning 0) (match-end 0))
                         'display  (nth 3 (eval (nth 2 keyword)))) ))
        (pop keywords)
        (setq keyword (car keywords)))))
  (add-hook 'org-agenda-finalize-hook #'org-agenda-show-svg)
  )
(global-svg-tag-mode t)

On initializing Emacs I get the following error message:
Wrong type argument: stringp, (, (format \(<%s>\) date-re))

Any idea what is the issue?

Causing issues with emacs-dashboard

I am using emacs-dashboard and for some reason it won't display an image I have (global-svg-tag-mode 1) in my init.

A workaround I am using is the below snippet to start it up in org and programming mode.

(add-hook 'prog-mode-hook 'svg-tag-mode)
(add-hook 'org-mode-hook 'svg-tag-mode)

destructive influence of possible recent updates of either org-mode or svg-tag-mode

Salut Nicolás,

As I have pointed out in April 2023 (cf. #41 (comment)) I am using notebook-mode/svg-tag-mode in some of my org documents (under doom emacs), i.e., "notebook-mode"

A recent upgrade/update/change of either org-mode (9.7) or svg-tag-mode had a strange destructive impact on my org notebooks.

The svg-tags are only rendered partially, i.e. the further one goes down the lesser the number of rendered svg-tags.

Let's say, rendering of svg-tags stops somewhere in the middle of an org file and in addition some tags are rendered further down whereas "#+begin_src" tags stop being rendered somewere at the beginning.... (I suspected that the presence of inline-images is responsible for that - but after testing - I think, it isn't)

I either have an org document perfectly colored depending on the text properties (section, programming language, tags) or I have partly rendered org files without some colored elements beginning somewhere ...
Unfortunately i was not able to find out where org-mode breaks. (switching on org-mode again renders a perfect document, but all rendered svg-tags vanish)

What I have noticed is, that switching on svg-tag-mode always shows errors:

Error during redisplay: (jit-lock-function 5959) signaled (wrong-type-argument stringp nil)
Error during redisplay: (jit-lock-function 7795) signaled (wrong-type-argument stringp nil)
Error during redisplay: (jit-lock-function 9338) signaled (wrong-type-argument stringp nil)
Error during redisplay: (jit-lock-function 4763) signaled (wrong-type-argument stringp nil)

I have tried turning jit-lock-debug-mode on and off to no avail.

Do you have a slightest glimpse of what's going on here and what could be a possible solution/workaround.

I'm on (doom)emacs 28.2, org-mode 9.7 (i have reinstalled emacs in different versions 28.1, 28.2, ...) always the same effect.

Best regards and many thanks in advance,
-.w.p.-

Can't launch `svg-tag-mode` when emacs is built from source

I have Emacs built from source (version 29.05) and was able to install svg-tag-mode just fine but when trying to launch it with svg-tag-mode I get an error that the command doesn't exist. I have killed emacs and restarted it but it still isn't showing. When I go into list-packages it shows svg-tag-mode as installed. A similar thing happened with another package of yours svg-lib. I can make the same issue on there but figured it was probably the same underlying issue?

Below are the example tags I have set up.

(setq svg-tag-tags
      '((":TODO:" . ((lambda (tag) (svg-tag-make "TODO"))))))

(setq svg-tag-tags
      '((":WIP:" . ((lambda (tag) (svg-tag-make "WIP"))))))

(setq svg-tag-tags
      '((":DONE:" . ((lambda (tag) (svg-tag-make "DONE"))))))

Problem while editing time and date tags in org mode

While using svg-tag-mode with org-mode, if there is:
(setq svg-tag-action-at-point 'edit)
and a tag is defined to cover org-mode date the editing experience is strange as it is shown below,
just before entering the tag:
image
after:
image

If you set svg-tag-action-at-point to 'echo you could see that the tag length is not identified properly, it is: [2024-02-06 Tue instead of [2024-02-06 Tue]. It guess it might be because of the way how svg-tag--cursor-function identifies the end of the tag by using next-property-change.

Bug :: This mode breaks `xwidget-webkit-browse-url`

Here is how to reproduce the issue.

;; C-x C-e ⇒ Works as expected
(xwidget-webkit-browse-url "www.google.ca")
;; Now kill the resulting buffer.

;; Evaluate this.
(global-svg-tag-mode)

;; C-x C-e ⇒ Busted!
(xwidget-webkit-browse-url "www.google.ca")

Otherwise, a great package!

What is the correct regexp for ~something~ in Org Mode?

I'm trying to create a regexp which would match the following sentences:

~sentence-without-space123~
~sentence- without-space123~

This is definition I have:

(setq svg-tags
        '(("\\(\~[0-9a-zA-Z]+\~\\)" 1
           `(face nil display ,(svg-tag-keyboard (match-string 0))))))

It seems to me that regex is correct, therefore I'm not quite sure whether it's issue in org-mode or svg-tag. (Or maybe regexp is incorrect)

Anyway I would be highly grateful for any help.

Not working with doom emacs

Hey Nicolas,

thank you for sharing this great package!

Unfortunately it seems to clash with the doom emacs distribution.
When i evaluate example-2.el i get the following result:

image

I am using GNU Emacs 27.1 with the latest release form the doom develop branch.

Pleas let me know if i can provide you any further information to tackle this issue.

Have a nice day,
Marcel

Font size messed up

I am trying to get svg-tags set up with org mode (using org-modern and doom emacs). However, I am having some issues. Here is what the tags look like:

image

I have looked through some of the other issues (mostly #12 and #10) and I have tried using the fork from PR #14, with no success. I am wondering if there is anything obvious that I am missing?

Unable to view SVG images properly

There is a prerequisite which I think I don't have on my machine. Also, I think I don't have proper Unicode support for special characters. Do you know how to enable it? For example, I am not able to display 🚀 character in terminal and in Emacs.

Arch Linux
Emacs 28.0.50
system-configuration-features value is "XPM JPEG TIFF GIF PNG RSVG CAIRO IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY ACL GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON PDUMPER LCMS2"

The issue is described here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.