[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/async afd1ad5 39/60: Allow removing text properties in
From: |
Stefan Monnier |
Subject: |
[elpa] externals/async afd1ad5 39/60: Allow removing text properties in strings when injecting |
Date: |
Tue, 8 Oct 2019 10:11:33 -0400 (EDT) |
branch: externals/async
commit afd1ad5f69e3fd04e8d358ea0da96de4899ff04d
Author: Thierry Volpiatto <address@hidden>
Commit: Thierry Volpiatto <address@hidden>
Allow removing text properties in strings when injecting
variables.
* async.el (async-variables-noprops-function): New user var.
(async-variables-noprops): Default fn for
`async-variables-noprops-function`.
(async-inject-variables): Use it, takes one more optional arg `noprops`.
---
async.el | 36 +++++++++++++++++++++++++++++++++---
1 file changed, 33 insertions(+), 3 deletions(-)
diff --git a/async.el b/async.el
index c1fb40b..e2889d1 100644
--- a/async.el
+++ b/async.el
@@ -35,6 +35,11 @@
"Simple asynchronous processing in Emacs"
:group 'emacs)
+(defcustom async-variables-noprops-function #'async-variables-noprops
+ "Default function to remove text properties in variables."
+ :group 'async
+ :type 'function)
+
(defvar async-debug nil)
(defvar async-send-over-pipe t)
(defvar async-in-child-emacs nil)
@@ -45,13 +50,35 @@
(defvar async-current-process nil)
(defvar async--procvar nil)
+(defun async-variables-noprops (sequence)
+ "Remove text properties in SEQUENCE.
+
+Argument SEQUENCE may be a list or a string, if anything else it
+returned unmodified.
+
+Note that this is a naive function that doesn't remove text properties
+in SEQUENCE recursively, only at the first level which suffice in most
+cases."
+ (cond ((stringp sequence)
+ (substring-no-properties sequence))
+ ((listp sequence)
+ (cl-loop for elm in sequence
+ if (stringp elm)
+ collect (substring-no-properties elm)
+ else collect elm))
+ (t sequence)))
+
(defun async-inject-variables
- (include-regexp &optional predicate exclude-regexp)
+ (include-regexp &optional predicate exclude-regexp noprops)
"Return a `setq' form that replicates part of the calling environment.
+
It sets the value for every variable matching INCLUDE-REGEXP and
also PREDICATE. It will not perform injection for any variable
-matching EXCLUDE-REGEXP (if present). It is intended to be used
-as follows:
+matching EXCLUDE-REGEXP (if present).
+When NOPROPS is non nil it tries to strip out text properties of each
+variable's value with `async-variables-noprops-function'.
+
+It is intended to be used as follows:
(async-start
`(lambda ()
@@ -73,6 +100,9 @@ as follows:
(or exclude-regexp "-syntax-table\\'")
(symbol-name sym))))
(let ((value (symbol-value sym)))
+ (when noprops
+ (setq value (funcall async-variables-noprops-function
+ value)))
(when (or (null predicate)
(funcall predicate sym))
(setq bindings (cons `(quote ,value) bindings)
- [elpa] externals/async 666066d 14/60: Merge pull request #72 from jwiegley/Fix_async_ready, (continued)
- [elpa] externals/async 666066d 14/60: Merge pull request #72 from jwiegley/Fix_async_ready, Stefan Monnier, 2019/10/08
- [elpa] externals/async 54977d6 10/60: Improve formatting in README., Stefan Monnier, 2019/10/08
- [elpa] externals/async e1a3735 20/60: Merge branch 'master' of github.com:jwiegley/emacs-async, Stefan Monnier, 2019/10/08
- [elpa] externals/async d6222c2 22/60: Ensure wdired-use-interactive-rename is disabled., Stefan Monnier, 2019/10/08
- [elpa] externals/async d422df5 24/60: Add new var to allow calling emacs with -Q or -q (#80)., Stefan Monnier, 2019/10/08
- [elpa] externals/async c3b297f 27/60: Merge pull request #83 from darkfeline/lighter, Stefan Monnier, 2019/10/08
- [elpa] externals/async 4e894a2 16/60: Update README., Stefan Monnier, 2019/10/08
- [elpa] externals/async 324549b 36/60: Merge pull request #94 from astahlman/auto-select-coding, Stefan Monnier, 2019/10/08
- [elpa] externals/async d13c0bc 35/60: Choose coding system based on environment, Stefan Monnier, 2019/10/08
- [elpa] externals/async 890b38f 18/60: Add makefile., Stefan Monnier, 2019/10/08
- [elpa] externals/async afd1ad5 39/60: Allow removing text properties in strings when injecting,
Stefan Monnier <=
- [elpa] externals/async 0a56cae 50/60: Update README, Stefan Monnier, 2019/10/08
- [elpa] externals/async b13baeb 47/60: Fix two issues in async-inject-variables, Stefan Monnier, 2019/10/08
- [elpa] externals/async 6fa6a86 49/60: Don't quote numbers as well, Stefan Monnier, 2019/10/08
- [elpa] externals/async caad15c 42/60: Bump to 1.9.3, Stefan Monnier, 2019/10/08
- [elpa] externals/async 373b32a 55/60: Remove props recursively when injecting vars with NOPROPS, Stefan Monnier, 2019/10/08
- [elpa] externals/async 81dc034 54/60: Merge pull request #107 from CeleritasCelery/master, Stefan Monnier, 2019/10/08
- [elpa] externals/async f61f1db 60/60: Merge pull request #113 from jwiegley/smonnier_patch, Stefan Monnier, 2019/10/08
- [elpa] externals/async 5e353eb 59/60: Change deps management in async-bytecomp.el, Stefan Monnier, 2019/10/08
- [elpa] externals/async 29e6144 07/60: Allow non list bindings in async-let., Stefan Monnier, 2019/10/08
- [elpa] externals/async d17c11e 51/60: Add more info about emacs bug when using async, Stefan Monnier, 2019/10/08