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

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

[elpa] externals/code-cells 67e1479a75 28/36: Add code-cells-mode-maybe


From: ELPA Syncer
Subject: [elpa] externals/code-cells 67e1479a75 28/36: Add code-cells-mode-maybe
Date: Mon, 28 Feb 2022 15:57:43 -0500 (EST)

branch: externals/code-cells
commit 67e1479a7518cf1ea82ec6e4d1147c786db49993
Author: Augusto Stoffel <arstoffel@gmail.com>
Commit: Augusto Stoffel <arstoffel@gmail.com>

    Add code-cells-mode-maybe
---
 code-cells.el | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/code-cells.el b/code-cells.el
index d44de426aa..3d982c63da 100644
--- a/code-cells.el
+++ b/code-cells.el
@@ -282,6 +282,15 @@ level."
     (font-lock-remove-keywords nil (code-cells--font-lock-keywords)))
   (font-lock-flush))
 
+;;;###autoload
+(defun code-cells-mode-maybe ()
+  "Turn on `code-cells-mode' if the buffer appears to contain cells.
+This function is useful when added to a major mode hook."
+    (when (save-excursion
+            (goto-char (point-min))
+            (re-search-forward (code-cells-boundary-regexp) 5000 t))
+      (code-cells-mode)))
+
 (let ((map (make-sparse-keymap)))
   (define-key code-cells-mode-map "\C-c%" map)
   (define-key map ";" 'code-cells-comment-or-uncomment)



reply via email to

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