emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/org-superstar 9c9c13280d 097/162: Added (tested) example f


From: Stefan Kangas
Subject: [nongnu] elpa/org-superstar 9c9c13280d 097/162: Added (tested) example for programmatically toggling lightweight-mode on startup.
Date: Fri, 31 Dec 2021 19:35:31 -0500 (EST)

branch: elpa/org-superstar
commit 9c9c13280df6591ff736b00f386a728460edc757
Author: D. Williams <d.williams@posteo.net>
Commit: D. Williams <d.williams@posteo.net>

    Added (tested) example for programmatically toggling lightweight-mode on 
startup.
---
 README.org | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/README.org b/README.org
index 9260887e76..a94df2da78 100644
--- a/README.org
+++ b/README.org
@@ -151,7 +151,23 @@ used, allowing the user to inherit the level-dependent 
default look.
     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!
+    This can even be done programmatically.  For example, if you
+    experience issues for files with more than 100 list items, you
+    could simply add the following to ~org-mode-hook~ instead of a
+    direct call to ~org-superstar-mode~:
+
+    #+BEGIN_SRC emacs-lisp
+      (defun my-auto-lightweight-mode ()
+        "Start Org Superstar differently depending on the number of lists 
items."
+        (let ((list-items
+               (count-matches "^[ \t]*?\\([+-]\\|[ \t]\\*\\)"
+                              (point-min) (point-max))))
+          (unless (< list-items 100)
+            (org-superstar-toggle-lightweight-lists)))
+        (org-superstar))
+
+      (add-hook 'org-mode-hook #'my-auto-lightweight-mode)
+    #+END_SRC
 
 ** Custom faces
    These faces allow you to further manipulate the look and feel of



reply via email to

[Prev in Thread] Current Thread [Next in Thread]