summaryrefslogtreecommitdiff
path: root/init.org
diff options
context:
space:
mode:
Diffstat (limited to 'init.org')
-rw-r--r--init.org35
1 files changed, 18 insertions, 17 deletions
diff --git a/init.org b/init.org
index f81a0ae..feb6324 100644
--- a/init.org
+++ b/init.org
@@ -288,15 +288,16 @@ headers of source code blocks in =org-mode=. The snippet was taken
from [[https://pank.eu/blog/pretty-babel-src-blocks.html][the blog of Rasmus Pank]] and slightly modified to suit my needs.
#+BEGIN_SRC elisp
-(defvar-local rasmus/org-at-src-begin -1
- "Variable that holds whether last position was a ")
+(defvar-local my/org-at-src-begin -1
+ "Variable that holds whether last position was an org source code block.")
+
(defvar-local my/org-src-begin-regexp
"^[ \t]*#\\+begin_src[ \t]+[^ \f\t\n\r\v]+[ \t]*")
-(defvar rasmus/ob-header-symbol ?☰
+(defvar my/ob-header-symbol ?☰
"Symbol used for babel headers")
-(defun rasmus/org-prettify-src--update ()
+(defun my/org-prettify-src--update ()
(let ((case-fold-search t)
(re my/org-src-begin-regexp)
found)
@@ -308,7 +309,7 @@ from [[https://pank.eu/blog/pretty-babel-src-blocks.html][the blog of Rasmus Pan
(buffer-substring-no-properties (point)
(line-end-position)))))
(when (org-string-nw-p args)
- (let ((new-cell (cons args rasmus/ob-header-symbol)))
+ (let ((new-cell (cons args my/ob-header-symbol)))
(cl-pushnew new-cell prettify-symbols-alist :test #'equal)
(cl-pushnew new-cell found :test #'equal)))))
(setq prettify-symbols-alist
@@ -316,7 +317,7 @@ from [[https://pank.eu/blog/pretty-babel-src-blocks.html][the blog of Rasmus Pan
(cl-set-difference
(cl-remove-if-not
(lambda (elm)
- (eq (cdr elm) rasmus/ob-header-symbol))
+ (eq (cdr elm) my/ob-header-symbol))
prettify-symbols-alist)
found :test #'equal)))
;; Clean up old font-lock-keywords.
@@ -330,41 +331,41 @@ from [[https://pank.eu/blog/pretty-babel-src-blocks.html][the blog of Rasmus Pan
(prettify-symbols-mode -1)
(prettify-symbols-mode +1))))
-(defun rasmus/org-prettify-src ()
+(defun my/org-prettify-src ()
"Hide src options via `prettify-symbols-mode'.
-`prettify-symbols-mode' is used because it has uncollpasing. It's
-may not be efficient."
+`prettify-symbols-mode' is used because expanding is simple. It’s
+not very efficient and maybe should be implemented using overlays."
(let* ((case-fold-search t)
(at-src-block (save-excursion
(beginning-of-line)
(looking-at my/org-src-begin-regexp))))
;; Test if we moved out of a block.
- (cond ((or (and rasmus/org-at-src-begin
+ (cond ((or (and my/org-at-src-begin
(not at-src-block))
;; File was just opened.
- (eq rasmus/org-at-src-begin -1))
- (rasmus/org-prettify-src--update))
+ (eq my/org-at-src-begin -1))
+ (my/org-prettify-src--update))
;; Remove composition if at line
(at-src-block
(with-silent-modifications
(remove-text-properties (match-end 0)
(1+ (line-end-position))
'(composition)))))
- (setq rasmus/org-at-src-begin at-src-block)))
+ (setq my/org-at-src-begin at-src-block)))
-(defun rasmus/org-prettify-symbols ()
+(defun my/org-prettify-symbols ()
(mapc (apply-partially 'add-to-list 'prettify-symbols-alist)
(cl-reduce 'append
(mapcar (lambda (x) (list x (cons (upcase (car x)) (cdr x))))
`(("#+begin_src" . ?✎) ;; ➤ 🖝 ➟ ➤ ✎
("#+end_src" . ?□) ;; ⏹
- ("#+header:" . ,rasmus/ob-header-symbol)
+ ("#+header:" . ,my/ob-header-symbol)
("#+begin_quote" . ?»)
("#+end_quote" . ?«)))))
(turn-on-prettify-symbols-mode)
- (add-hook 'post-command-hook 'rasmus/org-prettify-src t t))
-(add-hook 'org-mode-hook #'rasmus/org-prettify-symbols)
+ (add-hook 'post-command-hook 'my/org-prettify-src t t))
+(add-hook 'org-mode-hook #'my/org-prettify-symbols)
#+END_SRC
All of this should be loaded lazily.