[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-superstar ceb3be1018 088/162: Implement circumvention
From: |
Stefan Kangas |
Subject: |
[nongnu] elpa/org-superstar ceb3be1018 088/162: Implement circumvention for plain list syntax checking |
Date: |
Fri, 31 Dec 2021 19:35:29 -0500 (EST) |
branch: elpa/org-superstar
commit ceb3be1018fb60134750718145e273edd9d04180
Author: D. Williams <d.williams@posteo.net>
Commit: D. Williams <d.williams@posteo.net>
Implement circumvention for plain list syntax checking
While semantic prettification is a very nice concept on paper, it is a
rather expensive feature to implement. For this reason I have come to
believe the user should have the option to disable it on a
case-by-case (or rather buffer-by-buffer) basis.
---
README.org | 19 +++++++++++++++++++
org-superstar.el | 37 ++++++++++++++++++++++++++++++-------
2 files changed, 49 insertions(+), 7 deletions(-)
diff --git a/README.org b/README.org
index 204c229c32..86205da042 100644
--- a/README.org
+++ b/README.org
@@ -145,6 +145,16 @@ used, allowing the user to inherit the level-dependent
default look.
Exactly as it says on the tin. Set this variable to ~nil~ to stop
~org-superstar-mode~ from prettifying lists.
+*** Fast Plain List Items
+ The default syntax-checking done to ensure only actual plain list
+ items are prettified is rather expensive, but usually not
+ expensive enough to cause significant slowdown. This can change
+ when dealing with Org files containing hundreds or even thousands
+ of plain list items. The command
+ =org-superstar-toggle-lightweight-lists= allows the user to disable
+ syntax checking for plain lists both interactively and in code.
+**** TODO Give an elisp example for automated toggling!
+
** Custom faces
These faces allow you to further manipulate the look and feel of
prettified bullets.
@@ -178,6 +188,15 @@ used, allowing the user to inherit the level-dependent
default look.
problem. If this should not fix the problem, please consider
opening an issue or sending me a mail!
+*** "I experience lag when working with long plain lists!"
+ By default, Org Superstar does expensive syntax checking to ensure
+ plain lists are actual plain lists. This is usually not an issue
+ for small files. However, this may pose a problem when your file
+ contains hundreds or thousands of items! You can deal with this
+ interactively using the command
+ =org-superstar-toggle-lightweight-lists=. See also the subsection
+ "*Fast Plain List Items*" above.
+
* NEWS
** =2020-03-08=
diff --git a/org-superstar.el b/org-superstar.el
index 4ebebbafe8..3e902c7b59 100644
--- a/org-superstar.el
+++ b/org-superstar.el
@@ -5,7 +5,7 @@
;; Author: D. Williams <d.williams@posteo.net>
;; Maintainer: D. Williams <d.williams@posteo.net>
;; Keywords: faces, outlines
-;; Version: 1.0.2
+;; Version: 1.1.0
;; Homepage: https://github.com/integral-dw/org-superstar-mode
;; Package-Requires: ((org "9.1.9") (emacs "26.2"))
@@ -272,6 +272,12 @@ keyword)."
:group 'org-superstar
:type 'boolean)
+(defvar-local org-superstar-lightweight-lists nil
+ "Non-nil means circumvent expensive calls to ‘org-superstar-plain-list-p’.
+
+There is usually no need to use this variable directly; instead,
+use the command ‘org-superstar-toggle-lightweight-lists’.")
+
;;; Faces
@@ -348,6 +354,18 @@ variable for your changes to take effect."
(setq org-superstar-special-todo-items nil)
nil)
+;;;###autoload
+(defun org-superstar-toggle-lightweight-lists ()
+ "Toggle syntax checking for plain list items.
+
+Disabling syntax checking will cause Org Superstar to display
+lines looking like plain lists (for example in code) like plain
+lists. However, this may cause significant speedup for org files
+containing several hundred list items."
+ (interactive)
+ (setq org-superstar-lightweight-lists
+ (not org-superstar-lightweight-lists)))
+
;;; Accessor Functions
@@ -425,11 +443,16 @@ replaced by their corresponding entry in
‘org-superstar-item-bullet-alist’."
;; Explicitly returning t is redundant, but does not leak information
;; about how the predicate is implemented.
(defun org-superstar-plain-list-p ()
- "Return t if the current match is a proper plain list."
- (save-match-data
- (when (org-element-lineage (org-element-at-point)
- '(plain-list) t)
- t)))
+ "Return t if the current match is a proper plain list.
+
+This function may be expensive for files with very large plain
+lists; consider using ‘org-superstar-toggle-lightweight-lists’ in
+such cases to avoid slowdown."
+ (or org-superstar-lightweight-lists
+ (save-match-data
+ (org-element-lineage (org-element-at-point)
+ '(plain-list) t))
+ t))
(defun org-superstar-headline-or-inlinetask-p ()
"Return t if the current match is a proper headline or inlinetask."
@@ -622,7 +645,7 @@ cleanup routines."
(org-superstar--fontify-buffer))))
(defun org-superstar-restart ()
- "Re-enable ‘org-superstar-mode’, if the mode is enabled."
+ "Re-enable Org Superstar mode, if the mode is enabled."
(interactive)
(when org-superstar-mode
(org-superstar-mode 0)
- [nongnu] elpa/org-superstar 4965e70c75 036/162: added reference for default headline fontification, (continued)
- [nongnu] elpa/org-superstar 4965e70c75 036/162: added reference for default headline fontification, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar c58d1e2689 046/162: force org-superstar to clean up --font-lock-keywords, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar a7d6b37ea2 062/162: Removing references to org-hide-leading-stars-before-indent-mode., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 6ef00c4eaf 034/162: renamed sample-titles to sample-headlines, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar bd99047cb3 048/162: updating README, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar b7c660aa32 038/162: adding further faceup files, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 4c2015072c 024/162: updated roadmap, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 845aa85b78 080/162: fixed typo in docstring, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar fc62da2f85 077/162: fixed README conflict, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 772719da34 074/162: Streamlined headline predicates., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar ceb3be1018 088/162: Implement circumvention for plain list syntax checking,
Stefan Kangas <=
- [nongnu] elpa/org-superstar b366a40451 091/162: Allow for item bullets other than "*" to lack leading spaces., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 7b576a0f23 083/162: Fix org-superstar-restart docstring, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar addff4c813 086/162: Moved NEWS section to the bottom of the README., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 10735de9e9 093/162: Updating README (news), Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 9551ab129d 094/162: Merging updates from master branch., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 17481852c1 110/162: Merge pull request #17 from progfolio/fix/16, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 746d7afa3e 101/162: Updating README to reflect version bump., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 0a2dedc91f 107/162: Fix typo in org-superstar-plain-list-p causing it to always return t., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 3db4ab5d4d 096/162: Merge branch 'master' into volatile, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar a984d0d05a 104/162: Merge branch 'master' into volatile, Stefan Kangas, 2021/12/31