emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Alex Branham <alex.branham@gmail.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: Support showing stars as pretty bullets
Date: Tue, 10 Apr 2018 11:00:32 -0500	[thread overview]
Message-ID: <87po37nja7.fsf@gmail.com> (raw)
In-Reply-To: <87r2nt4y2f.fsf@nicolasgoaziou.fr>

[-- Attachment #1: Type: text/plain, Size: 5783 bytes --]


On Thu 05 Apr 2018 at 07:50, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

Hi, and sorry for the delayed response.

> I don't think users should call M-x prettify-symbols-mode. Instead, they
> could call `org-art-prettify-buffer', an autoloaded function, which
> would properly initialize `prettify-symbols-mode' and so on. What
> mechanism is behind prettification is not important.

But then users of global-prettify-symbols-mode don't see the pretty
symbols in org buffers without knowing about and activating
org-pretty-mode. Anyway, the attached patch moves it to org-pretty.el.

> BTW, we could have a defcustom listings all eye candy
> `org-art-prettify-buffer' -- or simply `org-prettify-buffer' if the
> library is called "org-prettify" -- could do (e.g., headlines,
> bullets...).
>
>> prettify-symbols-alist isn't, so I don't think this should be either.
>
> Of course. But Org users may want to control what symbol is used.
> Anyway, I don't have a strong opinion about it.

I've left it as a defvar since there's no way for us to know about what
people want prettified where. Hopefully the default
prettify-symbols-compose-p function does an OK job, but people will have
to modify that if they customize org-pretty-alist anyway.

>>> Can it be tested somehow?
>>
>> I'll look into it

Can you see if these tests work for you? They work on my end, but I'm
not sure where to put them. Should they go into a new file
testing/lisp/test-org-pretty.el?

(ert-deftest test-org-pretty-mode ()
  "Test `org-pretty-mode'."
  (should
   (equal t
	  (org-test-with-temp-text
	      "* Test"
	    (org-pretty-mode)
	    (org-pretty-compose-p 1 1 "*")
	    )))
  (should-not
   (equal t
	  (org-test-with-temp-text
	      "* Test *"
	    (org-pretty-mode)
	    (org-pretty-compose-p 8 8 "*")))))


------------------------------------------------------------

From 3278c7dd9d426bf205542c78d51456a96196988b Mon Sep 17 00:00:00 2001
From: Alex Branham <branham@utexas.edu>
Date: Tue, 10 Apr 2018 10:38:09 -0500
Subject: [PATCH] New minor mode org-pretty-mode

* lisp/org-pretty.el: New file
* etc/ORG-NEWS: Document new minor mode
---
 etc/ORG-NEWS       |  9 ++++++
 lisp/org-pretty.el | 71 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+)
 create mode 100644 lisp/org-pretty.el

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 0edd77115..0339a2df3 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -228,7 +228,16 @@ parameters.  See example bellow.
   select sysdate from dual;
   ,#+END_SRC
 #+END_SRC
+*** New minor mode ~org-pretty-mode~ supports showing prettier characters.
+By default, it replaces asterisks in headings with a utf8 bullet: •

+To enable, either call M-x org-pretty-mode or add
+
+#+BEGIN_SRC elisp
+  (add-hook 'org-mode-hook #'org-pretty-mode)
+#+END_SRC
+
+to your configuration file.
 ** New functions
 *** ~org-insert-structure-template~

diff --git a/lisp/org-pretty.el b/lisp/org-pretty.el
new file mode 100644
index 000000000..2f2aaa68d
--- /dev/null
+++ b/lisp/org-pretty.el
@@ -0,0 +1,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
--
2.17.0


[-- Attachment #2: 0001-New-minor-mode-org-pretty-mode.patch --]
[-- Type: text/x-patch, Size: 3867 bytes --]

From 3278c7dd9d426bf205542c78d51456a96196988b Mon Sep 17 00:00:00 2001
From: Alex Branham <branham@utexas.edu>
Date: Tue, 10 Apr 2018 10:38:09 -0500
Subject: [PATCH] New minor mode org-pretty-mode

* lisp/org-pretty.el: New file
* etc/ORG-NEWS: Document new minor mode
---
 etc/ORG-NEWS       |  9 ++++++
 lisp/org-pretty.el | 71 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+)
 create mode 100644 lisp/org-pretty.el

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 0edd77115..0339a2df3 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -228,7 +228,16 @@ parameters.  See example bellow.
   select sysdate from dual;
   ,#+END_SRC
 #+END_SRC
+*** New minor mode ~org-pretty-mode~ supports showing prettier characters.
+By default, it replaces asterisks in headings with a utf8 bullet: •
 
+To enable, either call M-x org-pretty-mode or add
+
+#+BEGIN_SRC elisp
+  (add-hook 'org-mode-hook #'org-pretty-mode)
+#+END_SRC
+
+to your configuration file.
 ** New functions
 *** ~org-insert-structure-template~
 
diff --git a/lisp/org-pretty.el b/lisp/org-pretty.el
new file mode 100644
index 000000000..2f2aaa68d
--- /dev/null
+++ b/lisp/org-pretty.el
@@ -0,0 +1,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
-- 
2.17.0


  reply	other threads:[~2018-04-10 16:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-01 20:59 Support showing stars as pretty bullets Alex Branham
2018-04-02 18:47 ` Nicolas Goaziou
2018-04-03  0:41   ` Alex Branham
2018-04-03  1:11     ` William Denton
2018-04-03  6:39     ` Nicolas Goaziou
2018-04-03 14:30       ` Alex Branham
2018-04-03 20:33         ` Nicolas Goaziou
2018-04-04 22:14           ` Alex Branham
2018-04-05 12:50             ` Nicolas Goaziou
2018-04-10 16:00               ` Alex Branham [this message]
2018-04-14 10:20                 ` Nicolas Goaziou
2018-04-14 13:10                   ` Rasmus
2018-04-06 20:22         ` Rasmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87po37nja7.fsf@gmail.com \
    --to=alex.branham@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).