* Re: Newline and copy above line's indentation
[not found] <mailman.3005.1530624947.1292.help-gnu-emacs@gnu.org>
@ 2018-07-03 14:03 ` Emanuel Berg
2018-07-03 14:37 ` Emanuel Berg
2018-07-03 16:03 ` HASM
1 sibling, 1 reply; 19+ messages in thread
From: Emanuel Berg @ 2018-07-03 14:03 UTC (permalink / raw)
To: help-gnu-emacs
Vas Vas wrote:
> 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:
The particular indentation system is a function
of the mode of the buffer you're in, so step
one is to have the right mode. This should
happen automatically, of course, but make sure
it is right anyway. Because sometimes because
of (mis)configuration and/or very exotic
files/languages it doesn't happen.
If you still feel something is missing please
provide me/us with an exact example of the
above line and what should happen on the line
below. That'll make it easier for us to help.
> (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)))
Some style issues:
1. Instead of storing "old-point" and then
using `goto-char', use `save-excursion' (see
the help for that function:
C-h f save-excursion RET).
2. Instead of `setq', use `let'.
3. Instead of `previous-line', use
`forward-line' with a negative argument.
Find out about points 2 and 3 by byte-compiling
the source:
$ emacs -batch -f byte-compile source.el
See
M-x man emacs RET
or emacs(1) - and ask again if you don't get it
to work, because it is very helpful.
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Newline and copy above line's indentation
[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 16:03 ` HASM
2018-07-03 17:45 ` Emanuel Berg
2018-07-23 23:32 ` Stefan Monnier
1 sibling, 2 replies; 19+ messages in thread
From: HASM @ 2018-07-03 16:03 UTC (permalink / raw)
To: help-gnu-emacs
Vas Vas <whiterocket@outlook.com> writes:
> Something I've missed is the indentation behaviour, specifically
> newline copying the above line's indentation without any
> syntax-awareness.
If you relax a bit on the syntax-awareness, you could use XEmacs'
filladapt. Seems it can't be part on FSF Emacs due to some copyright
issues, but the "latest" version (from 1998) compiles after some minor
fixes and seems to work fine.
-- HASM
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Newline and copy above line's indentation
2018-07-03 16:03 ` HASM
@ 2018-07-03 17:45 ` Emanuel Berg
2018-07-03 21:07 ` HASM
2018-07-23 23:32 ` Stefan Monnier
1 sibling, 1 reply; 19+ messages in thread
From: Emanuel Berg @ 2018-07-03 17:45 UTC (permalink / raw)
To: help-gnu-emacs
HASM wrote:
> If you relax a bit on the syntax-awareness,
> you could use XEmacs' filladapt. Seems it
> can't be part on FSF Emacs due to some
> copyright issues, but the "latest" version
> (from 1998) compiles after some minor fixes
> and seems to work fine.
C'mon now, the Emacs mode should offer
indentation that makes sense. No one should
have to use modules from any other piece of
software to have proper indentation.
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Newline and copy above line's indentation
2018-07-03 17:45 ` Emanuel Berg
@ 2018-07-03 21:07 ` HASM
2018-07-03 21:39 ` Emanuel Berg
0 siblings, 1 reply; 19+ messages in thread
From: HASM @ 2018-07-03 21:07 UTC (permalink / raw)
To: help-gnu-emacs
me> If you relax a bit on the syntax-awareness,
me> you could use XEmacs' filladapt.
eb> C'mon now, the Emacs mode should offer
eb> indentation that makes sense. No one should
eb> have to use modules from any other piece of
eb> software to have proper indentation.
I started with GNU Emacs, switched to XEmacs, used it for a long time,
switched back to GNU a few years ago.
Filladapt.el is the only module that I had to go back for. It does a
better job than GNU Emacs.
Even the emacswiki
https://www.emacswiki.org/emacs/FillAdapt
agrees, and I quote:
Emacs has a builtin AdaptiveFillMode, but filladapt tends to do a better
job. The token table makes filladapt largely mode-agnostic, so common
commenting styles work without a specific adaptive-fill-regexp
setup. And even better compounded forms like email cited text within a
lisp comment fills as you’d hope.
-- HASM
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Newline and copy above line's indentation
2018-07-03 21:07 ` HASM
@ 2018-07-03 21:39 ` Emanuel Berg
2018-07-03 22:16 ` HASM
0 siblings, 1 reply; 19+ messages in thread
From: Emanuel Berg @ 2018-07-03 21:39 UTC (permalink / raw)
To: help-gnu-emacs
HASM wrote:
> Emacs has a builtin AdaptiveFillMode, but
> filladapt tends to do a better job.
> The token table makes filladapt largely
> mode-agnostic, so common commenting styles
> work without a specific
> adaptive-fill-regexp setup. And even better
> compounded forms like email cited text
> within a lisp comment fills as you’d hope.
OK, and this cannot be brought to GNU Emacs
because of incompatible licenses? What does
XEmacs have? GNU Emacs has GNU GPL v3, right?
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Newline and copy above line's indentation
2018-07-03 21:39 ` Emanuel Berg
@ 2018-07-03 22:16 ` HASM
2018-07-04 0:25 ` Dan Espen
0 siblings, 1 reply; 19+ messages in thread
From: HASM @ 2018-07-03 22:16 UTC (permalink / raw)
To: help-gnu-emacs
me> Emacs has a builtin AdaptiveFillMode, but
me> filladapt tends to do a better job.
eb> OK, and this cannot be brought to GNU Emacs
eb> because of incompatible licenses? What does
eb> XEmacs have? GNU Emacs has GNU GPL v3, right?
It may have to do with the underlying licenses, but (and I could be
completely off base here) I seem to remember something to the effect
that the author/copyright owner, didn't agree with the release form
required by GNU/FSF.
-- HASM
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Newline and copy above line's indentation
2018-07-03 22:16 ` HASM
@ 2018-07-04 0:25 ` Dan Espen
2018-07-04 0:58 ` HASM
0 siblings, 1 reply; 19+ messages in thread
From: Dan Espen @ 2018-07-04 0:25 UTC (permalink / raw)
To: help-gnu-emacs
HASM <hasm@example.invalid> writes:
> me> Emacs has a builtin AdaptiveFillMode, but
> me> filladapt tends to do a better job.
>
> eb> OK, and this cannot be brought to GNU Emacs
> eb> because of incompatible licenses? What does
> eb> XEmacs have? GNU Emacs has GNU GPL v3, right?
>
> It may have to do with the underlying licenses, but (and I could be
> completely off base here) I seem to remember something to the effect
> that the author/copyright owner, didn't agree with the release form
> required by GNU/FSF.
According to JWZ:
all of our work on Emacs (and on GCC and GDB) was released under the
GPL. We even assigned the copyright on all of our work back to the
FSF, because we had no proprietary interest in Emacs per se: it was
just a tool that we wanted to use
https://www.jwz.org/doc/lemacs.html
I used lemacs/XEmacs a long time, (until GNU/Emacs caught up and surpassed
XEmacs).
--
Dan Espen
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Newline and copy above line's indentation
2018-07-04 0:25 ` Dan Espen
@ 2018-07-04 0:58 ` HASM
2018-07-04 13:45 ` Dan Espen
0 siblings, 1 reply; 19+ messages in thread
From: HASM @ 2018-07-04 0:58 UTC (permalink / raw)
To: help-gnu-emacs
Dan Espen <dan1espen@gmail.com> writes:
de> According to JWZ:
de> all of our work on Emacs (and on GCC and GDB) was released under the
de> GPL. We even assigned the copyright on all of our work back to the
de> FSF, because we had no proprietary interest in Emacs per se: it was
de> just a tool that we wanted to use
Can't find the reference, but I think the problem is that Kyle Jones was
not part of the "we" in "We even assigned" above.
-- HASM
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Newline and copy above line's indentation
2018-07-04 0:58 ` HASM
@ 2018-07-04 13:45 ` Dan Espen
2018-07-04 15:26 ` HASM
0 siblings, 1 reply; 19+ messages in thread
From: Dan Espen @ 2018-07-04 13:45 UTC (permalink / raw)
To: help-gnu-emacs
HASM <hasm@example.invalid> writes:
> Dan Espen <dan1espen@gmail.com> writes:
>
> de> According to JWZ:
> de> all of our work on Emacs (and on GCC and GDB) was released under the
> de> GPL. We even assigned the copyright on all of our work back to the
> de> FSF, because we had no proprietary interest in Emacs per se: it was
> de> just a tool that we wanted to use
>
> Can't find the reference, but I think the problem is that Kyle Jones was
> not part of the "we" in "We even assigned" above.
https://www.emacswiki.org/emacs/FillAdapt
This work is licensed to you under version 2 of the GNU General Public
License.
I see at least 1 file authored by Kyle in GNU Emacs.
--
Dan Espen
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Newline and copy above line's indentation
2018-07-04 13:45 ` Dan Espen
@ 2018-07-04 15:26 ` HASM
0 siblings, 0 replies; 19+ messages in thread
From: HASM @ 2018-07-04 15:26 UTC (permalink / raw)
To: help-gnu-emacs
> https://www.emacswiki.org/emacs/FillAdapt
> This work is licensed to you under version 2 of the GNU General Public
> License.
Yup, licensed to me, that's why I'm using it :-)
> I see at least 1 file authored by Kyle in GNU Emacs.
I had to patch filladapt.el to run with current Emacs. With Google one
can find several others who did the same. There has to be a reason why
filladapt.el is not distributed with GNU Emacs. Maybe because they
prefer people to use adaptive-fill, maybe because of licensing issues,
not sure anymore.
-- HASM
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Newline and copy above line's indentation
2018-07-03 16:03 ` HASM
2018-07-03 17:45 ` Emanuel Berg
@ 2018-07-23 23:32 ` Stefan Monnier
1 sibling, 0 replies; 19+ messages in thread
From: Stefan Monnier @ 2018-07-23 23:32 UTC (permalink / raw)
To: help-gnu-emacs
> If you relax a bit on the syntax-awareness, you could use XEmacs'
> filladapt. Seems it can't be part on FSF Emacs due to some copyright
It's in GNU ELPA ;-)
Stefan
^ permalink raw reply [flat|nested] 19+ messages in thread
* 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
* Re: 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
1 sibling, 0 replies; 19+ messages in thread
From: Robert Pluim @ 2018-07-03 14:21 UTC (permalink / raw)
To: Vas Vas; +Cc: help-gnu-emacs@gnu.org
Vas Vas <whiterocket@outlook.com> writes:
> 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.
Both are true, I think. Which mode(s) did you want this to work in?
Most modes already do this kind of thing automatically when you hit
RET, perhaps you have customizations that are preventing that from
working.
Robert
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: 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
1 sibling, 0 replies; 19+ messages in thread
From: Eli Zaretskii @ 2018-07-03 18:59 UTC (permalink / raw)
To: help-gnu-emacs
> From: Vas Vas <whiterocket@outlook.com>
> Date: Tue, 3 Jul 2018 12:40:22 +0000
>
> 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.
Look up 'indent-relative'.
^ 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).