From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Rodolfo Medina Newsgroups: gmane.emacs.help Subject: Re: Indent first line of each paragraph of file in one hit Date: Fri, 25 Nov 2016 11:52:55 +0000 Message-ID: <87k2brpyi0.fsf@gmail.com> References: <877f7ssxfz.fsf@gmail.com> <20161125104812.GA8781@eee.birulevo.net> <87lgw7lrx3.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1480074818 2054 195.159.176.226 (25 Nov 2016 11:53:38 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 25 Nov 2016 11:53:38 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Konstantin Shakhnov Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Nov 25 12:53:33 2016 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 1cAF4P-00084H-Hs for geh-help-gnu-emacs@m.gmane.org; Fri, 25 Nov 2016 12:53:33 +0100 Original-Received: from localhost ([::1]:45453 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cAF4T-0006AG-78 for geh-help-gnu-emacs@m.gmane.org; Fri, 25 Nov 2016 06:53:37 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cAF3v-0006A0-03 for help-gnu-emacs@gnu.org; Fri, 25 Nov 2016 06:53:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cAF3q-00069u-5y for help-gnu-emacs@gnu.org; Fri, 25 Nov 2016 06:53:03 -0500 Original-Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:38230) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cAF3p-00069Q-VJ for help-gnu-emacs@gnu.org; Fri, 25 Nov 2016 06:52:58 -0500 Original-Received: by mail-wm0-x232.google.com with SMTP id f82so89445159wmf.1 for ; Fri, 25 Nov 2016 03:52:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=D2c8uirPvxlzG46Fv6/rPEAbHHa0Qvste571NrgW00A=; b=zrvetrSWSMmqDqjfg44QSn+EavsWyXefxd9uYprRaJVauiqHbhQCnDwQ711AzIs/3U YMRFUoh3/i2Q6TPAd8McrYG25zALyyfFjNsnWWI9aj3JiGB3oADAQdSv5RcK60sWZ8dv Ax+1fu4/+IKPjSKCCawkHg16oaPDTAqm5d5OT5GCGCY5YlcEJ6SEiIu77kW5LiZiRsFl kkWexiMHM5Yp51ulYpNbLfCTOfONKwoSIxWlEzHcDrjPytboV930OotbmVECZYEUdNsC ki28b1z6KDK8z/2tBMrjI5M44YwlKjnRaBJ+ACRW9Wj1Q3IBua5bTpUBYIHCkDLgphex P3rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=D2c8uirPvxlzG46Fv6/rPEAbHHa0Qvste571NrgW00A=; b=dms13dUy560bhGPojMmQrHlVXWeLRpoLQd0Y/aJeOG7u7by1nyOK4TcMYPddjc/3e7 aIPrFJwQ010WhNYkY4ZcLvnXVRdrL54XvY/uL+Y2u0kcLK7lHz9IutclgS9pS5dFAUQY Y8L8Wxwfc9TH5i6unsPbuxr60yYiBT2OmDgIwZRwDJaluFSqCWWrIsiVXOK9E6VB5eRe c1QWePtc9pyUBMBQj0oWSKqwND/kXMX5ynfpqmaquoilDH/qmF/vsOX11eCWYnGaL1bh smc7TB+aiESbGsqAkeG7gBvcSWUZTKHsTTz9OATAkjS6sYGXNybWoI3EJnUdT4oobBB+ RQGQ== X-Gm-Message-State: AKaTC021ouevtwgsFBYtUMvonRQf2yPijDnTDa7ELEl0ucdJVx1lK3kz8CRa6xTgOFE9LQ== X-Received: by 10.28.208.203 with SMTP id h194mr7089927wmg.45.1480074776561; Fri, 25 Nov 2016 03:52:56 -0800 (PST) Original-Received: from sdb6-pentium3 ([151.70.84.20]) by smtp.gmail.com with ESMTPSA id b15sm13095135wma.5.2016.11.25.03.52.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Nov 2016 03:52:56 -0800 (PST) In-Reply-To: <87lgw7lrx3.fsf@gmail.com> (Rodolfo Medina's message of "Fri, 25 Nov 2016 11:28:40 +0000") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::232 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:111800 Archived-At: Rodolfo Medina writes: > Konstantin Shakhnov 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. This seems to work: (defun my-indent-first-line1 () "Indent the first line of each paragraph" (interactive) (backward-paragraph) (next-line) (insert " ") (fill-paragraph) ) Rodolfo