From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "B. T. Raven" Newsgroups: gmane.emacs.help Subject: help with regexp function Date: Tue, 21 Nov 2017 17:30:15 -0600 Organization: NewsGuy - Unlimited Usenet $23.95 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1511307356 6890 195.159.176.226 (21 Nov 2017 23:35:56 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 21 Nov 2017 23:35:56 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 22 00:35:52 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHI4x-0001Jk-Gv for geh-help-gnu-emacs@m.gmane.org; Wed, 22 Nov 2017 00:35:47 +0100 Original-Received: from localhost ([::1]:37065 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHI54-0001Ly-JT for geh-help-gnu-emacs@m.gmane.org; Tue, 21 Nov 2017 18:35:54 -0500 X-Received: by 10.107.134.224 with SMTP id q93mr11166483ioi.90.1511307030057; Tue, 21 Nov 2017 15:30:30 -0800 (PST) Original-Path: usenet.stanford.edu!i6no3138646itb.0!news-out.google.com!x87ni1620ita.0!nntp.google.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!spln!extra.newsguy.com!newsp.newsguy.com!news4 Original-Newsgroups: gnu.emacs.help Original-Lines: 36 Original-NNTP-Posting-Host: pe05ca3fa7e43b70640528c41b8e5b66fd0d2819e0903eb84.newsdawg.com X-Mozilla-News-Host: news://news.newsguy.net:8080 X-Received-Bytes: 1881 X-Received-Body-CRC: 397335056 Content-Language: en-US Original-Xref: usenet.stanford.edu gnu.emacs.help:220933 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:115044 Archived-At: Dear Emacs gurus: I can perform this inteactive substitution CM-%: \(^[0-9]+ \)\(.+\) -> \2 \1) in order to change a buffer line prefixed with a number into one post-fixed with the same number but I can't figue out how to do the same programatically to a whole region. I started with this code: (defun verse-num-move-beg-to-end (beg end) "Move int-string and following space from beginning of line to end of line throughout region." (interactive "r") (goto-char beg) (while (<= (point) end) (re-search-forward "^[0-9]+ ") (setq num (substring (match-string 0) 0 -1)) ;; should be a string of ;;digits without trailing space (print num) ;; here the value generates a wrong argument error: setq: Wrong type argument: listp, #("234" 0 3 (fontified t)) (type-of #("234" 0 3 (fontified t))) ;; I have a function which is a black box to to me but it works in the larger context I have it in. Does match-string do something like this implicitly (casting a list as a string?) ... (substring (match-string 0) 0 -1) (replace-match "" nil t) 234 asentuhasneothu ;; example buffer-line Any help apppreciated. Ed