* Re: Opening multiple files in a single buffer?
2020-06-13 14:31 Opening multiple files in a single buffer? Gregory Heytings
@ 2020-06-13 15:20 ` Douglas Lewan
2020-06-13 16:53 ` Gregory Heytings
2020-06-13 15:21 ` tomas
` (3 subsequent siblings)
4 siblings, 1 reply; 31+ messages in thread
From: Douglas Lewan @ 2020-06-13 15:20 UTC (permalink / raw)
To: help-gnu-emacs
On 6/13/20 10:31 AM, Gregory Heytings wrote:
>
> Dear List,
>
> I've now been using Emacs for many, many years, and there is perhaps a
> single feature I'm really missing, namely opening more than one file
> in a single buffer, with the contents of the files appearing one after
> the other in the same buffer, with some kind of visual separator
> between them. I don't know if that feature exists in other text editors.
>
> For example, suppose you write a book, which has fifteen chapters in
> files chap1.tex, ..., chap15.tex. Opening these files in a single
> buffer means that you could use isearch-{forward,backward} in the
> whole book. (I know that multi-isearch-buffers could be used in this
> particular case, but it is not as convenient to use.) You could also
> use query-replace on the whole book, or reindent all files, or execute
> shell-command on all files at once, and so forth. (Again I know that
> all this can be done with already existing features, e.g. through
> dired, but again I find them not as convenient as what I have in mind.)
>
> Each file would have its own major and minor modes, and the mode-line
> would adapt depending on the file corresponding to the buffer portion
> in which the point is currently located.
>
> My question is: Is this feasible, or is the one-to-one correspondence
> between buffers and files too deeply rooted in Emacs' codebase that it
> is not feasible? If it is feasible, could this feature be considered
> for implementation in a future Emacs version?
I would say it's feasible, but probably awkward as stated. An
application that implements something similar via a sequence of buffers
with a way of navigating next and previous and providing appropriate
commands via a (map) function would probably be simpler to build and
manage. It would also be much more natural.
--
,Doug
d.lewan2000@gmail.com
(908) 720 7908
If this is what winning looks like, I'd hate to see what losing is.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-13 15:20 ` Douglas Lewan
@ 2020-06-13 16:53 ` Gregory Heytings
0 siblings, 0 replies; 31+ messages in thread
From: Gregory Heytings @ 2020-06-13 16:53 UTC (permalink / raw)
To: help-gnu-emacs
Douglas Lewan:
>
>> I've now been using Emacs for many, many years, and there is perhaps a
>> single feature I'm really missing, namely opening more than one file in
>> a single buffer, with the contents of the files appearing one after the
>> other in the same buffer, with some kind of visual separator between
>> them. I don't know if that feature exists in other text editors.
>>
>> For example, suppose you write a book, which has fifteen chapters in
>> files chap1.tex, ..., chap15.tex. Opening these files in a single
>> buffer means that you could use isearch-{forward,backward} in the whole
>> book. (I know that multi-isearch-buffers could be used in this
>> particular case, but it is not as convenient to use.) You could also
>> use query-replace on the whole book, or reindent all files, or execute
>> shell-command on all files at once, and so forth. (Again I know that
>> all this can be done with already existing features, e.g. through
>> dired, but again I find them not as convenient as what I have in mind.)
>>
>> Each file would have its own major and minor modes, and the mode-line
>> would adapt depending on the file corresponding to the buffer portion
>> in which the point is currently located.
>>
>> My question is: Is this feasible, or is the one-to-one correspondence
>> between buffers and files too deeply rooted in Emacs' codebase that it
>> is not feasible? If it is feasible, could this feature be considered
>> for implementation in a future Emacs version?
>
> I would say it's feasible, but probably awkward as stated. An
> application that implements something similar via a sequence of buffers
> with a way of navigating next and previous and providing appropriate
> commands via a (map) function would probably be simpler to build and
> manage. It would also be much more natural.
>
In fact, what I have in mind is not an additional application, but a core
feature, that would be transparent (or almost transparent) to everything
else. It would not require a rewrite of any command. For example it
would also be possible to narrow the (multi-file) buffer to the last X
lines of a file and the first Y lines of the next file in the buffer.
Gregory
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-13 14:31 Opening multiple files in a single buffer? Gregory Heytings
2020-06-13 15:20 ` Douglas Lewan
@ 2020-06-13 15:21 ` tomas
2020-06-13 15:36 ` Douglas Lewan
2020-06-13 15:49 ` Jakub Jankiewicz
` (2 subsequent siblings)
4 siblings, 1 reply; 31+ messages in thread
From: tomas @ 2020-06-13 15:21 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 530 bytes --]
On Sat, Jun 13, 2020 at 02:31:52PM +0000, Gregory Heytings wrote:
>
> Dear List,
>
> I've now been using Emacs for many, many years, and there is perhaps
> a single feature I'm really missing, namely opening more than one
> file in a single buffer, with the contents of the files appearing
> one after the other in the same buffer, with some kind of visual
> separator between them. I don't know if that feature exists in other
> text editors.
Would "insert-file" (bound to C-x i) do what you want?
Cheers
-- t
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-13 15:21 ` tomas
@ 2020-06-13 15:36 ` Douglas Lewan
2020-06-13 15:53 ` tomas
0 siblings, 1 reply; 31+ messages in thread
From: Douglas Lewan @ 2020-06-13 15:36 UTC (permalink / raw)
To: help-gnu-emacs
On 6/13/20 11:21 AM, tomas@tuxteam.de wrote:
> On Sat, Jun 13, 2020 at 02:31:52PM +0000, Gregory Heytings wrote:
>> Dear List,
>>
>> I've now been using Emacs for many, many years, and there is perhaps
>> a single feature I'm really missing, namely opening more than one
>> file in a single buffer, with the contents of the files appearing
>> one after the other in the same buffer, with some kind of visual
>> separator between them. I don't know if that feature exists in other
>> text editors.
> Would "insert-file" (bound to C-x i) do what you want?
>
> Cheers
> -- t
For what he wants, that wouldn't handle multiple modes very easily. I
also assume that there's a desire to be able to save back to the
original files again which would require more work.
--
,Doug
d.lewan2000@gmail.com
(908) 720 7908
If this is what winning looks like, I'd hate to see what losing is.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-13 14:31 Opening multiple files in a single buffer? Gregory Heytings
2020-06-13 15:20 ` Douglas Lewan
2020-06-13 15:21 ` tomas
@ 2020-06-13 15:49 ` Jakub Jankiewicz
2020-06-13 16:43 ` Stefan Monnier
2020-06-13 18:10 ` Dan Hitt
4 siblings, 0 replies; 31+ messages in thread
From: Jakub Jankiewicz @ 2020-06-13 15:49 UTC (permalink / raw)
To: Gregory Heytings; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 2171 bytes --]
On Sat, 13 Jun 2020 14:31:52 +0000
Gregory Heytings <ghe@sdf.org> wrote:
> Dear List,
>
> I've now been using Emacs for many, many years, and there is perhaps a
> single feature I'm really missing, namely opening more than one file in a
> single buffer, with the contents of the files appearing one after the
> other in the same buffer, with some kind of visual separator between them.
> I don't know if that feature exists in other text editors.
>
> For example, suppose you write a book, which has fifteen chapters in files
> chap1.tex, ..., chap15.tex. Opening these files in a single buffer means
> that you could use isearch-{forward,backward} in the whole book. (I know
> that multi-isearch-buffers could be used in this particular case, but it
> is not as convenient to use.) You could also use query-replace on the
> whole book, or reindent all files, or execute shell-command on all files
> at once, and so forth. (Again I know that all this can be done with
> already existing features, e.g. through dired, but again I find them not
> as convenient as what I have in mind.)
>
> Each file would have its own major and minor modes, and the mode-line
> would adapt depending on the file corresponding to the buffer portion in
> which the point is currently located.
>
> My question is: Is this feasible, or is the one-to-one correspondence
> between buffers and files too deeply rooted in Emacs' codebase that it is
> not feasible? If it is feasible, could this feature be considered for
> implementation in a future Emacs version?
I think it's doable, it may require lot of work, to do this right though.
The only limitation I think is that you may have problems with multiple major
modes, but there is mode that do that polymode use different major modes in
same buffer and since you can create almost anything in Emacs (e.g. ERC,
dired mode or web browser) you probably can create something like this.
If you know ELips you can try writing something like this. Probably user will
use it to edit books if it would be easy to use.
--
Jakub Jankiewicz, Web Developer
https://jcubic.pl/me
[-- Attachment #2: Podpis cyfrowy OpenPGP --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-13 14:31 Opening multiple files in a single buffer? Gregory Heytings
` (2 preceding siblings ...)
2020-06-13 15:49 ` Jakub Jankiewicz
@ 2020-06-13 16:43 ` Stefan Monnier
2020-06-14 11:11 ` Michael Albinus
` (3 more replies)
2020-06-13 18:10 ` Dan Hitt
4 siblings, 4 replies; 31+ messages in thread
From: Stefan Monnier @ 2020-06-13 16:43 UTC (permalink / raw)
To: help-gnu-emacs
> For example, suppose you write a book, which has fifteen chapters in files
> chap1.tex, ..., chap15.tex. Opening these files in a single buffer means
> that you could use isearch-{forward,backward} in the whole book.
I don't know of any package which does that.
But I think it should not be too hard to implement something that
handles this particular use case.
For files that use different major modes, it'd be more problematic,
of course.
Stefan
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-13 16:43 ` Stefan Monnier
@ 2020-06-14 11:11 ` Michael Albinus
2020-06-15 8:26 ` Gregory Heytings
` (2 subsequent siblings)
3 siblings, 0 replies; 31+ messages in thread
From: Michael Albinus @ 2020-06-14 11:11 UTC (permalink / raw)
To: Stefan Monnier; +Cc: help-gnu-emacs
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> For example, suppose you write a book, which has fifteen chapters in files
>> chap1.tex, ..., chap15.tex. Opening these files in a single buffer means
>> that you could use isearch-{forward,backward} in the whole book.
>
> I don't know of any package which does that.
> But I think it should not be too hard to implement something that
> handles this particular use case.
>
> For files that use different major modes, it'd be more problematic,
> of course.
Another problem might be setting default-directory for that buffer, if
these files don't belong to the same directory.
> Stefan
Best regards, Michael.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-13 16:43 ` Stefan Monnier
2020-06-14 11:11 ` Michael Albinus
@ 2020-06-15 8:26 ` Gregory Heytings
2020-06-15 9:33 ` tomas
` (2 more replies)
2020-06-15 12:21 ` Sergey Organov
2020-06-15 15:26 ` Gregory Heytings
3 siblings, 3 replies; 31+ messages in thread
From: Gregory Heytings @ 2020-06-15 8:26 UTC (permalink / raw)
To: help-gnu-emacs
>
>> For example, suppose you write a book, which has fifteen chapters in
>> files chap1.tex, ..., chap15.tex. Opening these files in a single
>> buffer means that you could use isearch-{forward,backward} in the whole
>> book.
>
> I don't know of any package which does that. But I think it should not
> be too hard to implement something that handles this particular use
> case.
>
> For files that use different major modes, it'd be more problematic, of
> course.
>
It's not just that particular use case that I have in mind. As I wrote
earlier, the feature I have in mind should not be an additional (minor or
major) mode, but a core feature, adding the possibility for Emacs users to
open multiple files in a single buffer, in a way that would be as
transparent as possible to everything else. Or, in other words, to work
on a list of buffers as if it were a single buffer. Otherwise it would
indeed be necessary to reimplement many (possibly all) commands, and other
problem would have to be resolved, with a result that would likely be too
inefficient.
My question was: Is this feasible, or is the one-to-one correspondence
between buffers and files too deeply rooted in Emacs' codebase that it is
not feasible? If it is feasible, could this feature be considered for
implementation in a future Emacs version?
Gregory
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-15 8:26 ` Gregory Heytings
@ 2020-06-15 9:33 ` tomas
2020-06-15 9:52 ` Gregory Heytings
2020-06-15 12:48 ` Joost Kremers
2020-06-15 14:41 ` Stefan Monnier
2 siblings, 1 reply; 31+ messages in thread
From: tomas @ 2020-06-15 9:33 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 557 bytes --]
On Mon, Jun 15, 2020 at 08:26:46AM +0000, Gregory Heytings wrote:
[...]
> It's not just that particular use case that I have in mind. As I
> wrote earlier, the feature I have in mind should not be an
> additional (minor or major) mode, but a core feature [...]
I'd recommend to aim lower at first. The modes and packages are a big
help for people not to step on each other's toes. Trying something
new with the approach "I think everyone should have it" is a tall
order, especially with a community as diverse as Emacs.
Cheers
-- tomás
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-15 9:33 ` tomas
@ 2020-06-15 9:52 ` Gregory Heytings
2020-06-15 10:58 ` tomas
0 siblings, 1 reply; 31+ messages in thread
From: Gregory Heytings @ 2020-06-15 9:52 UTC (permalink / raw)
To: help-gnu-emacs
>
>> It's not just that particular use case that I have in mind. As I wrote
>> earlier, the feature I have in mind should not be an additional (minor
>> or major) mode, but a core feature [...]
>
> I'd recommend to aim lower at first. The modes and packages are a big
> help for people not to step on each other's toes. Trying something new
> with the approach "I think everyone should have it" is a tall order,
> especially with a community as diverse as Emacs.
>
I understand your viewpoint. I'm proposing something, I'm not ordering
anything. It just happens that this idea cannot be implemented with a
mode or a package, like proportional fonts for example. Making this
possible would not change anything for users who would not want to use it.
If it is not possible to implement this, or if nobody else thinks it would
be useful, that's fine.
Gregory
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-15 9:52 ` Gregory Heytings
@ 2020-06-15 10:58 ` tomas
0 siblings, 0 replies; 31+ messages in thread
From: tomas @ 2020-06-15 10:58 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1259 bytes --]
On Mon, Jun 15, 2020 at 09:52:52AM +0000, Gregory Heytings wrote:
>
> >
> >>It's not just that particular use case that I have in mind. As
> >>I wrote earlier, the feature I have in mind should not be an
> >>additional (minor or major) mode, but a core feature [...]
> >
> >I'd recommend to aim lower at first [...]
> I understand your viewpoint. I'm proposing something, I'm not
> ordering anything. It just happens that this idea cannot be
> implemented with a mode or a package, like proportional fonts for
> example.
Hm. To be proven :-)
> Making this possible would not change anything for users
> who would not want to use it.
Likewise. Emacs is a complex beast, but for a reason: it reflects
a wildly diverse community, which came together over many years
and use it in staggeringly different ways. Changing something in
core will almost surely have consequences you didn't plan for :)
> If it is not possible to implement
> this, or if nobody else thinks it would be useful, that's fine.
Mine was just an assessment. I don't speak (by far!) for the Emacs
community. I was just musing that you might have better chances
of trying things out if you don't aim straight at core.
Cheers
-- t
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-15 8:26 ` Gregory Heytings
2020-06-15 9:33 ` tomas
@ 2020-06-15 12:48 ` Joost Kremers
2020-06-15 14:24 ` Gregory Heytings
2020-06-15 14:41 ` Stefan Monnier
2 siblings, 1 reply; 31+ messages in thread
From: Joost Kremers @ 2020-06-15 12:48 UTC (permalink / raw)
To: help-gnu-emacs
On Mon, Jun 15 2020, Gregory Heytings wrote:
> My question was: Is this feasible, or is the one-to-one
> correspondence
> between buffers and files too deeply rooted in Emacs' codebase
> that it is
> not feasible? If it is feasible, could this feature be
> considered for
> implementation in a future Emacs version?
I can't tell you how feasible it would be, but unless you want to
implement it yourself, you'll probably have to do some more
convincing in order to get someone to implement it for you. As you
said yourself, the potential use cases for such a multi-file
buffer are easily covered by other means. There is `multi-occur`
for searching in multiple buffers, there are front-ends to e.g.,
ripgrep (I use `counsel-rg` self) to search through multiple files
and with `wgrep` you can then edit those occurrences in one go. (I
use `multiple-cursors`, but you can also do a search and replace
in the multi-occur buffer.)
The point is, for something like this to be implemented, there
needs to be someone to do it. And for something that appears to be
quite a fundamental change with relatively little gain, it's
unlikely you'll find an experienced Emacs dev to pick up the task.
--
Joost Kremers
Life has its moments
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-15 12:48 ` Joost Kremers
@ 2020-06-15 14:24 ` Gregory Heytings
0 siblings, 0 replies; 31+ messages in thread
From: Gregory Heytings @ 2020-06-15 14:24 UTC (permalink / raw)
To: help-gnu-emacs
>
> I can't tell you how feasible it would be, but unless you want to
> implement it yourself, you'll probably have to do some more convincing
> in order to get someone to implement it for you. As you said yourself,
> the potential use cases for such a multi-file buffer are easily covered
> by other means.
>
Are covered: yes. Are easily covered: no. If you take the tool-bar,
everything it offers is (very!) easily covered by other means. Yet it
exists, because it makes these things easier for some users.
>
> There is `multi-occur` for searching in multiple buffers, there are
> front-ends to e.g., ripgrep (I use `counsel-rg` self) to search through
> multiple files and with `wgrep` you can then edit those occurrences in
> one go. (I use `multiple-cursors`, but you can also do a search and
> replace in the multi-occur buffer.)
>
Yes, these tools exist. Yet I'd bet that many users would find a
multi-file buffer far easier to use than these tools. Many users find it
easier to use customize than to type Emacs LISP code by hand in their
.emacs file.
Gregory
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-15 8:26 ` Gregory Heytings
2020-06-15 9:33 ` tomas
2020-06-15 12:48 ` Joost Kremers
@ 2020-06-15 14:41 ` Stefan Monnier
2 siblings, 0 replies; 31+ messages in thread
From: Stefan Monnier @ 2020-06-15 14:41 UTC (permalink / raw)
To: help-gnu-emacs
>> I don't know of any package which does that. But I think it should not be
>> too hard to implement something that handles this particular use case.
>> For files that use different major modes, it'd be more problematic,
>> of course.
> It's not just that particular use case that I have in mind. As I wrote
> earlier, the feature I have in mind should not be an additional (minor or
> major) mode,
You're making assumptions about how Emacs works.
I did not say that it should be implemented as a (minor or major) mode.
> My question was: Is this feasible,
As I said, I think it should be easy to implement.
I also gave some pointers to get started.
> or is the one-to-one correspondence between buffers and files too
> deeply rooted in Emacs' codebase that it is not feasible?
It's not deeply rooted, no. What is more difficult is to handle various
kinds of data (i.e. multiple major modes) in a single buffer.
> If it is feasible, could this feature be considered for implementation
> in a future Emacs version?
The underlying functionality needed for that has existed in Emacs "for
ever", so no need for a future Emacs. Someone just needs to implement
it and make it available as a package.
Stefan
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-13 16:43 ` Stefan Monnier
2020-06-14 11:11 ` Michael Albinus
2020-06-15 8:26 ` Gregory Heytings
@ 2020-06-15 12:21 ` Sergey Organov
2020-06-15 15:26 ` Gregory Heytings
3 siblings, 0 replies; 31+ messages in thread
From: Sergey Organov @ 2020-06-15 12:21 UTC (permalink / raw)
To: Stefan Monnier; +Cc: help-gnu-emacs
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> For example, suppose you write a book, which has fifteen chapters in files
>> chap1.tex, ..., chap15.tex. Opening these files in a single buffer means
>> that you could use isearch-{forward,backward} in the whole book.
>
> I don't know of any package which does that.
> But I think it should not be too hard to implement something that
> handles this particular use case.
I think there could be parts of the puzzle to borrow in the wgrep.el:
https://www.emacswiki.org/emacs/wgrep.el
that is capable to save changes made in a single grep buffer into
corresponding files.
-- Sergey
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-13 16:43 ` Stefan Monnier
` (2 preceding siblings ...)
2020-06-15 12:21 ` Sergey Organov
@ 2020-06-15 15:26 ` Gregory Heytings
2020-06-15 15:31 ` Perry Smith
3 siblings, 1 reply; 31+ messages in thread
From: Gregory Heytings @ 2020-06-15 15:26 UTC (permalink / raw)
To: help-gnu-emacs
>
> As I said, I think it should be easy to implement.
> I also gave some pointers to get started.
>
> [...]
>
> The underlying functionality needed for that has existed in Emacs "for
> ever", so no need for a future Emacs. Someone just needs to implement
> it and make it available as a package.
>
Okay, thank you, I'll have a look at this. Your sentence "For files that
use different major modes, it'd be more problematic, of course." made me
think you were suggesting something that would not do what I have in mind,
but I was wrong.
Gregory
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-15 15:26 ` Gregory Heytings
@ 2020-06-15 15:31 ` Perry Smith
0 siblings, 0 replies; 31+ messages in thread
From: Perry Smith @ 2020-06-15 15:31 UTC (permalink / raw)
To: Gregory Heytings; +Cc: help-gnu-emacs
> On Jun 15, 2020, at 10:26 AM, Gregory Heytings <ghe@sdf.org> wrote:
>
>
>>
>> As I said, I think it should be easy to implement.
>> I also gave some pointers to get started.
>>
>> [...]
>>
>> The underlying functionality needed for that has existed in Emacs "for ever", so no need for a future Emacs. Someone just needs to implement it and make it available as a package.
>>
>
> Okay, thank you, I'll have a look at this. Your sentence "For files that use different major modes, it'd be more problematic, of course." made me think you were suggesting something that would not do what I have in mind, but I was wrong.
The major modes per file is “problematic” but it has been “done” kinda sorta. You can look at mmm-mode <https://www.emacswiki.org/emacs/MmmMode>. I’ve toyed with it a little and decided to go another path.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-13 14:31 Opening multiple files in a single buffer? Gregory Heytings
` (3 preceding siblings ...)
2020-06-13 16:43 ` Stefan Monnier
@ 2020-06-13 18:10 ` Dan Hitt
2020-06-13 18:41 ` Jakub Jankiewicz
` (2 more replies)
4 siblings, 3 replies; 31+ messages in thread
From: Dan Hitt @ 2020-06-13 18:10 UTC (permalink / raw)
To: Gregory Heytings; +Cc: help-gnu-emacs
On Sat, Jun 13, 2020 at 7:41 AM Gregory Heytings <ghe@sdf.org> wrote:
>
> .....
>
> For example, suppose you write a book, which has fifteen chapters in files
> chap1.tex, ..., chap15.tex. Opening these files in a single buffer means
> that you could use isearch-{forward,backward} in the whole book. (I know
> that multi-isearch-buffers could be used in this particular case, but it
> is not as convenient to use.) You could also use query-replace on the
> whole book, or reindent all files, or execute shell-command on all files
> at once, and so forth. (Again I know that all this can be done with
> already existing features, e.g. through dired, but again I find them not
> as convenient as what I have in mind.)
>
> Each file would have its own major and minor modes, and the mode-line
> would adapt depending on the file corresponding to the buffer portion in
> which the point is currently located.
>
>
>
Another application would be to open all the code files in a directory into
a single buffer, and do replace-string or query-replace on all of them, to
rename variables, for example. You'd want to be able to mark the
sub-buffers read-only or not independently, since (e.g.) not all of them
might be owned by the same account. And you might want to make a provision
so that one file could appear more than once in the linear list of
sub-buffers (as could happen naturally with links).
I think your idea is a real winner.
I have no idea how hard it would be to implement, but could it be just a
matter of making a new kind of buffer, say a multi-file buffer, and then
just specifying the new behavior for all buffer functions for this new kind
of buffer?
dan
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-13 18:10 ` Dan Hitt
@ 2020-06-13 18:41 ` Jakub Jankiewicz
2020-06-13 18:41 ` Eli Zaretskii
2020-06-13 19:31 ` Stefan Monnier
2 siblings, 0 replies; 31+ messages in thread
From: Jakub Jankiewicz @ 2020-06-13 18:41 UTC (permalink / raw)
To: Dan Hitt; +Cc: Gregory Heytings, help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 2423 bytes --]
On Sat, 13 Jun 2020 11:10:00 -0700
Dan Hitt <dan.hitt@gmail.com> wrote:
> On Sat, Jun 13, 2020 at 7:41 AM Gregory Heytings <ghe@sdf.org> wrote:
>
> >
> > .....
> >
> > For example, suppose you write a book, which has fifteen chapters in files
> > chap1.tex, ..., chap15.tex. Opening these files in a single buffer means
> > that you could use isearch-{forward,backward} in the whole book. (I know
> > that multi-isearch-buffers could be used in this particular case, but it
> > is not as convenient to use.) You could also use query-replace on the
> > whole book, or reindent all files, or execute shell-command on all files
> > at once, and so forth. (Again I know that all this can be done with
> > already existing features, e.g. through dired, but again I find them not
> > as convenient as what I have in mind.)
> >
> > Each file would have its own major and minor modes, and the mode-line
> > would adapt depending on the file corresponding to the buffer portion in
> > which the point is currently located.
> >
> >
> >
> Another application would be to open all the code files in a directory into
> a single buffer, and do replace-string or query-replace on all of them, to
> rename variables, for example. You'd want to be able to mark the
> sub-buffers read-only or not independently, since (e.g.) not all of them
> might be owned by the same account. And you might want to make a provision
> so that one file could appear more than once in the linear list of
> sub-buffers (as could happen naturally with links).
>
> I think your idea is a real winner.
>
> I have no idea how hard it would be to implement, but could it be just a
> matter of making a new kind of buffer, say a multi-file buffer, and then
> just specifying the new behavior for all buffer functions for this new kind
> of buffer?
It can be just multi-file-mode major mode where you open file/buffers as
linked list and have functions that operate on that list like on one buffer.
You should be able to add and remove file/buffers form that list. With this
you will be able to write lisp function that open all the files and create a
list. Then you will need to implement the display.
I'm not elisp expert, but it look like something you can try to create. Maybe
start with POC to test if something like this is possible.
--
Jakub Jankiewicz, Web Developer
https://jcubic.pl/me
[-- Attachment #2: Podpis cyfrowy OpenPGP --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-13 18:10 ` Dan Hitt
2020-06-13 18:41 ` Jakub Jankiewicz
@ 2020-06-13 18:41 ` Eli Zaretskii
2020-06-13 19:22 ` Gregory Heytings
2020-06-13 19:31 ` Stefan Monnier
2 siblings, 1 reply; 31+ messages in thread
From: Eli Zaretskii @ 2020-06-13 18:41 UTC (permalink / raw)
To: help-gnu-emacs
> From: Dan Hitt <dan.hitt@gmail.com>
> Date: Sat, 13 Jun 2020 11:10:00 -0700
> Cc: help-gnu-emacs@gnu.org
>
> Another application would be to open all the code files in a directory into
> a single buffer, and do replace-string or query-replace on all of them, to
> rename variables, for example.
We have a special Dired command to do such renaming.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-13 18:41 ` Eli Zaretskii
@ 2020-06-13 19:22 ` Gregory Heytings
2020-06-13 19:45 ` Perry Smith
0 siblings, 1 reply; 31+ messages in thread
From: Gregory Heytings @ 2020-06-13 19:22 UTC (permalink / raw)
To: help-gnu-emacs
>
>> Another application would be to open all the code files in a directory
>> into a single buffer, and do replace-string or query-replace on all of
>> them, to rename variables, for example.
>
> We have a special Dired command to do such renaming.
>
Indeed, but that's not the point. As I said what I'm proposing is a way
to do some things more easily (for some users). Everything that could be
done with such a feature can already be done in other ways. I don't use
the menu-bar, the tool-bar, customize, or the menus on the mode-line. But
I do not consider that they are useless. All these features make it
possible to do things more easily (for some users), that can already be
done in other ways.
Gregory
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-13 19:22 ` Gregory Heytings
@ 2020-06-13 19:45 ` Perry Smith
2020-06-13 20:42 ` Gregory Heytings
0 siblings, 1 reply; 31+ messages in thread
From: Perry Smith @ 2020-06-13 19:45 UTC (permalink / raw)
To: Gregory Heytings; +Cc: help-gnu-emacs
> On Jun 13, 2020, at 2:22 PM, Gregory Heytings <ghe@sdf.org> wrote:
>
>
>>
>>> Another application would be to open all the code files in a directory into a single buffer, and do replace-string or query-replace on all of them, to rename variables, for example.
>>
>> We have a special Dired command to do such renaming.
>>
>
> Indeed, but that's not the point. As I said what I'm proposing is a way to do some things more easily (for some users). Everything that could be done with such a feature can already be done in other ways. I don't use the menu-bar, the tool-bar, customize, or the menus on the mode-line. But I do not consider that they are useless. All these features make it possible to do things more easily (for some users), that can already be done in other ways.
Before you decide to dive into this, I would suggest doing a test run by writing a simple script to cat the files together with a separator and edit that file with something like search and replace or bounce around in various places making edits. I have vague memories that when buffers get extremely big, emacs slows down considerably but my memories are not clear enough to recall the exact circumstances. Perhaps one of the emacs maintainers can jump in and comment. Is emacs going to be more efficient with several “small” buffers rather than one extremely large buffer. Some of the people commenting are wanting to load up an entire project into a single buffer. As I recall, that is going to be very unfriendly to use.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-13 19:45 ` Perry Smith
@ 2020-06-13 20:42 ` Gregory Heytings
2020-06-14 5:29 ` Arthur Miller
0 siblings, 1 reply; 31+ messages in thread
From: Gregory Heytings @ 2020-06-13 20:42 UTC (permalink / raw)
To: help-gnu-emacs
>
>> Indeed, but that's not the point. As I said what I'm proposing is a
>> way to do some things more easily (for some users). Everything that
>> could be done with such a feature can already be done in other ways.
>> I don't use the menu-bar, the tool-bar, customize, or the menus on the
>> mode-line. But I do not consider that they are useless. All these
>> features make it possible to do things more easily (for some users),
>> that can already be done in other ways.
>
> Before you decide to dive into this, I would suggest doing a test run by
> writing a simple script to cat the files together with a separator and
> edit that file with something like search and replace or bounce around
> in various places making edits. I have vague memories that when buffers
> get extremely big, emacs slows down considerably but my memories are not
> clear enough to recall the exact circumstances.
>
> Perhaps one of the emacs maintainers can jump in and comment. Is emacs
> going to be more efficient with several “small” buffers rather than one
> extremely large buffer. Some of the people commenting are wanting to
> load up an entire project into a single buffer. As I recall, that is
> going to be very unfriendly to use.
>
That's not correct. On my laptop, I can easily edit a 100 (one hundred)
MB text file, Emacs is almost as reactive as with a 1 KB text file. Of
course some operations take more time, e.g. a query-replace-regexp on the
whole buffer, but from what I see (on my laptop it takes about four
seconds, with a regexp) I doubt that it takes more time than hundred
query-replace-regexp in a 1 MB file, or for that matter than doing this
with dired on hundred 1 MB files.
Gregory
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-13 20:42 ` Gregory Heytings
@ 2020-06-14 5:29 ` Arthur Miller
2020-06-14 7:12 ` Gregory Heytings
0 siblings, 1 reply; 31+ messages in thread
From: Arthur Miller @ 2020-06-14 5:29 UTC (permalink / raw)
To: Gregory Heytings; +Cc: help-gnu-emacs
Gregory Heytings <ghe@sdf.org> writes:
>>
>>> Indeed, but that's not the point. As I said what I'm proposing is a way to
>>> do some things more easily (for some users). Everything that could be done
>>> with such a feature can already be done in other ways. I don't use the
>>> menu-bar, the tool-bar, customize, or the menus on the mode-line. But I do
>>> not consider that they are useless. All these features make it possible to
>>> do things more easily (for some users), that can already be done in other
>>> ways.
>>
>> Before you decide to dive into this, I would suggest doing a test run by
>> writing a simple script to cat the files together with a separator and
>> edit that file with something like search and replace or bounce around in
>> various places making edits. I have vague memories that when buffers get
>> extremely big, emacs slows down considerably but my memories are not clear
>> enough to recall the exact circumstances.
>>
>> Perhaps one of the emacs maintainers can jump in and comment. Is emacs going
>> to be more efficient with several “small” buffers rather than one extremely
>> large buffer. Some of the people commenting are wanting to load up an entire
>> project into a single buffer. As I recall, that is going to be very
>> unfriendly to use.
>>
>
> That's not correct. On my laptop, I can easily edit a 100 (one hundred) MB text
> file, Emacs is almost as reactive as with a 1 KB text file. Of course some
> operations take more time, e.g. a query-replace-regexp on the whole buffer, but
> from what I see (on my laptop it takes about four seconds, with a regexp) I
> doubt that it takes more time than hundred query-replace-regexp in a 1 MB file,
> or for that matter than doing this with dired on hundred 1 MB files.
>
> Gregory
I think it depends on content in those files as well as of size.
Try to edit some of those two files: https://github.com/amno1/Plato ,
possibly Plato.org. Don't just display them, but try to actually put
some text note in it or add/remove some whitespace or whatever. Jump to
some paragraph and insert a new line and see how long it takes. Then try
to do same in Atom text editor.
My Emacs takes quite some time even to add a white space char while Atom
has not problems whatsoever. I run on 6700K i7 cpu + 32 gig 3000Mhz
ram.
I don't know what the problem is, if it is just my Emacs config or
actually underlaying data structure (Gap buffer vs linked structure optimized
for changes - their "Superstring").
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-14 5:29 ` Arthur Miller
@ 2020-06-14 7:12 ` Gregory Heytings
2020-06-14 7:45 ` Arthur Miller
0 siblings, 1 reply; 31+ messages in thread
From: Gregory Heytings @ 2020-06-14 7:12 UTC (permalink / raw)
To: help-gnu-emacs
>
>> That's not correct. On my laptop, I can easily edit a 100 (one
>> hundred) MB text file, Emacs is almost as reactive as with a 1 KB text
>> file. Of course some operations take more time, e.g. a
>> query-replace-regexp on the whole buffer, but from what I see (on my
>> laptop it takes about four seconds, with a regexp) I doubt that it
>> takes more time than hundred query-replace-regexp in a 1 MB file, or
>> for that matter than doing this with dired on hundred 1 MB files.
>>
> I think it depends on content in those files as well as of size.
>
> Try to edit some of those two files: https://github.com/amno1/Plato ,
> possibly Plato.org. Don't just display them, but try to actually put
> some text note in it or add/remove some whitespace or whatever. Jump to
> some paragraph and insert a new line and see how long it takes. Then try
> to do same in Atom text editor.
>
> My Emacs takes quite some time even to add a white space char while Atom
> has not problems whatsoever. I run on 6700K i7 cpu + 32 gig 3000Mhz ram.
>
> I don't know what the problem is, if it is just my Emacs config or
> actually underlaying data structure (Gap buffer vs linked structure
> optimized for changes - their "Superstring").
>
These files work flawlessly on my laptop (under Org-mode), which has half
the memory of your computer. So this has nothing to do with Emacs per se.
I don't know what the problem on your computer is. I'd suggest to try to
open these files by opening with emacs -q. Then try to find what causes
the problem in your .emacs file.
Anyway, all this has nothing to do with the proposed feature. The fact
that it will not work under some circumstances is obvious and is not a
problem. Of course every feature has a limit, I mean, even opening files
does not work anymore above some limit.
Gregory
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-14 7:12 ` Gregory Heytings
@ 2020-06-14 7:45 ` Arthur Miller
2020-06-14 20:14 ` Gregory Heytings
0 siblings, 1 reply; 31+ messages in thread
From: Arthur Miller @ 2020-06-14 7:45 UTC (permalink / raw)
To: Gregory Heytings; +Cc: help-gnu-emacs
Gregory Heytings <ghe@sdf.org> writes:
>>
>>> That's not correct. On my laptop, I can easily edit a 100 (one hundred) MB
>>> text file, Emacs is almost as reactive as with a 1 KB text file. Of course
>>> some operations take more time, e.g. a query-replace-regexp on the whole
>>> buffer, but from what I see (on my laptop it takes about four seconds, with a
>>> regexp) I doubt that it takes more time than hundred query-replace-regexp in
>>> a 1 MB file, or for that matter than doing this with dired on hundred 1 MB
>>> files.
>>>
>> I think it depends on content in those files as well as of size.
>>
>> Try to edit some of those two files: https://github.com/amno1/Plato , possibly
>> Plato.org. Don't just display them, but try to actually put some text note in
>> it or add/remove some whitespace or whatever. Jump to some paragraph and
>> insert a new line and see how long it takes. Then try to do same in Atom text
>> editor.
>>
>> My Emacs takes quite some time even to add a white space char while Atom has
>> not problems whatsoever. I run on 6700K i7 cpu + 32 gig 3000Mhz ram.
>>
>> I don't know what the problem is, if it is just my Emacs config or actually
>> underlaying data structure (Gap buffer vs linked structure optimized for
>> changes - their "Superstring").
>>
>
> These files work flawlessly on my laptop (under Org-mode), which has half the
> memory of your computer. So this has nothing to do with Emacs per se. I don't
> know what the problem on your computer is. I'd suggest to try to open these
> files by opening with emacs -q. Then try to find what causes the problem in
> your .emacs file.
>
> Anyway, all this has nothing to do with the proposed feature. The fact that it
> will not work under some circumstances is obvious and is not a problem. Of
> course every feature has a limit, I mean, even opening files does not work
> anymore above some limit.
>
> Gregory
I know I can run with -Q option, but then I don't have some nice org
features I like to have :-). The point is when you open different files
with different major modes, start to do stuff etc it might be very heavy
maybe unusuable.
Wonder how fast it would work with emacs src directory by opening all .h
anc .c files, some of which are 5k+ lines of code. If that is the case
for refactorisation and similar.
But sure it could be usefull feature in some cases.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-14 7:45 ` Arthur Miller
@ 2020-06-14 20:14 ` Gregory Heytings
2020-06-15 6:58 ` Sv: " arthur miller
0 siblings, 1 reply; 31+ messages in thread
From: Gregory Heytings @ 2020-06-14 20:14 UTC (permalink / raw)
To: help-gnu-emacs
>
> Wonder how fast it would work with emacs src directory by opening all .h
> anc .c files, some of which are 5k+ lines of code. If that is the case
> for refactorisation and similar.
>
I just tried this. With "cat *.h *.c > all.c" in the Emacs src directory,
the resulting file is 11 MB, for about 370K source lines. Opening and
using that file, with c-mode, font-lock-mode, transient-mark-mode,
hl-line-mode and display-line-numbers-mode (and a few others), works
without any visible problems. I tried e.g. to insert some code at random
places, to kill the second half ot the buffer and to yank it as its first
part, to query-replace-regexp the 1652 occurrences of "E\([^ ]*\)s " with
"Es\1 ", to narrow-to-region/widen, ... The Emacs process did not use
more than 120 MB.
Gregory
^ permalink raw reply [flat|nested] 31+ messages in thread
* Sv: Opening multiple files in a single buffer?
2020-06-14 20:14 ` Gregory Heytings
@ 2020-06-15 6:58 ` arthur miller
0 siblings, 0 replies; 31+ messages in thread
From: arthur miller @ 2020-06-15 6:58 UTC (permalink / raw)
To: Gregory Heytings, help-gnu-emacs@gnu.org
That sounds great!
________________________________
Från: help-gnu-emacs <help-gnu-emacs-bounces+arthur.miller=live.com@gnu.org> för Gregory Heytings <ghe@sdf.org>
Skickat: den 14 juni 2020 22:14
Till: help-gnu-emacs@gnu.org <help-gnu-emacs@gnu.org>
Ämne: Re: Opening multiple files in a single buffer?
>
> Wonder how fast it would work with emacs src directory by opening all .h
> anc .c files, some of which are 5k+ lines of code. If that is the case
> for refactorisation and similar.
>
I just tried this. With "cat *.h *.c > all.c" in the Emacs src directory,
the resulting file is 11 MB, for about 370K source lines. Opening and
using that file, with c-mode, font-lock-mode, transient-mark-mode,
hl-line-mode and display-line-numbers-mode (and a few others), works
without any visible problems. I tried e.g. to insert some code at random
places, to kill the second half ot the buffer and to yank it as its first
part, to query-replace-regexp the 1652 occurrences of "E\([^ ]*\)s " with
"Es\1 ", to narrow-to-region/widen, ... The Emacs process did not use
more than 120 MB.
Gregory
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: Opening multiple files in a single buffer?
2020-06-13 18:10 ` Dan Hitt
2020-06-13 18:41 ` Jakub Jankiewicz
2020-06-13 18:41 ` Eli Zaretskii
@ 2020-06-13 19:31 ` Stefan Monnier
2 siblings, 0 replies; 31+ messages in thread
From: Stefan Monnier @ 2020-06-13 19:31 UTC (permalink / raw)
To: help-gnu-emacs
> I think your idea is a real winner.
As I said, it's probably pretty easy to write such a thing.
If you like the idea, why don't you try?
You can call `insert-file-contents` several times in the same buffer to
insert the various files's contents. Then you need to keep track of
where is the separation between each file (probably using one overlay or
marker per file), and then use a hook like `write-contents-functions`
to do the save "by hand".
Stefan
^ permalink raw reply [flat|nested] 31+ messages in thread