unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Newline and copy above line's indentation
@ 2018-07-03 12:40 Vas Vas
  2018-07-03 14:21 ` Robert Pluim
  2018-07-03 18:59 ` Eli Zaretskii
  0 siblings, 2 replies; 19+ messages in thread
From: Vas Vas @ 2018-07-03 12:40 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Hello, I've been using emacs since last November, migrating from
vim. Something I've missed is the indentation behaviour, specifically
newline copying the above line's indentation without any
syntax-awareness. I understand emacs' indentation is much more
powerful, but it's easier customising emacs than changing habits. The
hack I've ended up with is:

	(defun copy-whitespace-above-and-indent()
		(interactive)
		(setq old-point (point))
		(previous-line)
		(beginning-of-line)
		(setq start (point))
		(beginning-of-line-text)
		(setq end (point))
		(goto-char old-point)
		(newline)
		(insert (buffer-substring start end)))

I was wondering if there's a more elegant solution to this, such as by
using emacs' existing indentation mechanisms, or by a cleaner
implementation of that function.



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2018-07-23 23:32 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.3005.1530624947.1292.help-gnu-emacs@gnu.org>
2018-07-03 14:03 ` Newline and copy above line's indentation Emanuel Berg
2018-07-03 14:37   ` Emanuel Berg
2018-07-03 14:49     ` Robert Pluim
     [not found]     ` <mailman.3009.1530629379.1292.help-gnu-emacs@gnu.org>
2018-07-03 14:56       ` Emanuel Berg
2018-07-03 15:23         ` Robert Pluim
     [not found]         ` <mailman.3013.1530631400.1292.help-gnu-emacs@gnu.org>
2018-07-03 17:44           ` Emanuel Berg
2018-07-03 16:03 ` HASM
2018-07-03 17:45   ` Emanuel Berg
2018-07-03 21:07     ` HASM
2018-07-03 21:39       ` Emanuel Berg
2018-07-03 22:16         ` HASM
2018-07-04  0:25           ` Dan Espen
2018-07-04  0:58             ` HASM
2018-07-04 13:45               ` Dan Espen
2018-07-04 15:26                 ` HASM
2018-07-23 23:32   ` Stefan Monnier
2018-07-03 12:40 Vas Vas
2018-07-03 14:21 ` Robert Pluim
2018-07-03 18:59 ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).