From b11adad984e8160e366d7e154d12c378a9545b9a Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 13 Dec 2021 10:29:50 -0600 Subject: Lots of changes, most interestingly browse-url stuff --- lisp/+org.el | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'lisp/+org.el') diff --git a/lisp/+org.el b/lisp/+org.el index a4ce230..9a91ef1 100644 --- a/lisp/+org.el +++ b/lisp/+org.el @@ -337,5 +337,60 @@ the deletion might narrow the column." (backward-delete-char-untabify N) (org-fix-tags-on-the-fly)))) +;;; Smarter {super,sub}scripts +;; https://old.reddit.com/r/emacs/comments/qzlzm0/what_are_your_top_key_bindings_rebindings_minor/hmwyhm3/ +;; I don't use this currently because I found out about +;; `org-pretty-entities-include-sub-superscripts', which really does exactly +;; what I wanted. + +(defface +org-script-markers '((t :inherit shadow)) + "Face to be used for sub/superscripts markers i.e., ^, _, {, }.") + +;; Hiding the super and subscript markers is extremely annoying +;; since any remotely complex equation becomes a chore. And leaving +;; it not raised is jarring to the eye. So this fontifies the +;; buffer just like how auctex does -- use a muted colour to +;; highlight the markup and raise the script. +(defun +org-raise-scripts (limit) + "Differences from `org-raise-scripts' are: + +- It doesn't actually hide the markup used for super and subscript. +- It uses a custom face to highlight the markup: +org-script-markers. +- It doesn't require `org-pretty-entities' to be t." + (when (and org-pretty-entities-include-sub-superscripts + (re-search-forward + (if (eq org-use-sub-superscripts t) + org-match-substring-regexp + org-match-substring-with-braces-regexp) + limit t)) + (let* ((pos (point)) table-p comment-p + (mpos (match-beginning 3)) + (emph-p (get-text-property mpos 'org-emphasis)) + (link-p (get-text-property mpos 'mouse-face)) + (keyw-p (eq 'org-special-keyword (get-text-property mpos 'face)))) + (goto-char (point-at-bol)) + (setq table-p (looking-at-p org-table-dataline-regexp) + comment-p (looking-at-p "^[ \t]*#[ +]")) + (goto-char pos) + ;; Handle a_b^c + (when (member (char-after) '(?_ ?^)) (goto-char (1- pos))) + (unless (or comment-p emph-p link-p keyw-p) + (put-text-property (match-beginning 3) (match-end 0) + 'display + (if (equal (char-after (match-beginning 2)) ?^) + ;; (nth (if table-p 3 1) org-script-display) + (nth 3 org-script-display) + ;; (nth (if table-p 2 0) org-script-display) + (nth 2 org-script-display))) + (put-text-property (match-beginning 2) (match-end 2) + 'face 'vz/org-script-markers) + (when (and (eq (char-after (match-beginning 3)) ?{) + (eq (char-before (match-end 3)) ?})) + (put-text-property (match-beginning 3) (1+ (match-beginning 3)) + 'face '+org-script-markers) + (put-text-property (1- (match-end 3)) (match-end 3) + 'face '+org-script-markers))) + t))) + (provide '+org) ;;; +org.el ends here -- cgit 1.4.1-21-gabe81