From: Rodolfo Medina <rodolfo.medina@gmail.com>
To: Konstantin Shakhnov <kastian@mail.ru>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Indent first line of each paragraph of file in one hit
Date: Fri, 25 Nov 2016 11:28:40 +0000 [thread overview]
Message-ID: <87lgw7lrx3.fsf@gmail.com> (raw)
In-Reply-To: <20161125104812.GA8781@eee.birulevo.net> (Konstantin Shakhnov's message of "Fri, 25 Nov 2016 13:48:12 +0300")
Konstantin Shakhnov <kastian@mail.ru> writes:
> On Thu, Nov 24, 2016 at 03:35:12PM +0000, Rodolfo Medina wrote:
>> Suppose you have a large file, in which the first line of each paragraph is
>> not indented; and want it to be with one single command for the whole file.
>> Is that possible, and how?
>
> I'm not great lisp master, but this dirty sketches works (just replace
> ">>>>" to what you need at the beginning of line):
>
> ;; Variant 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (defun my-indent-first-line1 ()
> "Indent the first line of each paragraph"
> (interactive)
> (goto-char (point-min))
> (while (not (= (point) (point-max)))
> (forward-paragraph)
> (next-line)
> (insert ">>>>")
> (fill-paragraph)))
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> (fill-paragraph) - is optional, delete it if you don't want refill
> paragraph after inserting
>
> ;; Variant 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (defun my-indent-first-line2 ()
> "Indent the first line of each paragraph"
> (interactive)
> (replace-regexp "\n\n" "\n\n>>>>" nil (point-min) (point-max)))
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Thanks, it seems to work fine. But please now suppose that I want that command
to act only upon the paragraph where the cursor is now and not on the rest of
the document.
Thanks,
Rodolfo
next prev parent reply other threads:[~2016-11-25 11:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-24 15:35 Indent first line of each paragraph of file in one hit Rodolfo Medina
2016-11-24 22:44 ` Rodolfo Medina
2016-11-25 10:48 ` Konstantin Shakhnov
2016-11-25 11:28 ` Rodolfo Medina [this message]
2016-11-25 11:52 ` Rodolfo Medina
2016-11-25 12:15 ` Konstantin Shakhnov
2016-11-25 12:20 ` Rodolfo Medina
2016-11-25 12:45 ` Konstantin Shakhnov
2016-11-25 15:39 ` [solved] " Rodolfo Medina
-- strict thread matches above, loose matches on Subject: below --
2016-11-24 20:18 Rodolfo Medina
2016-11-25 11:34 ` Andreas Röhler
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=87lgw7lrx3.fsf@gmail.com \
--to=rodolfo.medina@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=kastian@mail.ru \
/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.