unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Same file on two buffers - Two different major modes
@ 2020-11-04 11:37 Christopher Dimech
  2020-11-04 11:52 ` Philipp Stephani
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Christopher Dimech @ 2020-11-04 11:37 UTC (permalink / raw)
  To: Help Gnu Emacs

Can one have two buffers of the same file, next to each other,
but in different modes.  When I change one buffer, the major mode
of the other is changing automatically.



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

* Re: Same file on two buffers - Two different major modes
  2020-11-04 11:37 Same file on two buffers - Two different major modes Christopher Dimech
@ 2020-11-04 11:52 ` Philipp Stephani
  2020-11-04 11:57   ` tomas
  2020-11-04 11:55 ` tomas
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Philipp Stephani @ 2020-11-04 11:52 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: Help Gnu Emacs

Am Mi., 4. Nov. 2020 um 12:38 Uhr schrieb Christopher Dimech <dimech@gmx.com>:
>
> Can one have two buffers of the same file, next to each other,
> but in different modes.

Yes, see "Indirect Buffers" in the Emacs manual. E.g. you can run C-x
4 c to clone the current buffer, and then switch the major mode in the
clone buffer. However, this seems to break font locking.

>  When I change one buffer, the major mode
> of the other is changing automatically.

I don't quite understand - if the buffers should have different modes,
how would changing the mode in one buffer affect another buffer?



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

* Re: Same file on two buffers - Two different major modes
  2020-11-04 11:37 Same file on two buffers - Two different major modes Christopher Dimech
  2020-11-04 11:52 ` Philipp Stephani
@ 2020-11-04 11:55 ` tomas
  2020-11-04 12:08 ` Joost Kremers
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: tomas @ 2020-11-04 11:55 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 495 bytes --]

On Wed, Nov 04, 2020 at 12:37:00PM +0100, Christopher Dimech wrote:
> Can one have two buffers of the same file, next to each other,
> but in different modes.  When I change one buffer, the major mode
> of the other is changing automatically.

That's because it most probably is /one/ buffer. The mode is bound
to the buffer, not the window, as far as I know.

(And, I'm guessing here, you /want/ "them" to be one buffer: changes
should occur simultaneously, right? => one buffer).

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: Same file on two buffers - Two different major modes
  2020-11-04 11:52 ` Philipp Stephani
@ 2020-11-04 11:57   ` tomas
  0 siblings, 0 replies; 12+ messages in thread
From: tomas @ 2020-11-04 11:57 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: Christopher Dimech, Help Gnu Emacs

[-- Attachment #1: Type: text/plain, Size: 185 bytes --]

On Wed, Nov 04, 2020 at 12:52:01PM +0100, Philipp Stephani wrote:

[...]

> Yes, see "Indirect Buffers" in the Emacs manual [...]

Oh, yes. I forgot about those, thanks :)

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: Same file on two buffers - Two different major modes
  2020-11-04 11:37 Same file on two buffers - Two different major modes Christopher Dimech
  2020-11-04 11:52 ` Philipp Stephani
  2020-11-04 11:55 ` tomas
@ 2020-11-04 12:08 ` Joost Kremers
  2020-11-04 12:30   ` Christopher Dimech
  2020-11-04 12:30 ` Jean Louis
  2020-11-04 21:18 ` Marcin Borkowski
  4 siblings, 1 reply; 12+ messages in thread
From: Joost Kremers @ 2020-11-04 12:08 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: help-gnu-emacs


On Wed, Nov 04 2020, Christopher Dimech wrote:
> Can one have two buffers of the same file, next to each other,
> but in different modes.  When I change one buffer, the major mode
> of the other is changing automatically.

You probably have two *windows* displaying the *same* buffer. I don't think you
can have two buffers visiting the same file, because visiting a file first
checks if the file is already being visited.

As pointed out by others, you could use an indirect buffer, but that's not a
perfect solution, because it messes up font lock (apparently among other
things).

-- 
Joost Kremers
Life has its moments



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

* Re: Same file on two buffers - Two different major modes
  2020-11-04 11:37 Same file on two buffers - Two different major modes Christopher Dimech
                   ` (2 preceding siblings ...)
  2020-11-04 12:08 ` Joost Kremers
@ 2020-11-04 12:30 ` Jean Louis
  2020-11-04 21:18 ` Marcin Borkowski
  4 siblings, 0 replies; 12+ messages in thread
From: Jean Louis @ 2020-11-04 12:30 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: Help Gnu Emacs

* Christopher Dimech <dimech@gmx.com> [2020-11-04 14:38]:
> Can one have two buffers of the same file, next to each other,
> but in different modes.  When I change one buffer, the major mode
> of the other is changing automatically.

If nothing works, open up new Emacs instance and use different mode.





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

* Re: Same file on two buffers - Two different major modes
  2020-11-04 12:08 ` Joost Kremers
@ 2020-11-04 12:30   ` Christopher Dimech
  2020-11-04 21:40     ` Drew Adams
  0 siblings, 1 reply; 12+ messages in thread
From: Christopher Dimech @ 2020-11-04 12:30 UTC (permalink / raw)
  To: Joost Kremers; +Cc: help-gnu-emacs

Se you get a shitty buffer!  Is there a need for a fix?  The
principal idea is to have the same buffer next to each other,
where one can change the major mode on each buffer, but saves
to the save buffer.



> Sent: Wednesday, November 04, 2020 at 1:08 PM
> From: "Joost Kremers" <joostkremers@fastmail.fm>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Same file on two buffers - Two different major modes
>
>
> On Wed, Nov 04 2020, Christopher Dimech wrote:
> > Can one have two buffers of the same file, next to each other,
> > but in different modes.  When I change one buffer, the major mode
> > of the other is changing automatically.
>
> You probably have two *windows* displaying the *same* buffer. I don't think you
> can have two buffers visiting the same file, because visiting a file first
> checks if the file is already being visited.
>
> As pointed out by others, you could use an indirect buffer, but that's not a
> perfect solution, because it messes up font lock (apparently among other
> things).
>
> --
> Joost Kremers
> Life has its moments
>



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

* Re: Same file on two buffers - Two different major modes
  2020-11-04 11:37 Same file on two buffers - Two different major modes Christopher Dimech
                   ` (3 preceding siblings ...)
  2020-11-04 12:30 ` Jean Louis
@ 2020-11-04 21:18 ` Marcin Borkowski
  4 siblings, 0 replies; 12+ messages in thread
From: Marcin Borkowski @ 2020-11-04 21:18 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: Help Gnu Emacs


On 2020-11-04, at 12:37, Christopher Dimech <dimech@gmx.com> wrote:

> Can one have two buffers of the same file, next to each other,
> but in different modes.  When I change one buffer, the major mode
> of the other is changing automatically.

Never actually tried it (but I should), but you might be interested in
Lentic:
https://github.com/phillord/lentic

Hth,

-- 
Marcin Borkowski
http://mbork.pl



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

* RE: Same file on two buffers - Two different major modes
  2020-11-04 12:30   ` Christopher Dimech
@ 2020-11-04 21:40     ` Drew Adams
  2020-11-04 21:47       ` Christopher Dimech
  0 siblings, 1 reply; 12+ messages in thread
From: Drew Adams @ 2020-11-04 21:40 UTC (permalink / raw)
  To: Christopher Dimech, Joost Kremers; +Cc: help-gnu-emacs

> The principal idea is to have the same buffer next to each other,
> where one can change the major mode on each buffer, but saves
> to the save buffer.

OK, that's "the principal idea", but I don't understand the
use case. Could you say why you want to see the same buffer
in two windows, but in a different mode in each window?

What is it you are really trying to do?  That might help
understanding.



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

* Re: RE: Same file on two buffers - Two different major modes
  2020-11-04 21:40     ` Drew Adams
@ 2020-11-04 21:47       ` Christopher Dimech
  2020-11-04 22:16         ` Drew Adams
  2020-11-05  0:50         ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 12+ messages in thread
From: Christopher Dimech @ 2020-11-04 21:47 UTC (permalink / raw)
  To: Drew Adams; +Cc: Joost Kremers, help-gnu-emacs

For instance, I have source code with org-mode and rec-wode
commands.  Thus while I am working on the source code I could
be navigating the same file in org-mode.



> Sent: Wednesday, November 04, 2020 at 10:40 PM
> From: "Drew Adams" <drew.adams@oracle.com>
> To: "Christopher Dimech" <dimech@gmx.com>, "Joost Kremers" <joostkremers@fastmail.fm>
> Cc: help-gnu-emacs@gnu.org
> Subject: RE: Same file on two buffers - Two different major modes
>
> > The principal idea is to have the same buffer next to each other,
> > where one can change the major mode on each buffer, but saves
> > to the save buffer.
>
> OK, that's "the principal idea", but I don't understand the
> use case. Could you say why you want to see the same buffer
> in two windows, but in a different mode in each window?
>
> What is it you are really trying to do?  That might help
> understanding.
>
>



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

* RE: RE: Same file on two buffers - Two different major modes
  2020-11-04 21:47       ` Christopher Dimech
@ 2020-11-04 22:16         ` Drew Adams
  2020-11-05  0:50         ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 0 replies; 12+ messages in thread
From: Drew Adams @ 2020-11-04 22:16 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: Joost Kremers, help-gnu-emacs

> For instance, I have source code with org-mode and rec-wode
> commands.  Thus while I am working on the source code I could
> be navigating the same file in org-mode.

Got it; thanks.

<ducks>
It's maybe too bad that Org mode, unlike
Outline mode, doesn't have a minor-mode version.
</ducks>

(I suppose there's at least one good reason.)  



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

* Re: Same file on two buffers - Two different major modes
  2020-11-04 21:47       ` Christopher Dimech
  2020-11-04 22:16         ` Drew Adams
@ 2020-11-05  0:50         ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 0 replies; 12+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-11-05  0:50 UTC (permalink / raw)
  To: help-gnu-emacs

Christopher Dimech wrote:

> For instance, I have source code with org-mode and rec-wode
> commands. Thus while I am working on the source code I could be
> navigating the same file in org-mode.

C-u M-x make-indirect-buffer RET RET org-mode-version RET

M-x pop-to-buffer org-mode-version RET

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

end of thread, other threads:[~2020-11-05  0:50 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-04 11:37 Same file on two buffers - Two different major modes Christopher Dimech
2020-11-04 11:52 ` Philipp Stephani
2020-11-04 11:57   ` tomas
2020-11-04 11:55 ` tomas
2020-11-04 12:08 ` Joost Kremers
2020-11-04 12:30   ` Christopher Dimech
2020-11-04 21:40     ` Drew Adams
2020-11-04 21:47       ` Christopher Dimech
2020-11-04 22:16         ` Drew Adams
2020-11-05  0:50         ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-11-04 12:30 ` Jean Louis
2020-11-04 21:18 ` Marcin Borkowski

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).