[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/code-cells 54ade13f08 2/4: New option code-cells-bounda
From: |
ELPA Syncer |
Subject: |
[elpa] externals/code-cells 54ade13f08 2/4: New option code-cells-boundary-regexp |
Date: |
Sat, 10 Sep 2022 08:57:27 -0400 (EDT) |
branch: externals/code-cells
commit 54ade13f08fa46f46a218c6571a825448539c13f
Author: Augusto Stoffel <arstoffel@gmail.com>
Commit: Augusto Stoffel <arstoffel@gmail.com>
New option code-cells-boundary-regexp
It obsoletes code-cells-boundary-markers. Also, in outline style
boundaries, allow no space between the comment character and the
asterisk, as this lead to false positives.
---
README.org | 6 +++++-
code-cells.el | 34 +++++++++++++++++++++++-----------
2 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/README.org b/README.org
index f01879944f..bb3445801b 100644
--- a/README.org
+++ b/README.org
@@ -20,7 +20,7 @@ boundaries:
# %% Optional title
- # * Optional title
+ #* Optional title
#+end_example
The first is what you get by exporting a notebook to a script on
@@ -29,6 +29,10 @@ second style is compatible with Jupytext, among several
other tools.
The third is in the spirit of Emacs's outline mode. Further percent
signs or asterisks signify nested cells.
+*Note.* As of version 0.4, the “outline mode” style heading requires
+/no space/ between the comment character and the asterisk. The
+previous behavior, which allowed spaces, led to many false positives.
+
** Minor mode
The =code-cells-mode= minor mode provides the following things:
diff --git a/code-cells.el b/code-cells.el
index 872b6dccb9..41ab18f23d 100644
--- a/code-cells.el
+++ b/code-cells.el
@@ -66,24 +66,36 @@
;;; Cell navigation
-(defcustom code-cells-boundary-markers
- (list (rx "%" (group-n 1 (+ "%")))
- (rx (group-n 1 (+ "*")))
- (rx " In[" (* (any space digit)) "]:"))
+(defcustom code-cells-boundary-markers nil
"List of regular expressions specifying cell boundaries.
They should match immediately after a comment start at the
beginning of a line. The length of the first capture determines
the outline level."
- :type '(repeat sexp))
+ :type '(repeat regexp))
+(make-obsolete-variable 'code-cells-boundary-markers
+ 'code-cells-boundary-regexp
+ "0.3")
+
+(defcustom code-cells-boundary-regexp
+ (rx (+ (syntax comment-start))
+ (or (seq (* (syntax whitespace)) "%" (group-n 1 (+ "%")))
+ (group-n 1 (+ "*"))
+ (seq " In[" (* (any space digit)) "]:")))
+ "Regular expression specifying cell boundaries.
+It should match at the beginning of a line. The length of the
+first capture determines the outline level."
+ :type 'regexp)
(defun code-cells-boundary-regexp ()
"Return a regexp matching comment lines that serve as cell boundary."
- (concat (rx line-start)
- (or comment-start-skip
- (rx (+ (syntax comment-start)) (* (syntax whitespace))))
- "\\(?:"
- (string-join code-cells-boundary-markers "\\|")
- "\\)"))
+ (if code-cells-boundary-markers
+ (concat (rx line-start)
+ (or comment-start-skip
+ (rx (+ (syntax comment-start)) (* (syntax whitespace))))
+ "\\(?:"
+ (string-join code-cells-boundary-markers "\\|")
+ "\\)")
+ (rx line-start (regexp code-cells-boundary-regexp))))
;;;###autoload
(defun code-cells-forward-cell (&optional arg)