Ihor Radchenko <yanta...@posteo.net> writes:

> Amy Grinn <grinn....@gmail.com> writes:
>
>> First of all, I would like to change (defalias) the function name
>> org-babel-noweb-wrap to org-babel-noweb-make-regexp. I think this in
>> more in line with other functions which create regular expressions.
>
> +1
> You may even use obsolete alias (add it to lisp/org-compat.el)

Here's a patch to rename org-babel-noweb-wrap to
org-babel-noweb-make-regexp.

>From b318fef6af8ae47b7e6d0371ccc87a01ed1a7755 Mon Sep 17 00:00:00 2001
From: Amy Grinn <grinn....@gmail.com>
Date: Wed, 17 Apr 2024 16:01:40 -0400
Subject: [PATCH] lisp/ob-core.el: (org-babel-noweb-wrap): renamed to
 org-babel-noweb-make-regexp

* etc/ORG-NEWS (~org-babel-noweb-wrap~ is now
~org-babel-noweb-make-regexp~): Announce the change.
* lisp/org-compat.el: Declare org-babel-noweb-wrap to be an obselete
function alias for org-babel-noweb-make-regexp.
* lisp/ob-core.el (org-babel-noweb-make-regexp): Rename the function.
(org-babel-goto-named-src-block):
(org-babel-expand-noweb-references):
* lisp/ob-exp.el (org-babel-exp-code):
* lisp/ob-tangle.el (org-babel-tangle-clean):
(org-babel-tangle-single-block): Use the new function name.
---
 etc/ORG-NEWS       | 6 ++++++
 lisp/ob-core.el    | 8 ++++----
 lisp/ob-exp.el     | 2 +-
 lisp/ob-tangle.el  | 5 +++--
 lisp/org-compat.el | 2 +-
 5 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 978882a7a..97e2f2e3f 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1563,6 +1563,12 @@ optional argument =NEW-HEADING-CONTAINER= specifies where in the
 buffer it will be added.  If not specified, new headings are created
 at level 1 at the end of the accessible part of the buffer, as before.
 
+** Removed or renamed functions and variables
+*** ~org-babel-noweb-wrap~ is now ~org-babel-noweb-make-regexp~
+
+This is more in line with other functions that return a regular
+expression.
+
 ** Miscellaneous
 *** =org-crypt.el= now applies initial visibility settings to decrypted entries
 
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index c5dd20b0e..1518d7726 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -194,7 +194,7 @@ This string must include a \"%s\" which will be replaced by the results."
   :package-version '(Org . "9.1")
   :safe #'booleanp)
 
-(defun org-babel-noweb-wrap (&optional regexp)
+(defun org-babel-noweb-make-regexp (&optional regexp)
   "Return regexp matching a Noweb reference.
 
 Match any reference, or only those matching REGEXP, if non-nil.
@@ -1976,7 +1976,7 @@ src block, then return nil."
 		   (type (org-element-type context))
 		   (noweb-ref
 		    (and (memq type '(inline-src-block src-block))
-			 (org-in-regexp (org-babel-noweb-wrap)))))
+			 (org-in-regexp (org-babel-noweb-make-regexp)))))
 	      (cond
 	       (noweb-ref
 		(buffer-substring
@@ -3125,7 +3125,7 @@ block but are passed literally to the \"example-block\"."
                                   (not (equal (cdr v) "no"))))))
 	 (noweb-re (format "\\(.*?\\)\\(%s\\)"
 			   (with-current-buffer parent-buffer
-			     (org-babel-noweb-wrap)))))
+			     (org-babel-noweb-make-regexp)))))
     (unless (equal (cons parent-buffer
                          (with-current-buffer parent-buffer
                            (buffer-chars-modified-tick)))
@@ -3175,7 +3175,7 @@ block but are passed literally to the \"example-block\"."
 	               ((guard (or org-babel-noweb-error-all-langs
 			           (member lang org-babel-noweb-error-langs)))
 	                (error "Cannot resolve %s (see `org-babel-noweb-error-langs')"
-		               (org-babel-noweb-wrap ,ref)))
+		               (org-babel-noweb-make-regexp ,ref)))
 	               (_ ""))))
       (replace-regexp-in-string
        noweb-re
diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el
index 80eaeeb27..a61b26ed5 100644
--- a/lisp/ob-exp.el
+++ b/lisp/ob-exp.el
@@ -419,7 +419,7 @@ replaced with its value."
   (setf (nth 1 info)
 	(if (string= "strip-export" (cdr (assq :noweb (nth 2 info))))
 	    (replace-regexp-in-string
-	     (org-babel-noweb-wrap) "" (nth 1 info))
+	     (org-babel-noweb-make-regexp) "" (nth 1 info))
 	  (if (org-babel-noweb-p (nth 2 info) :export)
 	      (org-babel-expand-noweb-references
 	       info org-babel-exp-reference-buffer)
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 79fe6448b..4427250ae 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -412,7 +412,7 @@ references."
   (interactive)
   (goto-char (point-min))
   (while (or (re-search-forward "\\[\\[file:.*\\]\\[.*\\]\\]" nil t)
-             (re-search-forward (org-babel-noweb-wrap) nil t))
+             (re-search-forward (org-babel-noweb-make-regexp) nil t))
     (delete-region (save-excursion (forward-line) (point))
                    (save-excursion (end-of-line 1) (forward-char 1) (point)))))
 
@@ -580,7 +580,8 @@ non-nil, return the full association list to be used by
 	  ;; Run the tangle-body-hook.
           (let ((body (if (org-babel-noweb-p params :tangle)
                           (if (string= "strip-tangle" (cdr (assq :noweb (nth 2 info))))
-                            (replace-regexp-in-string (org-babel-noweb-wrap) "" (nth 1 info))
+                              (replace-regexp-in-string (org-babel-noweb-make-regexp)
+                                                        "" (nth 1 info))
 			    (org-babel-expand-noweb-references info))
 			(nth 1 info))))
 	    (with-temp-buffer
diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index 92cad3d6e..ce46fd399 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -433,7 +433,7 @@ This is a floating point number if the size is too large for an integer."
 (define-obsolete-function-alias 'org-show-context 'org-fold-show-context "9.6")
 (define-obsolete-function-alias 'org-show-entry 'org-fold-show-entry "9.6")
 (define-obsolete-function-alias 'org-show-children 'org-fold-show-children "9.6")
-
+(define-obsolete-function-alias 'org-babel-noweb-wrap 'org-babel-noweb-make-regexp "9.7")
 
 (defmacro org-re (s)
   "Replace posix classes in regular expression S."
-- 
2.39.2

-- 
Best,

Amy

Reply via email to