fix(org): address fancy links regressions

- several all-the-icons references were missed, and some code points are
  different in nerd-fonts. the variable icon became a folder, the
  package icon became a scissors, and the file-icons font icon is not
  available
- make face link type face passthrough work
- remove extraneous rear-nonsticky and height properties that nerd-icons
  already sets
- generally improve consistency across link types
  - material design icons, underlines, and font lock faces for symbols,
    shadow if unbound
  - octicons for packages, modules, and executables, blue links if
    installed, shadow if not. color coded icon based on status
  - refactor and remove extraneous code
This commit is contained in:
Liam Hupfer 2023-09-19 22:07:11 -05:00 committed by Henrik Lissner
parent c3342a8011
commit 2279a42c50
2 changed files with 41 additions and 74 deletions

View file

@ -98,17 +98,14 @@ exist, and `org-link' otherwise."
(when buffer-read-only (when buffer-read-only
(add-text-properties (add-text-properties
start end start end
(list 'display (list
(concat 'display
#("" 0 1 (concat (nerd-icons-mdicon "nf-md-toggle_switch") ; "󰔡"
(rear-nonsticky " " (propertize var
t display (raise 0.05) 'face
face (:family "github-octicons" (if (boundp (intern var))
:inherit font-lock-variable-name-face 'font-lock-variable-name-face
:height 0.8 'shadow)))))))
:box (:line-width 1 :style none)))
1 2 (face (:height 0.2)))
var)))))
;;;###autoload ;;;###autoload
(defun +org-link--fn-link-activate-fn (start end fn _bracketed-p) (defun +org-link--fn-link-activate-fn (start end fn _bracketed-p)
@ -116,12 +113,12 @@ exist, and `org-link' otherwise."
(add-text-properties (add-text-properties
start end start end
(list 'display (list 'display
(concat (concat (nerd-icons-mdicon "nf-md-function") ; "󰊕"
#("λ " 0 1 (face (:inherit font-lock-function-name-face " " (propertize fn
:box (:line-width 1 :style none) 'face
:height 0.9)) (if (fboundp (intern fn))
1 2 (face (:height 0.2))) 'font-lock-function-name-face
fn))))) 'shadow)))))))
;;;###autoload ;;;###autoload
(defun +org-link--face-link-activate-fn (start end face _bracketed-p) (defun +org-link--face-link-activate-fn (start end face _bracketed-p)
@ -129,18 +126,12 @@ exist, and `org-link' otherwise."
(add-text-properties (add-text-properties
start end start end
(list 'display (list 'display
(concat (concat (nerd-icons-mdicon "nf-md-format_text") ; "󰊄"
(propertize " " (propertize face
"" 'face
'rear-nonsticky t
'display '(raise -0.02)
'face (list '(:family "file-icons" :height 1.0)
(if (facep (intern face)) (if (facep (intern face))
(intern face) (intern face)
'default) 'shadow)))))))
'(:underline nil)))
#(" " 0 1 (face (:underline nil)))
face)))))
(defun +org-link--command-keys (command) (defun +org-link--command-keys (command)
"Convert command reference TEXT to key binding representation." "Convert command reference TEXT to key binding representation."
@ -182,51 +173,37 @@ exist, and `org-link' otherwise."
(org-show-entry) (org-show-entry)
(recenter))))) (recenter)))))
;;;###autoload
(defun +org-link--doom-module-link-face-fn (module-path)
(cl-destructuring-bind (&key category module flag)
(+org-link--read-module-spec module-path)
(if (and category (doom-module-locate-path category module))
`(:inherit org-priority
:weight bold)
'error)))
;;;###autoload ;;;###autoload
(defun +org-link--doom-module-link-activate-fn (start end module-path _bracketed-p) (defun +org-link--doom-module-link-activate-fn (start end module-path _bracketed-p)
(when buffer-read-only (when buffer-read-only
(cl-destructuring-bind (&key category module flag) (cl-destructuring-bind (&key category module flag)
(+org-link--read-module-spec module-path) (+org-link--read-module-spec module-path)
(let ((overall-face (let ((overall-face
(cond (if (and category (doom-module-locate-path category module))
((doom-module-p category module flag) '((:underline nil) org-link org-block bold)
'((:underline nil) org-link org-block bold)) '(shadow org-block bold)))
((and category (doom-module-locate-path category module))
'(shadow org-block bold))
(t '((:strike-through t) error org-block))))
(icon-face (icon-face
(if (doom-module-p category module flag) 'success 'error))) (cond
((doom-module-p category module flag) 'success)
((and category (doom-module-locate-path category module)) 'warning)
(t 'error))))
(add-text-properties (add-text-properties
start end start end
(list 'face overall-face (list 'face overall-face
'display 'display
(concat (concat
(propertize (nerd-icons-octicon "nf-oct-stack" ; ""
"" :face icon-face)
'rear-nonsticky t " " module-path)))))))
'display '(raise -0.02)
'face `(:inherit ,icon-face
:family "FontAwesome"
:height 1.0))
module-path)))))))
;;;###autoload ;;;###autoload
(defun +org-link--doom-package-link-activate-fn (start end package _bracketed-p) (defun +org-link--doom-package-link-activate-fn (start end package _bracketed-p)
(when buffer-read-only (when buffer-read-only
(let ((overall-face (let ((overall-face
(if (locate-library package) (if (locate-library package)
'((:underline nil) org-link org-block italic) '((:underline nil :weight regular) org-link org-block italic)
'(shadow org-block italic))) '(shadow org-block italic)))
(pkg-face (icon-face
(cond (cond
((featurep (intern package)) 'success) ((featurep (intern package)) 'success)
((locate-library package) 'warning) ((locate-library package) 'warning)
@ -236,12 +213,8 @@ exist, and `org-link' otherwise."
(list 'face overall-face (list 'face overall-face
'display 'display
(concat (concat
(propertize (nerd-icons-octicon "nf-oct-package" ; ""
"\uf0c4" ; Octicon package symbol :face icon-face)
'rear-nonsticky t
'display '(raise -0.02)
'face `(:family "github-octicons" :height 1.0
:inherit ,pkg-face))
" " package)))))) " " package))))))
;;;###autoload ;;;###autoload
@ -257,15 +230,11 @@ exist, and `org-link' otherwise."
start end start end
(list 'display (list 'display
(concat (concat
(nerd-icons-devicon "nf-dev-terminal_badge" (nerd-icons-octicon "nf-oct-terminal" ; ""
:rear-nonsticky t :face (if found 'success 'error))
:display '(raise -0.02)
:face (list :height 1.0
:inherit (if found 'success 'error)))
" " " "
(propertize (propertize executable
executable 'face (if found 'org-verbatim 'shadow))))))))
'face (if found 'org-verbatim 'default))))))))
;; ;;
;;; Help-echo / eldoc ;;; Help-echo / eldoc

View file

@ -548,12 +548,12 @@ relative to `org-directory', unless it is an absolute path."
"var" "var"
:follow (-call-interactively #'helpful-variable) :follow (-call-interactively #'helpful-variable)
:activate-func #'+org-link--var-link-activate-fn :activate-func #'+org-link--var-link-activate-fn
:face 'org-code) :face '(font-lock-variable-name-face underline))
(org-link-set-parameters (org-link-set-parameters
"fn" "fn"
:follow (-call-interactively #'helpful-callable) :follow (-call-interactively #'helpful-callable)
:activate-func #'+org-link--fn-link-activate-fn :activate-func #'+org-link--fn-link-activate-fn
:face 'org-code) :face '(font-lock-function-name-face underline))
(org-link-set-parameters (org-link-set-parameters
"face" "face"
:follow (-call-interactively #'describe-face) :follow (-call-interactively #'describe-face)
@ -569,13 +569,11 @@ relative to `org-directory', unless it is an absolute path."
"doom-package" "doom-package"
:follow #'+org-link--doom-package-link-follow-fn :follow #'+org-link--doom-package-link-follow-fn
:activate-func #'+org-link--doom-package-link-activate-fn :activate-func #'+org-link--doom-package-link-activate-fn
:face (lambda (_) '(:inherit org-priority :slant italic))
:help-echo #'+org-link-doom--help-echo-from-textprop) :help-echo #'+org-link-doom--help-echo-from-textprop)
(org-link-set-parameters (org-link-set-parameters
"doom-module" "doom-module"
:follow #'+org-link--doom-module-link-follow-fn :follow #'+org-link--doom-module-link-follow-fn
:activate-func #'+org-link--doom-module-link-activate-fn :activate-func #'+org-link--doom-module-link-activate-fn
:face #'+org-link--doom-module-link-face-fn
:help-echo #'+org-link-doom--help-echo-from-textprop) :help-echo #'+org-link-doom--help-echo-from-textprop)
(org-link-set-parameters (org-link-set-parameters
"doom-executable" "doom-executable"
@ -614,7 +612,7 @@ relative to `org-directory', unless it is an absolute path."
(format "https://github.com/%s" (format "https://github.com/%s"
(string-remove-prefix (string-remove-prefix
"@" (+org-link-read-desc-at-point link))))) "@" (+org-link-read-desc-at-point link)))))
:face (lambda (_) 'org-priority)) :face 'org-priority)
(org-link-set-parameters (org-link-set-parameters
"doom-changelog" "doom-changelog"
:follow (lambda (link) :follow (lambda (link)