summary refs log tree commit diff stats
path: root/lisp/+org.el
diff options
context:
space:
mode:
authorCase Duckworth2021-12-13 10:29:50 -0600
committerCase Duckworth2021-12-13 10:29:50 -0600
commitb11adad984e8160e366d7e154d12c378a9545b9a (patch)
tree72c23feb56d4d05107ac8285537429786efcda0d /lisp/+org.el
parentMostley add +key.el (but of course other stuff) (diff)
downloademacs-b11adad984e8160e366d7e154d12c378a9545b9a.tar.gz
emacs-b11adad984e8160e366d7e154d12c378a9545b9a.zip
Lots of changes, most interestingly browse-url stuff
Diffstat (limited to 'lisp/+org.el')
-rw-r--r--lisp/+org.el55
1 files changed, 55 insertions, 0 deletions
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."
337 (backward-delete-char-untabify N) 337 (backward-delete-char-untabify N)
338 (org-fix-tags-on-the-fly)))) 338 (org-fix-tags-on-the-fly))))
339 339
340;;; Smarter {super,sub}scripts
341;; https://old.reddit.com/r/emacs/comments/qzlzm0/what_are_your_top_key_bindings_rebindings_minor/hmwyhm3/
342;; I don't use this currently because I found out about
343;; `org-pretty-entities-include-sub-superscripts', which really does exactly
344;; what I wanted.
345
346(defface +org-script-markers '((t :inherit shadow))
347 "Face to be used for sub/superscripts markers i.e., ^, _, {, }.")
348
349;; Hiding the super and subscript markers is extremely annoying
350;; since any remotely complex equation becomes a chore. And leaving
351;; it not raised is jarring to the eye. So this fontifies the
352;; buffer just like how auctex does -- use a muted colour to
353;; highlight the markup and raise the script.
354(defun +org-raise-scripts (limit)
355 "Differences from `org-raise-scripts' are:
356
357- It doesn't actually hide the markup used for super and subscript.
358- It uses a custom face to highlight the markup: +org-script-markers.
359- It doesn't require `org-pretty-entities' to be t."
360 (when (and org-pretty-entities-include-sub-superscripts
361 (re-search-forward
362 (if (eq org-use-sub-superscripts t)
363 org-match-substring-regexp
364 org-match-substring-with-braces-regexp)
365 limit t))
366 (let* ((pos (point)) table-p comment-p
367 (mpos (match-beginning 3))
368 (emph-p (get-text-property mpos 'org-emphasis))
369 (link-p (get-text-property mpos 'mouse-face))
370 (keyw-p (eq 'org-special-keyword (get-text-property mpos 'face))))
371 (goto-char (point-at-bol))
372 (setq table-p (looking-at-p org-table-dataline-regexp)
373 comment-p (looking-at-p "^[ \t]*#[ +]"))
374 (goto-char pos)
375 ;; Handle a_b^c
376 (when (member (char-after) '(?_ ?^)) (goto-char (1- pos)))
377 (unless (or comment-p emph-p link-p keyw-p)
378 (put-text-property (match-beginning 3) (match-end 0)
379 'display
380 (if (equal (char-after (match-beginning 2)) ?^)
381 ;; (nth (if table-p 3 1) org-script-display)
382 (nth 3 org-script-display)
383 ;; (nth (if table-p 2 0) org-script-display)
384 (nth 2 org-script-display)))
385 (put-text-property (match-beginning 2) (match-end 2)
386 'face 'vz/org-script-markers)
387 (when (and (eq (char-after (match-beginning 3)) ?{)
388 (eq (char-before (match-end 3)) ?}))
389 (put-text-property (match-beginning 3) (1+ (match-beginning 3))
390 'face '+org-script-markers)
391 (put-text-property (1- (match-end 3)) (match-end 3)
392 'face '+org-script-markers)))
393 t)))
394
340(provide '+org) 395(provide '+org)
341;;; +org.el ends here 396;;; +org.el ends here