emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
blob 2f2aaa68d1a6166319e859304cf93529c2ab5df1 2473 bytes (raw)
name: lisp/org-pretty.el 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
 
;;; org-pretty.el --- Support for prettify-symbols-mode  -*- lexical-binding: t; -*-

;; Copyright (C) 2018 Free Software Foundation, Inc.
;;
;; Author: J. Alexander Branham <alex.branham at gmail dot com>
;; Maintainer: emacs-orgmode@gnu.org
;;
;; This file is part of GNU Emacs.
;;
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
;;
;;; Commentary:
;;
;; This file adds support for `prettify-symbols-mode' in Org buffers.
;; To use, call M-x org-prettify-mode or put
;;
;; (add-hook 'org-mode-hook #'org-prettify-mode)
;;
;; in your configuration file.

;;; Code:

(require 'org)

(defvar-local org-pretty-alist '(("*" . ?•))
  "An alist of symbols to prettify, see `prettify-symbols-alist'.
Whether the symbol actually gets prettified is controlled by
`org-pretty-compose-p', which see.")

(defun org-pretty-compose-p (start end match)
  "Return non-nil if the symbol between START and END is to be prettified.
MATCH is the string match.  See also
`prettify-symbols-compose-predicate'."
  (if (string= match "*")
      ;; Prettify asterisks in headings.
      (and (org-match-line org-outline-regexp-bol)
	   (< end (match-end 0)))
    ;; Else rely on the default function.
    (funcall #'prettify-symbols-default-compose-p start end match)))

;;;###autoload
(define-minor-mode org-pretty-mode
  "Set up `prettify-symbols-mode' in org buffers."
  :lighter nil
  :keymap nil
  (if org-pretty-mode
      ;; Turn on.
      (when (eq major-mode 'org-mode)
	(setq-local prettify-symbols-alist org-pretty-alist)
	(setq-local prettify-symbols-compose-predicate #'org-pretty-compose-p)
	(prettify-symbols-mode))
    ;; Turn off.
    (when (eq major-mode 'org-mode)
      (setq-local prettify-symbols-alist nil)
      (setq-local prettify-symbols-compose-predicate #'prettify-symbols-default-compose-p)
      (prettify-symbols-mode -1))))

(provide 'org-pretty)

;;; org-pretty.el ends here

debug log:

solving 2f2aaa68d ...
found 2f2aaa68d in https://list.orgmode.org/orgmode/87po37nja7.fsf@gmail.com/

applying [1/1] https://list.orgmode.org/orgmode/87po37nja7.fsf@gmail.com/
diff --git a/lisp/org-pretty.el b/lisp/org-pretty.el
new file mode 100644
index 000000000..2f2aaa68d

Checking patch lisp/org-pretty.el...
Applied patch lisp/org-pretty.el cleanly.

skipping https://list.orgmode.org/orgmode/87po37nja7.fsf@gmail.com/ for 2f2aaa68d
index at:
100644 2f2aaa68d1a6166319e859304cf93529c2ab5df1	lisp/org-pretty.el

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).