Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A minor mode for Emacs that replace keywords with nice SVG labels

License

NotificationsYou must be signed in to change notification settings

rougier/svg-tag-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Usage example

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

  • KEYWORD is a regular expression including a matched group ofthe form\\(xxx\\). If this is not the case the wholestring 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 stringargument (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 overthe tag. It can be nil if no command is associated with the tag.

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

  1. Replace any occurrence of:TODO: with a static SVG tag displayingTODO
(setq svg-tag-tags'((":TODO:". ((lambda (tag) (svg-tag-make"TODO"))))))
  1. Replace any occurrence of:HELLO: with a static SVG tag displayingHELLO that can be clicked to execute the specified command. Helpmessage 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 displayingTODO
(setq svg-tag-tags'((":TODO:". ((lambda (tag)                       (svg-tag-make tag:beg1:end-1))))))
  1. Replaces any occurrence of:XXX: with a dynamic SVG tag displayingXXX
(setq svg-tag-tags'(("\\(:[A-Z]+:\\)". ((lambda (tag)                               (svg-tag-make tag:beg1:end-1))))))
  1. Replaces any occurrence of:XXX|YYY: with two adjacent dynamic SVGtags displayingXXX andYYY
(setq svg-tag-tags'(("\\(:[A-Z]+\\)\|[a-zA-Z#0-9]+:". ((lambda (tag)                                           (svg-tag-make tag:beg1:inverset:margin0:crop-rightt))))        (":[A-Z]+\\(\|[a-zA-Z#0-9]+:\\)". ((lambda (tag)                                           (svg-tag-make tag:beg1:end-1:margin0:crop-leftt))))))
  1. This replaces any occurrence of:#TAG1:#TAG2:…:$ ($ means end ofline) with a dynamic collection of SVG tags. Note the# symbol infront of tags. This is mandatory because Emacs cannot do regex lookahead.
(setq svg-tag-tags'(("\\(:#[A-Za-z0-9]+\\)". ((lambda (tag)                                     (svg-tag-make tag:beg2))))        ("\\(:#[A-Za-z0-9]+:\\)$". ((lambda (tag)                                       (svg-tag-make tag:beg2:end-1))))))

Known Problems

SVG tags cannot render in org-agenda

Asissue #27 mentioned, SVG tags cannot render in org-agenda, becausesvg-tag-mode usesfont-lock-mode to show SVG tags. However,org-agendadoes not usefont-lock-mode, so it only shows rendered SVG tags in visitedbuffers. 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)

About

A minor mode for Emacs that replace keywords with nice SVG labels

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp