如何安装svg-tag-mode?

svg-tag-mode按照如下设置org mode 没有任何改变?

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

org-mode 里的 TODO 正则用 “TODO” 就好了,可以参考仓库里的例子:

我用下面的配置:

(require 'svg-tag-mode)
(add-hook 'org-mode-hook (lambda ()
                               (make-local-variable 'font-lock-extra-managed-props)
                               (svg-tag-mode)))
(setq svg-tag-tags
      '((":TODO:" . ((svg-tag-make "TODO" :face 'org-tag
                                   :radius 0 :inverse t :margin 0)))
        (":NOTE:" . ((svg-tag-make "NOTE" :face 'font-lock-comment-face
                                   :inverse nil :margin 0 :radius 0)))
        ("\([0-9a-zA-Z]\)" . ((lambda (tag)
                                (svg-tag-make tag :beg 1 :end -1 :radius 12))))
        ("\([0-9a-zA-Z][0-9a-zA-Z]\)" . ((lambda (tag)
                                           (svg-tag-make tag :beg 1 :end -1 :radius 8))))
        ("|[0-9a-zA-Z- ]+?|" . ((lambda (tag)
                                  (svg-tag-make tag :face 'font-lock-comment-face
                                                :margin 0 :beg 1 :end -1))))))
(svg-tag-mode t)

没有出现示例的效果?电脑系统是mac ,org:9.5.3. 出现的错误提示:File mode specification error: (error svg-lib.el requires Emacs to be compiled with svg support. )

看来你的 emacs 版本不支持显示 svg,需要切换个支持的

我的emacs 是28.1版,需要哪个版本才能支持?

你的变量 system-configuration-features 里有 RSVG 吗?

我的显示如下: system-configuration-options is a variable defined in ‘C source code’.

Its value is “–with-ns ‘–enable-locallisppath=/Library/Application Support/Emacs/${version}/site-lisp:/Library/Application Support/Emacs/site-lisp’ --with-modules”

system-configuration-features

不好意思,输错了。确实没有RSVG system-configuration-features is a variable defined in ‘src/emacs.c’.

Its value is “ACL GMP GNUTLS JSON LIBXML2 MODULES NOTIFY KQUEUE NS PDUMPER THREADS TOOLKIT_SCROLL_BARS ZLIB”

怎么样才能支持 RSVG

mac 上面我不是很懂, 可能需要下载librsvg,然后重新编译

brew tap railwaycat/emacsmacport
brew install emacs-mac --with-rsvg 

我的emacs 是用 Emacs for Mac OS X 安装的。不重新编译的话,可以安装rsvg 么?

不可以,需要重新编译

我参照你的设置文件, 在添加如下代码后:SVG-tag-mode 的效果显示不出来?如果不加下面的代码是有效果的。RSVG已经有了。

   ;; 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 :ascent 14))))    ;;

请检查自己的配置,或者提供详细信息

代码如下:

(use-package svg-tag-mode
  :init
  (setq svg-lib-style-default
        '(:background "#F5F5F5" :foreground "#37474f" :padding 1 :margin 0
                      :stroke 2 :radius 5 :alignment 0.5 :width 20 :height 0.9
                      :scale 0.75 :ascent center :crop-left nil :crop-right nil
                      :collection "material" :font-family "Cascadia Mono"
                      :font-size 11 :font-weight regular))
  (setq svg-tag-action-at-point 'edit)
  (setq svg-lib-icon-collections
        '(("bootstrap" .
           "https://icons.getbootstrap.com/assets/icons/%s.svg")
          ("simple" .
           "https://raw.githubusercontent.com/simple-icons/simple-icons/develop/icons/%s.svg")
          ("material" .
           "https://raw.githubusercontent.com/Templarian/MaterialDesign/master/svg/%s.svg")
          ("octicons" .
           "https://raw.githubusercontent.com/primer/octicons/master/icons/%s-24.svg")
          ("boxicons" .
           "https://boxicons.com/static/img/svg/regular/bx-%s.svg")))
 (defun svg-lib-tag (label &optional style &rest args)
    "Create an image displaying LABEL in a rounded box using given STYLE
and style elements ARGS."

    (let* ((default svg-lib-style-default)
           (style (if style (apply #'svg-lib-style nil style) default))
           (style (if args  (apply #'svg-lib-style style args) style))

           (foreground  (plist-get style :foreground))
           (background  (plist-get style :background))

           (crop-left   (plist-get style :crop-left))
           (crop-right  (plist-get style :crop-right))

           (alignment   (plist-get style :alignment))
           (stroke      (plist-get style :stroke))
           ;; (width       (plist-get style :width))
           (height      (plist-get style :height))
           (radius      (plist-get style :radius))
           ;; (scale       (plist-get style :scale))
           (margin      (plist-get style :margin))
           (padding     (plist-get style :padding))
           (font-size   (plist-get style :font-size))
           (font-family (plist-get style :font-family))
           (font-weight (plist-get style :font-weight))
           
           ;; use `fixed-pitch' while in `mixed-pitch-mode'
           (txt-char-width  (window-font-width nil 'fixed-pitch))
           (txt-char-height (window-font-height nil 'fixed-pitch))
           (txt-char-height (if line-spacing
                                (+ txt-char-height line-spacing)
                              txt-char-height))
           (font-info       (font-info (format "%s-%d" font-family font-size)))
           (font-size       (aref font-info 2)) ;; redefine font-size
           ;; (ascent          (aref font-info 8))
           (ascent          (plist-get style :ascent))
           (tag-char-width  (aref font-info 11))
           ;; (tag-char-height (aref font-info 3))
           (tag-width       (* (+ (length label) padding) txt-char-width))
           (tag-height      (* txt-char-height height))

           (svg-width       (+ tag-width (* margin txt-char-width)))
           (svg-height      tag-height)

           (tag-x  (* (- svg-width tag-width)  alignment))
           (text-x (+ tag-x (/ (- tag-width (* (length label) tag-char-width))
                               2)))
           (text-y ascent)

           (tag-x      (if crop-left  (- tag-x     txt-char-width) tag-x))
           (tag-width  (if crop-left  (+ tag-width txt-char-width) tag-width))
           (text-x     (if crop-left  (- text-x (/ stroke 2)) text-x))
           (tag-width  (if crop-right (+ tag-width txt-char-width) tag-width))
           (text-x     (if crop-right (+ text-x (/ stroke 2)) text-x))
           
           (svg (svg-create svg-width svg-height)))

      (if (>= stroke 0.25)
          (svg-rectangle svg tag-x 0 tag-width tag-height
                         :fill foreground :rx radius))
      (svg-rectangle svg (+ tag-x (/ stroke 2.0)) (/ stroke 2.0)
                     (- tag-width stroke) (- tag-height stroke)
                     :fill background :rx (- radius (/ stroke 2.0)))
      (svg-text svg label
                :font-family font-family :font-weight font-weight
                :font-size font-size :fill foreground :x text-x :y  text-y)
      (svg-lib--image svg :ascent 'center)))
 
  (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\\}\\(?: [.+]?\\+[0-9]+[dwmy]\\)?")
  (defconst day-time-re (format "\\(%s\\)? ?\\(%s\\)?" day-re time-re))
  (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 :width 4 :height 0.4
                                      :foreground "#B0BEC5")
                (svg-lib-tag (concat value "%") nil
                             :stroke 0 :margin 0 :foreground "#384d57"
                             :ascent 12))
               :ascent 70 :scale 0.7))
  (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 :width 4 :height 0.4
                                        :foreground "#B0BEC5")
                  (svg-lib-tag value nil
                               :stroke 0 :margin 0 :foreground "#384d57"
                               :ascent 12))
                 :ascent 70 :scale 0.7)))
 
  (setq svg-tag-tags
          '(
           ;; Task priority
            ("\\[#[A-Z]\\]" . ( (lambda (tag)
                                (svg-tag-make tag :face 'org-priority 
                                              :beg 2 :end -1 :margin 0
                                              :height 1.1 :ascent 16))))
             ;; Progress
          ("\\(\\[[0-9]\\{1,3\\}%\\]\\)" . ((lambda (tag)
                                              (svg-progress-percent
                                               (substring tag 1 -2)))))
          ("\\(\\[[0-9]+/[0-9]+\\]\\)" . ((lambda (tag)
                                            (svg-progress-count
                                             (substring tag 1 -1)))))
                    ;; TODO / DONE
          ("TODO" . ((lambda (tag)
                       (svg-tag-make "TODO" :face 'org-todo :inverse t :margin 0
                                     :height 1.1 :ascent 16))))
          ("NEXT" . ((lambda (tag)
                       (svg-tag-make "NEXT" :face 'mindre-keyword :margin 0
                                     :height 1.1 :ascent 16))))
          ("STARTED" . ((lambda (tag)
                          (svg-tag-make "STARTED" :face 'mindre-keyword
                                        :margin 0 :height 1.1 :ascent 16))))
          ("PROJECT" . ((lambda (tag)
                          (svg-tag-make "PROJECT" :face 'mindre-keyword
                                        :margin 0 :height 1.1 :ascent 16))))
          ("DONE" . ((lambda (tag)
                       (svg-tag-make "DONE" :face 'mindre-faded :inverse t
                                     :margin 0 :height 1.1 :ascent 16))))
          ("FIXME" . ((lambda (tag)
                        (svg-tag-make "FIXME" :face 'mindre-critical :margin 0
                                      :height 1.1 :ascent 16))))
                   ;; Citation of the form [cite:@Knuth:1984] 
          ("\\(\\[cite:@[A-Za-z]+:\\)" . ((lambda (tag)
                                            (svg-tag-make tag
                                                          :inverse t
                                                          :beg 7 :end -1
                                                          :crop-right t))))
          ("\\[cite:@[A-Za-z]+:\\([0-9]+\\]\\)" . ((lambda (tag)
                                                     (svg-tag-make
                                                      tag
                                                      :end -1
                                                      :crop-left t))))
          
          
           ;; 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 :ascent 14))))    ;;
        
          
            ))
  (add-hook 'org-mode-hook (lambda ()
                             (make-local-variable 'font-lock-extra-managed-props)
                             (svg-tag-mode)))

  (defun eli-org-agenda-show-svg ()
    (let* ((n 0)
           (case-fold-search nil)
           (keywords (mapcar #'svg-tag--build-keywords svg-tag--active-tags))
           (keyword (nth n 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)))) ))
        (setq n (1+ n))
        (setq keyword (nth n keywords)))))
     (add-hook 'org-agenda-finalize-hook #'eli-org-agenda-show-svg)

  
  :hook org-mode
  )

这里的引号要改成反引号 `

:+1:t2: :+1:t2: :+1:t2: 正解! 框中的文字如何调整到方框的中间?

自己用 :ascent 参数调吧,这每个人不一样的