From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Vas Vas Newsgroups: gmane.emacs.help Subject: Newline and copy above line's indentation Date: Tue, 3 Jul 2018 12:40:22 +0000 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1530624864 10469 195.159.176.226 (3 Jul 2018 13:34:24 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 3 Jul 2018 13:34:24 +0000 (UTC) To: "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 03 15:34:20 2018 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 1faLRi-0002ZE-FG for geh-help-gnu-emacs@m.gmane.org; Tue, 03 Jul 2018 15:34:19 +0200 Original-Received: from localhost ([::1]:40580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faLTp-0006tp-IG for geh-help-gnu-emacs@m.gmane.org; Tue, 03 Jul 2018 09:36:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faKbe-0006tW-0N for help-gnu-emacs@gnu.org; Tue, 03 Jul 2018 08:40:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faKba-0001xs-0x for help-gnu-emacs@gnu.org; Tue, 03 Jul 2018 08:40:29 -0400 Original-Received: from mail-oln040092069010.outbound.protection.outlook.com ([40.92.69.10]:12288 helo=EUR02-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faKbZ-0001uS-9U for help-gnu-emacs@gnu.org; Tue, 03 Jul 2018 08:40:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XUXjji7mcsAM1rfhyhy66EkE/Gl7z7Vl8o40X/kshPE=; b=DlQXIGN+L0uAl0bUcdArewLizJCivMb6fUSKjGe2csd1XClgknhr+aIfk9PL6MQPKSSiXA4OOswNu0HiAYig70U0Tr0OOHKc7Z77WUS2+MlXiJM50kG52b8p11Z36xaXCtk+n/oDikA5SL0y4tqf6UoyuxsJPtoHQdWqprXJGD5OIlHQPMvSV5B35LG49p6gUy0xfxCvAWzWvAUSvFXzyaByg/xnwaV9HUzUALjeWBAm3dHmGczeyydC7wwqX72vu/ArxsrAj45iI7X7K6GhjvF+Rk8qPfWRZty+WRZyV/IG++7FUY9hdk73HLQuUQCMNhX+ymr6qFrVqP1pmgAFew== Original-Received: from VE1EUR02FT016.eop-EUR02.prod.protection.outlook.com (10.152.12.55) by VE1EUR02HT150.eop-EUR02.prod.protection.outlook.com (10.152.13.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.906.15; Tue, 3 Jul 2018 12:40:22 +0000 Original-Received: from DB7P194MB0316.EURP194.PROD.OUTLOOK.COM (10.152.12.58) by VE1EUR02FT016.mail.protection.outlook.com (10.152.12.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.906.15 via Frontend Transport; Tue, 3 Jul 2018 12:40:22 +0000 Original-Received: from DB7P194MB0316.EURP194.PROD.OUTLOOK.COM ([fe80::b92c:3e97:6f5e:927b]) by DB7P194MB0316.EURP194.PROD.OUTLOOK.COM ([fe80::b92c:3e97:6f5e:927b%5]) with mapi id 15.20.0906.026; Tue, 3 Jul 2018 12:40:22 +0000 Thread-Topic: Newline and copy above line's indentation Thread-Index: AQHUEsq8Nb4zUTHiNUOSM/qfPBPsrQ== Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:1219F890B31C2F0CAC2B1E3F99C20E76957C0007F5CDCF35B796D1520D3543AB; UpperCasedChecksum:2D5B81D35CBBAF37FF57094DEA4A00BB263784C162832A787A15ED1D4913CD7E; SizeAsReceived:7002; Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [Z4aR6tbzc6TW5YIHg7bnSXh7g0qA2DqxpDNCQ537jFKGAvL/diLVLV3AtAK1WttX] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VE1EUR02HT150; 7:C2XSPORNjn8UEpUfnQXtHab8hFttp8XE9sOB3M5PqmxwGrExpVb0tFZpO0OfUo97Rff3jvAeSpPvFiGjQ59ivUroIxNm6NXi7wmqkkpAp+wI4r2pjqBsHA8wA+ztochdhXTZbfXtKLODucsmu935Q0ohdKb/EPJEilYJEC/IVsprTwYIYbYija1dkzvfOmaIFYqwcw7J5aeaS0BALEsabncu0ZyW4j7DmjZx6XtvByDZZH0jC9Iz9c30czxkUg0E x-incomingheadercount: 44 x-eopattributedmessage: 0 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322404)(1603101448)(1601125500)(1701031045); SRVR:VE1EUR02HT150; x-ms-traffictypediagnostic: VE1EUR02HT150: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(444000031); SRVR:VE1EUR02HT150; BCL:0; PCL:0; RULEID:; SRVR:VE1EUR02HT150; x-forefront-prvs: 0722981D2A x-forefront-antispam-report: SFV:NSPM; SFS:(7070007)(189003)(199004)(53906005)(476003)(86362001)(6916009)(7696005)(68736007)(6436002)(33656002)(6346003)(486006)(105586002)(14454004)(102836004)(5640700003)(20460500001)(104016004)(256004)(87572001)(8676002)(5660300001)(81156014)(426003)(5250100002)(97736004)(2900100001)(46003)(55016002)(106356001)(82202002)(2501003)(2351001)(25786009)(99286004)(74316002)(305945005)(8936002); DIR:OUT; SFP:1901; SCL:1; SRVR:VE1EUR02HT150; H:DB7P194MB0316.EURP194.PROD.OUTLOOK.COM; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:; received-spf: None (protection.outlook.com: outlook.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=whiterocket@outlook.com; x-microsoft-antispam-message-info: hyDqvSMB3mXT9S75+chxIAudt0HwO3nNGwmsmn4NHdUJ55vZr3Fxfsoq8Rk+sL+Meryft4BhRzWwaC/GocccnR5Fh6jEAoyh7LExdkVWvj6sEZ+ZE6Ca4QzGAz3aC06jUiec2FUPTG1TrBU4LnS2XTDYG259XN8CUdN+9Y1/XGYi+YEdHOPltLvAINmarszdLcWtCZCxcc+qbXiQf7SgU/wXgjZ7m+bOov75aBIyDf8= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 54485d23-c432-40fe-8436-6091d627118c X-MS-Exchange-CrossTenant-Network-Message-Id: 0b16d22c-f18b-4b43-d31a-08d5e0e224b1 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 54485d23-c432-40fe-8436-6091d627118c X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Jul 2018 12:40:22.5017 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR02HT150 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.92.69.10 X-Mailman-Approved-At: Tue, 03 Jul 2018 09:35:46 -0400 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:117322 Archived-At: Hello, I've been using emacs since last November, migrating from=0A= vim. Something I've missed is the indentation behaviour, specifically=0A= newline copying the above line's indentation without any=0A= syntax-awareness. I understand emacs' indentation is much more=0A= powerful, but it's easier customising emacs than changing habits. The=0A= hack I've ended up with is:=0A= =0A= (defun copy-whitespace-above-and-indent()=0A= (interactive)=0A= (setq old-point (point))=0A= (previous-line)=0A= (beginning-of-line)=0A= (setq start (point))=0A= (beginning-of-line-text)=0A= (setq end (point))=0A= (goto-char old-point)=0A= (newline)=0A= (insert (buffer-substring start end)))=0A= =0A= I was wondering if there's a more elegant solution to this, such as by=0A= using emacs' existing indentation mechanisms, or by a cleaner=0A= implementation of that function.=0A=