[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 293e13a 198/433: (mmm-format-matches): Changed to allow ac
From: |
Dmitry Gutov |
Subject: |
[elpa] master 293e13a 198/433: (mmm-format-matches): Changed to allow accessing any subexp, not |
Date: |
Thu, 15 Mar 2018 19:44:01 -0400 (EDT) |
branch: master
commit 293e13a5a4d7447a22ff06cdae49abe898b91a03
Author: mas <mas>
Commit: mas <mas>
(mmm-format-matches): Changed to allow accessing any subexp, not
limited by a numerical value of save-matches.
---
mmm-class.el | 6 ++++--
mmm-utils.el | 32 ++++++++++++++++++--------------
2 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/mmm-class.el b/mmm-class.el
index c34db74..de76843 100644
--- a/mmm-class.el
+++ b/mmm-class.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2000 by Michael Abraham Shulman
;; Author: Michael Abraham Shulman <address@hidden>
-;; Version: $Id: mmm-class.el,v 1.13 2001/01/11 00:56:08 mas Exp $
+;; Version: $Id: mmm-class.el,v 1.14 2001/01/14 01:26:09 mas Exp $
;;{{{ GPL
@@ -206,7 +206,9 @@ point at which the search should continue if the region is
invalid."
(match-face
(cdr (assoc front-form match-face))))))
(when (mmm-match-and-verify
- (mmm-format-matches back save-matches)
+ (if save-matches
+ (mmm-format-matches back)
+ back)
beg stop back-verify)
(let ((end (mmm-match->point (not include-back) back-offset))
(back-form (mmm-get-form back-form)))
diff --git a/mmm-utils.el b/mmm-utils.el
index 4a60ac6..c33bf98 100644
--- a/mmm-utils.el
+++ b/mmm-utils.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2000 by Michael Abraham Shulman
;; Author: Michael Abraham Shulman <address@hidden>
-;; Version: $Id: mmm-utils.el,v 1.7 2000/08/01 01:54:18 mas Exp $
+;; Version: $Id: mmm-utils.el,v 1.8 2001/01/14 01:26:09 mas Exp $
;;{{{ GPL
@@ -81,19 +81,23 @@ substituted for the corresponding REGEXP wherever it
matches."
(setq string (replace-match (cdr pair) t t string))))))
string)
-(defun mmm-make-matches-list (count)
- "Make a list of the most recent subexpression matches by number.
-Returns \(\(\"~0\" . \"whole-match\") \(\"~1\" . \"first-subexp\") ...)
-up until COUNT."
- (loop for n from 0 to count
- collect (cons (format "~%s" n) (or (match-string n) ""))))
-
-(defun mmm-format-matches (string count)
- "Format STRING by the last COUNT matches.
-Does nothing if COUNT is nil or STRING is not a string."
- (if (and count (stringp string))
- (mmm-format-string string (mmm-make-matches-list count))
- string))
+(defun mmm-format-matches (string)
+ "Format STRING by matches from the current match data.
+Strings like ~N are replaced by the Nth subexpression from the last
+global match. Does nothing if STRING is not a string."
+ (when (and count (stringp string))
+ (let ((old-data (match-data))
+ subexp)
+ (save-match-data
+ (while (string-match "~\\([0-9]\\)" string)
+ (setq subexp (string-to-int (match-string 1 string))
+ string
+ (replace-match
+ (save-match-data
+ (set-match-data old-data)
+ (match-string subexp))
+ t t string))))))
+ string)
;;}}}
;;{{{ Save Keywords
- [elpa] master b25ce5b 204/433: (mmm-insert-by-key): Use match-face and major-mode-preferences., (continued)
- [elpa] master b25ce5b 204/433: (mmm-insert-by-key): Use match-face and major-mode-preferences., Dmitry Gutov, 2018/03/15
- [elpa] master e2cabee 161/433: Autoloaded `rpm'., Dmitry Gutov, 2018/03/15
- [elpa] master 3fe80af 155/433: # Updated., Dmitry Gutov, 2018/03/15
- [elpa] master 800e78a 171/433: (mmm-save-local-variables): Added abbrev-mode variables., Dmitry Gutov, 2018/03/15
- [elpa] master a040c3d 176/433: Added comment about installing with multiple emacsen., Dmitry Gutov, 2018/03/15
- [elpa] master 885e2fb 180/433: (mmm-keywords-used): Added `:private'., Dmitry Gutov, 2018/03/15
- [elpa] master e0a2e51 196/433: (mmm-save-local-variables): Added syntax and indentation variables for, Dmitry Gutov, 2018/03/15
- [elpa] master d674c74 202/433: (mmm-format-matches): Removed reference to `count' variable., Dmitry Gutov, 2018/03/15
- [elpa] master d64a049 192/433: Modified classes to use preferred mode list., Dmitry Gutov, 2018/03/15
- [elpa] master b0b7520 217/433: # Added comment about bug fix., Dmitry Gutov, 2018/03/15
- [elpa] master 293e13a 198/433: (mmm-format-matches): Changed to allow accessing any subexp, not,
Dmitry Gutov <=
- [elpa] master 2a00982 215/433: * mmm-mason.el (mmm-mason-end-line, mmm-mason-start-line): Use bolp, Dmitry Gutov, 2018/03/15
- [elpa] master 1ef198a 219/433: # Updated, Dmitry Gutov, 2018/03/15
- [elpa] master ef73242 214/433: Added `javascript-mode' to list of C-derived modes., Dmitry Gutov, 2018/03/15
- [elpa] master 23170fe 205/433: Added `mmm-primary-mode' variable so that `major-mode' can be saved., Dmitry Gutov, 2018/03/15
- [elpa] master 72ca55f 213/433: # Updated menus., Dmitry Gutov, 2018/03/15
- [elpa] master c95f9b0 157/433: Added file (contributed by Marcus Harnisch)., Dmitry Gutov, 2018/03/15
- [elpa] master c9c6c19 194/433: Added ePerl and JSP to autoload., Dmitry Gutov, 2018/03/15
- [elpa] master c659e19 141/433: Released 0.4.4, Dmitry Gutov, 2018/03/15
- [elpa] master d06e9a3 143/433: (mmm-here-doc-get-mode): Extended to recognize names like TEXT_EOF., Dmitry Gutov, 2018/03/15
- [elpa] master 28cda1d 160/433: # Added headers., Dmitry Gutov, 2018/03/15