Last active
June 9, 2023 03:08
-
-
Save orangeclover/9867a858ac046acb85d4b420461f3b03 to your computer and use it in GitHub Desktop.
Org Mode でリンク種別に応じたプレフィクスを表示する 検証用
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (require 'org) | |
| (defconst toncs-org-link-prefixes '(("id" . "🦄") | |
| ("roam" . "🦄") | |
| ("attachment" . "📎") | |
| ("file" . "💾") | |
| ("file+sys" . "💾") | |
| ("file+emacs" . "🗒") | |
| ("shell" . "💻") | |
| ("https" . "🌐") | |
| ("http" . "🌐") | |
| ("help" . "❓") | |
| ("info" . "ℹ") | |
| ("elisp" . "⚡"))) | |
| (defun toncs-org-link-on-modification (ov changed _start _end &optional _len) | |
| (when changed (delete-overlay ov))) | |
| (defun toncs-org-link-activate (type start end bracketp) | |
| (remove-overlays start end 'org-link-prefix t) | |
| (when (and org-link-descriptive bracketp) | |
| (let* ((prefix (or (when-let ((found (cdr-safe (assoc-string type toncs-org-link-prefixes)))) | |
| (format "%s " found)) | |
| (format "%s:" (upcase type)))) | |
| (ov (make-overlay start end)) | |
| (props `((org-link-prefix . t) | |
| (before-string . ,prefix) | |
| (evaporate . t) | |
| (modification-hooks . ,(list #'toncs-org-link-on-modification)) | |
| (insert-in-front-hooks . ,(list #'toncs-org-link-on-modification))))) | |
| (dolist (prop props) | |
| (overlay-put ov (car prop) (cdr prop)))))) | |
| (defun toncs-config-org-link () | |
| (dolist (type (org-link-types)) | |
| (org-link-set-parameters type | |
| :activate-func | |
| (lambda (start end _path bracketp) | |
| (toncs-org-link-activate type start end bracketp))))) | |
| (toncs-config-org-link) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (require 'org) | |
| (defconst toncs-org-link-prefixes '(("id" . "午") | |
| ("roam" . "午") | |
| ("attachment" . "添") | |
| ("file" . "書") | |
| ("file+sys" . "書") | |
| ("file+emacs" . "書") | |
| ("shell" . "貝") | |
| ("https" . "安") | |
| ("http" . "超") | |
| ("help" . "助") | |
| ("info" . "情") | |
| ("elisp" . "E"))) | |
| (defun toncs-org-link-on-modification (ov changed _start _end &optional _len) | |
| (when changed (delete-overlay ov))) | |
| (defun toncs-org-link-activate (type start end bracketp) | |
| (remove-overlays start end 'org-link-prefix t) | |
| (when (and org-link-descriptive bracketp) | |
| (let* ((prefix (or (when-let ((found (cdr-safe (assoc-string type toncs-org-link-prefixes)))) | |
| (format "%s " found)) | |
| (format "%s:" (upcase type)))) | |
| (ov (make-overlay start end)) | |
| (props `((org-link-prefix . t) | |
| (before-string . ,prefix) | |
| (evaporate . t) | |
| (modification-hooks . ,(list #'toncs-org-link-on-modification)) | |
| (insert-in-front-hooks . ,(list #'toncs-org-link-on-modification))))) | |
| (dolist (prop props) | |
| (overlay-put ov (car prop) (cdr prop)))))) | |
| (defun toncs-config-org-link () | |
| (dolist (type (org-link-types)) | |
| (org-link-set-parameters type | |
| :activate-func | |
| (lambda (start end _path bracketp) | |
| (toncs-org-link-activate type start end bracketp))))) | |
| (toncs-config-org-link) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| emacs-28.2\bin\runemacs.exe -q -l C:\Users\orangeclover\Desktop\org-link-prefixes-init.el | |
| emacs-28.2\bin\runemacs.exe -q -l C:\Users\orangeclover\Desktop\org-link-prefixes-init2.el |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (org-version) | |
| "9.5.5" | |
| (emacs-version) | |
| "GNU Emacs 28.2 (build 2, x86_64-w64-mingw32) | |
| of 2022-09-14" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment