all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: pjb@informatimago.com (Pascal J. Bourguignon)
To: help-gnu-emacs@gnu.org
Subject: Re: suppress terminating return by shell-command-on-region
Date: Sat, 21 Aug 2010 17:00:55 +0200	[thread overview]
Message-ID: <87eids1048.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: 87aaogprro.fsf@linux-lqcw.site

Cecil Westerhof <Cecil@decebal.nl> writes:

> Op vrijdag 20 aug 2010 17:53 CEST schreef Pascal J. Bourguignon:
>
>> Cecil Westerhof <Cecil@decebal.nl> writes:
>>
>>> I needed to reverse some text in a buffer. For this I used:
>>> C-u M-| rev
>>>
>>> This works, except that there is put a return after the replaced
>>> region. Is it possible to suppress this return? It is not a biggy, I
>>> can remove it, but it would be nice if this was not necessary.
>>
>> Instead you could use M-x reverse-lines RET
>
> My Emacs does not know this function.

Oops, sorry, it's in http://tinyurl.com/pjb-utilities

(defun reverse-lines (start end)
  "Reverse the order of the characters in each lines in the region."
  (interactive "r")
  (let* ((text)(lines)(first))
    (setq text (buffer-substring-no-properties start end))
    (setq lines  (split-string text "[\n]"))
    (setq first lines)
    (while lines
      (if (< 0 (length (car lines)))
        (setcar lines (apply 'string (reverse (string-to-list (car lines))))))
      (setq lines (cdr lines)))
    (delete-region  start end)
    (insert (unsplit-string first "\n"))))

;; unsplit-string is in pjb-strings, get the whole sources...


>> (there's also a reverse-region).
>
> That does not what I want. It changes lines, but I want to change
> characters. For example from:
>     Some before text. Decebal Computing Some after text.
> to:
>     Some before text. gnitupmoC labeceD Some after text.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/


      reply	other threads:[~2010-08-21 15:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-20 15:09 suppress terminating return by shell-command-on-region Cecil Westerhof
2010-08-20 15:53 ` Pascal J. Bourguignon
2010-08-21  3:29   ` Cecil Westerhof
2010-08-21 15:00     ` Pascal J. Bourguignon [this message]

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=87eids1048.fsf@kuiper.lan.informatimago.com \
    --to=pjb@informatimago.com \
    --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.