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

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

[nongnu] elpa/org-superstar ca448ebd7c 065/162: Added a temporary file s


From: Stefan Kangas
Subject: [nongnu] elpa/org-superstar ca448ebd7c 065/162: Added a temporary file slomode.el
Date: Fri, 31 Dec 2021 19:35:26 -0500 (EST)

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

    Added a temporary file slomode.el
    
    This file serves as a working example for the Issue discussed here:
    https://github.com/integral-dw/org-superstar-mode/issues/3
---
 tests/slomode.el | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/tests/slomode.el b/tests/slomode.el
new file mode 100644
index 0000000000..3dd8c3af02
--- /dev/null
+++ b/tests/slomode.el
@@ -0,0 +1,59 @@
+;; this is a temporary file for testing slowdown issues.
+;; edit the variable test-case to 1,2 or 3, then run:
+;; emacs -Q -l slomode-redux-1.el <your sample file>
+;; start the test with ‘M-x slo-mode’.
+(require 'org)
+
+(defvar test-case 1
+  "Check one of several plausible test cases.")
+
+(setq inhibit-compacting-font-caches nil)
+
+(cond ((= test-case 1)
+       ;; same as 2 and 3 combined
+       (defun slo-compose ()
+         (compose-region (match-beginning 1) (match-end 1) ?◉)
+         'slo-face))
+      ((= test-case 2)
+       (defun slo-compose ()
+         'slo-face))
+      ((= test-case 3)
+       (defun slo-compose ()
+         (compose-region (match-beginning 1) (match-end 1) ?◉)
+         nil)))
+
+(defface slo-face '((default . nil)) "Sloface")
+
+(defvar slo-keywords
+  '(("^\\**\\(?1:\\*\\) "
+     (1 (slo-compose) prepend))))
+
+(defun slo-fontify-buffer ()
+  "Fontify the buffer."
+  (when font-lock-mode
+    (save-restriction
+      (widen)
+      (font-lock-ensure)
+      (font-lock-flush))))
+
+(defun un-slo ()
+  (save-excursion
+    (goto-char (point-min))
+    (while (re-search-forward "^\\*+ " nil t)
+      (decompose-region (match-beginning 0) (match-end 0)))))
+
+
+;;; Mode commands
+;;;###autoload
+(define-minor-mode slo-mode
+  "Try and slow down the buffer."
+  nil " Slo" nil
+  (cond
+   (slo-mode
+    (font-lock-add-keywords nil slo-keywords
+                            'append)
+    (slo-fontify-buffer))
+   (t
+    (font-lock-remove-keywords nil slo-keywords)
+    (un-slo)
+    (slo-fontify-buffer))))



reply via email to

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