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

View file

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