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: [solved] Re: Indent first line of each paragraph of file in one hit Date: Fri, 25 Nov 2016 15:39:09 +0000 Message-ID: <87eg1z36xu.fsf_-_@gmail.com> References: <877f7ssxfz.fsf@gmail.com> <20161125104812.GA8781@eee.birulevo.net> <87lgw7lrx3.fsf@gmail.com> <87k2brpyi0.fsf@gmail.com> <20161125121552.GA11459@eee.birulevo.net> <8760nbn42q.fsf@gmail.com> <20161125124539.GA12944@eee.birulevo.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1480088387 28364 195.159.176.226 (25 Nov 2016 15:39:47 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 25 Nov 2016 15:39:47 +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 16:39:43 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 1cAIbE-0006eV-KR for geh-help-gnu-emacs@m.gmane.org; Fri, 25 Nov 2016 16:39:40 +0100 Original-Received: from localhost ([::1]:46751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cAIbI-0000yy-7X for geh-help-gnu-emacs@m.gmane.org; Fri, 25 Nov 2016 10:39:44 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cAIaq-0000yt-AP for help-gnu-emacs@gnu.org; Fri, 25 Nov 2016 10:39:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cAIan-0004MK-7D for help-gnu-emacs@gnu.org; Fri, 25 Nov 2016 10:39:16 -0500 Original-Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:36275) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cAIam-0004L2-Ku for help-gnu-emacs@gnu.org; Fri, 25 Nov 2016 10:39:12 -0500 Original-Received: by mail-wm0-x244.google.com with SMTP id m203so8193191wma.3 for ; Fri, 25 Nov 2016 07:39:12 -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:content-transfer-encoding; bh=LMjb72WpQiTnqNyjtFj3od/XsVxTWyvWC8gbZ/R1qFA=; b=AH2k9EKXnRU1Xg+wrGD0UUilKiJUBJg8Pu2rlzYVoQttuaNUeDOyFQcXNKypEbLTco ErIVG2AeYDNXKiI33WH0HbwNJZZST7E0TBO8wFZvAyvLh8Z4fpoO9yj3IN+Smvd26jJl ZBBNTPBSn3Pp+l+5YhvEyrFTKeb4u8QSjTfauxnNExYP9lhHU4HvjJPH91vSM0ui30/A iCMK+2/zZKNapBe2kqbwDaiK1uk/mHp2ce0J9hIz7LDkhazarXVoAdJ7jzuH5aRmpejm nEFDejvD2QdtJSBQsddt5dk2kRHUn4tfTFLaJODcoag+Mk1BqwAcVe5Np8S48NLXoMKY wu+w== 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:content-transfer-encoding; bh=LMjb72WpQiTnqNyjtFj3od/XsVxTWyvWC8gbZ/R1qFA=; b=cKQvgjmhFNjP9ftNXoDFAUblChvYeQ+pJFePMltpM3vSjJ13YckYme7PeARfzP/ttC bt2d18LtAHizhMB8yC9XzuxDUWi3ljigOgUllA6IJzwQdTMD5Q6E4w7gYACzRiKkdkEN YCVUnNsXONe+YKFjyPmN1rB+/oBrmcUrr/j3eTr/TZvXFoKflf5FAAuM/15NZ/03fu1x nULwiRGti3RVst+NVbKL/4o/6oYegOxClPPze8QaqD/5iXADRBFeCJQXpiYdmsv2YLjW 3g89FJcXs9mnwBEB9zyP7mLFzavyMYhcAPPgEYXLUuKy7egU0Dle4GgJSPHfANdTDAF8 4sVw== X-Gm-Message-State: AKaTC03dwpTYwI/ZgZ0FRWSnejytNxNc3vy6rPB24Zk2ek6Aivf5XKN4n6aBoUmeHcZyWA== X-Received: by 10.28.127.9 with SMTP id a9mr8555740wmd.95.1480088351196; Fri, 25 Nov 2016 07:39:11 -0800 (PST) Original-Received: from sdb6-pentium3 ([151.70.84.20]) by smtp.gmail.com with ESMTPSA id l187sm14024791wml.6.2016.11.25.07.39.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Nov 2016 07:39:10 -0800 (PST) In-Reply-To: <20161125124539.GA12944@eee.birulevo.net> (Konstantin Shakhnov's message of "Fri, 25 Nov 2016 15:45:39 +0300") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::244 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:111808 Archived-At: Konstantin Shakhnov writes: > On Fri, Nov 25, 2016 at 12:20:45PM +0000, Rodolfo Medina wrote: >> Konstantin Shakhnov writes: >> > Yes, I've just made something similar. But there is a trap - if your >> > file doesn't starts with '\n' you'll get wrong indentation of the >> > first paraghaph >> Yes, I see. No way to avoid that? > > (defun my-indent-first-line () > "Indent the first line of current paragraph" > (interactive) > (backward-paragraph) > (if (=3D (line-beginning-position) (line-end-position)) ; if line not e= mpty > (next-line)) > (insert ">>>>") > (fill-paragraph)) > > Not very nice, but seems working. Thanks! =D0=9A=D0=BE=D0=BD=D1=81=D1=82=D0=B0=D0=BD=D1=82=D0=B8=D0=BD also = provided this: (defun my-indent-first-line-of-all-paragraphs () "Indent the first line of each paragraph" (interactive) (save-excursion (goto-char (point-min)) (while (not (=3D (point) (point-max))) (if (=3D (line-beginning-position) (line-end-position)) ; if empty li= ne (next-line)) (insert ">>>>") (fill-paragraph) (forward-paragraph)))) (global-set-key (kbd "C-c i") 'my-indent-all-paragraphs) (defun my-indent-first-line-of-current-paragraph () "Indent the first line of current paragraph" (interactive) (backward-paragraph) (if (=3D (line-beginning-position) (line-end-position)) (next-line)) (insert ">>>>") (fill-paragraph)) (global-set-key (kbd "M-p") 'my-indent-first-line) Thanks to all for these splendid solutions. Cheers, Rodolfo