[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/lentic 97c01a0a02 310/333: First line fixup now works f
From: |
ELPA Syncer |
Subject: |
[elpa] externals/lentic 97c01a0a02 310/333: First line fixup now works from org to lua/sh |
Date: |
Tue, 27 Feb 2024 13:00:48 -0500 (EST) |
branch: externals/lentic
commit 97c01a0a02fc462a30fdd1644d4ead2b884ffc0e
Author: Phillip Lord <phillip.lord@russet.org.uk>
Commit: Phillip Lord <phillip.lord@russet.org.uk>
First line fixup now works from org to lua/sh
We now make explicit use of the comment character to perform the first
line fixup which was preventing org to lua/sh from working. Also, lua
and sh config had comment-start, comment-stop backward.
---
dev-resources/fulllua.lua | 13 ++++++------
dev-resources/fullsh.org | 7 +++----
dev-resources/fullsh.sh | 7 +++----
lentic-cookie.el | 52 ++++++++++++++++++++--------------------------
lentic-script.el | 8 +++----
test/lentic-cookie-test.el | 21 ++++++++++++++++++-
test/lentic-script-test.el | 28 +++++++++++++++++++++++++
7 files changed, 87 insertions(+), 49 deletions(-)
diff --git a/dev-resources/fulllua.lua b/dev-resources/fulllua.lua
index 37d95cd07e..2415ac3a8d 100644
--- a/dev-resources/fulllua.lua
+++ b/dev-resources/fulllua.lua
@@ -1,10 +1,9 @@
#!/usr/bin/env lua
--- #+begin_src lua
--- print( "Hello World" )
--- #+end_src
+-- #+BEGIN_SRC lua
+print( "Hello World" )
+-- #+END_SRC
-
--- Local Variables:
--- lentic-init: lentic-lua-script-init
--- End:
+-- # Local Variables:
+-- # lentic-init: lentic-lua-script-init
+-- # End:
diff --git a/dev-resources/fullsh.org b/dev-resources/fullsh.org
index 6bab26f3d5..4dadf80bba 100644
--- a/dev-resources/fullsh.org
+++ b/dev-resources/fullsh.org
@@ -4,7 +4,6 @@
echo "hello world"
#+end_src
-
-Local Variables:
-lentic-init: lentic-bash-script-init
-End:
+# Local Variables:
+# lentic-init: lentic-bash-script-init
+# End:
diff --git a/dev-resources/fullsh.sh b/dev-resources/fullsh.sh
index cf00fe90da..f77f0c2208 100644
--- a/dev-resources/fullsh.sh
+++ b/dev-resources/fullsh.sh
@@ -4,7 +4,6 @@
echo "hello world"
## #+end_src
-
-## Local Variables:
-## lentic-init: lentic-bash-script-init
-## End:
+## # Local Variables:
+## # lentic-init: lentic-bash-script-init
+## # End:
diff --git a/lentic-cookie.el b/lentic-cookie.el
index 1be423434a..e255fc8d3d 100644
--- a/lentic-cookie.el
+++ b/lentic-cookie.el
@@ -39,7 +39,8 @@
:documentation "Configuration for a magic cookie containing
lentic buffer that is not commented.")
-(defun lentic-cookie--uncommented-fixup-first-line-1 (buffer first-line-end)
+(defun lentic-cookie--uncommented-fixup-first-line-1 (buffer first-line-end
+ comment)
"Fixup the first line.
BUFFER is the buffer.
@@ -51,8 +52,15 @@ despite the name of the function!"
(m-buffer-replace-match
(m-buffer-match
buffer
- (rx
- (and line-start (0+ anything) "# #!"))
+ (rx-to-string
+ `(and line-start
+ (or
+ ;; the line may have been commented during the update
+ ,comment
+ ;; the line may have the comment from org-mode
+ "# ")
+ ;; and this is the actual start
+ "#!"))
:end first-line-end)
"#!")))
@@ -62,7 +70,8 @@ despite the name of the function!"
CONF is the `lentic-configuration' object.
FIRST-LINE-END is the location of the end of the line."
(lentic-cookie--uncommented-fixup-first-line-1
- (lentic-that conf) first-line-end))
+ (lentic-that conf) first-line-end
+ (oref conf :comment)))
(defmethod lentic-clone
((conf lentic-cookie-uncommented-configuration)
@@ -71,30 +80,13 @@ FIRST-LINE-END is the location of the end of the line."
(let ((clone-return
(call-next-method conf start stop
length-before start-converted stop-converted)))
- (if
- (or
- ;; next method has done strange things
- (not clone-return)
- ;; calling method is broad
- (not start)
- (not stop)
- (m-buffer-with-markers
- ((first-line
- (m-buffer-match-first-line
- (lentic-this conf))))
- (or
- (m-buffer-in-match-p
- first-line start)
- (m-buffer-in-match-p
- first-line stop))))
- (progn
- (lentic-cookie-uncommented-fixup-first-line
- conf
- (cl-cadar
- (m-buffer-match-first-line
- (lentic-this conf)
- :numeric t)))
- nil)
+ (if (lentic-cookie-uncommented-fixup-first-line
+ conf
+ (cl-cadar
+ (m-buffer-match-first-line
+ (lentic-this conf)
+ :numeric t)))
+ nil
clone-return)))
(defclass lentic-cookie-commented-configuration
@@ -116,7 +108,9 @@ despite the name of the function!"
(m-buffer-match
buffer
(rx
- (and line-start "#!"))
+ (and line-start
+ (0+ anything)
+ "#!"))
:end first-line-end)
"# #!")))
diff --git a/lentic-script.el b/lentic-script.el
index 5d80495674..cd668c5052 100644
--- a/lentic-script.el
+++ b/lentic-script.el
@@ -80,8 +80,8 @@
"temp"
:this-buffer (current-buffer)
:comment "## "
- :comment-start "#\\\+BEGIN_SRC sh"
- :comment-stop "#\\\+END_SRC"
+ :comment-stop "#\\\+BEGIN_SRC sh"
+ :comment-start "#\\\+END_SRC"
:lentic-file
(lentic-script-lentic-file)))
@@ -95,8 +95,8 @@
"temp"
:this-buffer (current-buffer)
:comment "-- "
- :comment-start "#\\\+BEGIN_SRC lua"
- :comment-stop "#\\\+END_SRC"
+ :comment-stop "#\\\+BEGIN_SRC lua"
+ :comment-start "#\\\+END_SRC"
:lentic-file
(lentic-script-lentic-file)))
diff --git a/test/lentic-cookie-test.el b/test/lentic-cookie-test.el
index b6527bbdb2..0bfe3a9535 100644
--- a/test/lentic-cookie-test.el
+++ b/test/lentic-cookie-test.el
@@ -38,7 +38,8 @@
")
(lentic-cookie--uncommented-fixup-first-line-1
(current-buffer)
- (point-max))
+ (point-max)
+ "## ")
(buffer-substring-no-properties
(point-min)
(point-max)))
@@ -62,6 +63,24 @@
"# #!/usr/bin/python
")))
+(ert-deftest lentic-cookie-test-commented-fixup-with-comments-in ()
+ (should
+ (assess=
+ (with-temp-buffer
+ (insert
+ "-- #!/usr/bin/lua
+")
+ (lentic-cookie--commented-fixup-first-line-1
+ (current-buffer)
+ (point-max))
+ (buffer-substring-no-properties
+ (point-min)
+ (point-max)))
+ "# #!/usr/bin/lua
+")))
+
+
+
;;; lentic-cookie-test.el ends here:
diff --git a/test/lentic-script-test.el b/test/lentic-script-test.el
index 9b68a7eb75..1a4c089dae 100644
--- a/test/lentic-script-test.el
+++ b/test/lentic-script-test.el
@@ -78,5 +78,33 @@
"fulllua.lua"
#'lentic-lua-script-init))))
+
+(ert-deftest lentic-script-lua-clone-change ()
+ (should
+ (lentic-test-clone-and-change=
+ #'lentic-lua-script-init
+ "fulllua.lua"
+ "fulllua.org"
+ (lambda ()
+ (forward-line)
+ (insert "-- hello")
+ (beginning-of-line)
+ (kill-line))))
+ (should
+ (lentic-test-clone-and-change=
+ #'lentic-lua-script-init
+ "fulllua.lua"
+ "fulllua.org"
+ nil
+ (lambda ()
+ (forward-line)
+ (insert "hello")
+ (beginning-of-line)
+ (kill-line))))
+ )
+
+
+
+
(provide 'lentic-script-test)
;;; lentic-script-test.el ends here
- [elpa] externals/lentic 1ce36f1ab6 144/333: More linked->lentic renames., (continued)
- [elpa] externals/lentic 1ce36f1ab6 144/333: More linked->lentic renames., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 2f9d3fbd7f 153/333: All files are now orgel documented., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 406a36bae2 151/333: All autoloads added., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 3b1d0cb77a 154/333: Split lentic.el code into -mode and -dev., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 2f141ed978 201/333: Deprecated Emacs-24.3., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 3c7736b52d 221/333: Move to releases only after m-buffer update., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic b625f8a6bc 217/333: Move to load-relative for tests., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 51f0f6257c 226/333: Back to melpa-stable in preparation for new release., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 9a56901f68 249/333: Ensure lentic-mode is loaded during test., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic d5268570c0 289/333: Fix typo in lentic-when-with-current-buffer., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 97c01a0a02 310/333: First line fixup now works from org to lua/sh,
ELPA Syncer <=
- [elpa] externals/lentic 73cdcd768a 275/333: Added autoload cookie to clojure-asciidoc-init., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 9b556df984 312/333: Add support for additional files for HTML export, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 6af878392e 332/333: Use `cl-generic` and remove dependency on `f` and `s`, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic fd93a7072c 292/333: Make travis quieter, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 22c1590c57 279/333: Lentic-doc can now include an els file., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic debb9005b4 308/333: Require assess directly, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 4b48430872 309/333: Fix broken file name in test, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic dd53109fe0 298/333: Test discovery by assess-discover, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic ca9a6093b6 272/333: Correctly require s in cask and lentic-doc., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic dfb99c62ff 296/333: Update maintainer email, ELPA Syncer, 2024/02/27