all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "B. T. Raven" <btraven@nihilo.net>
To: help-gnu-emacs@gnu.org
Subject: help with regexp function
Date: Tue, 21 Nov 2017 17:30:15 -0600	[thread overview]
Message-ID: <ov2cu6016ko@news4.newsguy.com> (raw)

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


             reply	other threads:[~2017-11-21 23:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-21 23:30 B. T. Raven [this message]
2017-11-22 11:15 ` help with regexp function Stephen Berman
2017-11-22 17:05 ` Kendall Shaw
     [not found] ` <mailman.4298.1511349362.27995.help-gnu-emacs@gnu.org>
2017-11-23  4:18   ` B. T. Raven
2017-11-23 15:20     ` Stephen Berman
     [not found]     ` <mailman.4372.1511450434.27995.help-gnu-emacs@gnu.org>
2017-11-24 14:46       ` B. T. Raven
2017-11-24 16:28         ` Stephen Berman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ov2cu6016ko@news4.newsguy.com \
    --to=btraven@nihilo.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.