* Keybinding that loops through Major Modes
@ 2020-11-02 20:32 Christopher Dimech
2020-11-02 20:59 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-11-02 21:02 ` Stefan Monnier
0 siblings, 2 replies; 22+ messages in thread
From: Christopher Dimech @ 2020-11-02 20:32 UTC (permalink / raw)
To: Help Gnu Emacs
Is it difficult to make an keybinding that if I continue to
press it, it will loop through a list of major modes in
a predefined order (e.g. text-mode, org-mode, normal-mode, text-mode, ...)
Regards
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-02 20:32 Keybinding that loops through Major Modes Christopher Dimech
@ 2020-11-02 20:59 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-11-02 21:10 ` Christopher Dimech
2020-11-02 22:54 ` Christopher Dimech
2020-11-02 21:02 ` Stefan Monnier
1 sibling, 2 replies; 22+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-11-02 20:59 UTC (permalink / raw)
To: help-gnu-emacs
Christopher Dimech wrote:
> Is it difficult to make an keybinding that if I continue to press
> it, it will loop through a list of major modes in a predefined
> order (e.g. text-mode, org-mode, normal-mode, text-mode, ...)
Not difficult but perhaps not a good idea since it is probably better
to let Emacs set the major mode automatically.
If it doesn't do it to your liking there are many ways to set it up,
depending on the situation.
Based on file extension:
(let ((modes (list
'("\\.bal\\'" . balance-mode)
'("\\.lu\\'" . lua-mode)
'("\\.nqp\\'" . perl-mode)
'("\\.php\\'" . html-mode)
'("\\.pic\\'" . nroff-mode)
'("\\.pl\\'" . prolog-mode)
'("\\.tex\\'" . latex-mode)
'("\\.xr\\'" . conf-xdefaults-mode)
'("*" . text-mode) )))
(setf auto-mode-alist (nconc modes auto-mode-alist)) )
For scripts, use the hash-bang line, topmost. You probably want it
anyway. For example, for zsh:
#! /bin/zsh
You can also force a mode like this, also topmost:
;;; -*- emacs-lisp -*-
For the rare cases none of these methods will do, I think M-x
perl-mode RET will do...
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-02 20:32 Keybinding that loops through Major Modes Christopher Dimech
2020-11-02 20:59 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-11-02 21:02 ` Stefan Monnier
1 sibling, 0 replies; 22+ messages in thread
From: Stefan Monnier @ 2020-11-02 21:02 UTC (permalink / raw)
To: help-gnu-emacs
> Is it difficult to make an keybinding that if I continue to
> press it, it will loop through a list of major modes in
> a predefined order (e.g. text-mode, org-mode, normal-mode, text-mode, ...)
No,
Stefan
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-02 20:59 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-11-02 21:10 ` Christopher Dimech
2020-11-02 21:31 ` Vegard Vesterheim
2020-11-03 8:11 ` tomas
2020-11-02 22:54 ` Christopher Dimech
1 sibling, 2 replies; 22+ messages in thread
From: Christopher Dimech @ 2020-11-02 21:10 UTC (permalink / raw)
To: moasenwood; +Cc: help-gnu-emacs
I shall explain better then. In my .texi files I customarily include commands
from other modes or want to use some hooks from other modes (e.g. org-mode).
So even after I load a file with the default mode, I would need to quickly
shift to another mode temporarily, then switch back to normal-mode.
> Sent: Monday, November 02, 2020 at 9:59 PM
> From: "Emanuel Berg via Users list for the GNU Emacs text editor" <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Keybinding that loops through Major Modes
>
> Christopher Dimech wrote:
>
> > Is it difficult to make an keybinding that if I continue to press
> > it, it will loop through a list of major modes in a predefined
> > order (e.g. text-mode, org-mode, normal-mode, text-mode, ...)
>
> Not difficult but perhaps not a good idea since it is probably better
> to let Emacs set the major mode automatically.
>
> If it doesn't do it to your liking there are many ways to set it up,
> depending on the situation.
>
> Based on file extension:
>
> (let ((modes (list
> '("\\.bal\\'" . balance-mode)
> '("\\.lu\\'" . lua-mode)
> '("\\.nqp\\'" . perl-mode)
> '("\\.php\\'" . html-mode)
> '("\\.pic\\'" . nroff-mode)
> '("\\.pl\\'" . prolog-mode)
> '("\\.tex\\'" . latex-mode)
> '("\\.xr\\'" . conf-xdefaults-mode)
> '("*" . text-mode) )))
> (setf auto-mode-alist (nconc modes auto-mode-alist)) )
>
> For scripts, use the hash-bang line, topmost. You probably want it
> anyway. For example, for zsh:
>
> #! /bin/zsh
>
> You can also force a mode like this, also topmost:
>
> ;;; -*- emacs-lisp -*-
>
> For the rare cases none of these methods will do, I think M-x
> perl-mode RET will do...
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-02 21:10 ` Christopher Dimech
@ 2020-11-02 21:31 ` Vegard Vesterheim
2020-11-02 22:11 ` Christopher Dimech
2020-11-03 8:11 ` tomas
1 sibling, 1 reply; 22+ messages in thread
From: Vegard Vesterheim @ 2020-11-02 21:31 UTC (permalink / raw)
To: Christopher Dimech; +Cc: moasenwood, help-gnu-emacs
On Mon, 2 Nov 2020 22:10:02 +0100 Christopher Dimech <dimech@gmx.com> wrote:
> I shall explain better then. In my .texi files I customarily include commands
> from other modes or want to use some hooks from other modes (e.g. org-mode).
> So even after I load a file with the default mode, I would need to quickly
> shift to another mode temporarily, then switch back to normal-mode.
I realize this is not an answer to your original question. But have you
considered writing your file in org-mode? Org-mode can export to
several formats, also texi.
Org-mode has this thing called babel
(https://orgmode.org/worg/org-contrib/babel/) which allows you to embed
(and even execute) blocks of code in your document.
From the manual
(https://orgmode.org/manual/Editing-Source-Code.html#Editing-Source-Code):
Use C-c ' to edit the current code block. It opens a new major mode edit
buffer containing the body of the source code block, ready for any edits.
--
Vennlig hilsen/Best regards
Vegard Vesterheim
Senior Software engineer
+47 48 11 98 98
vegard.vesterheim@uninett.no
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-02 21:31 ` Vegard Vesterheim
@ 2020-11-02 22:11 ` Christopher Dimech
0 siblings, 0 replies; 22+ messages in thread
From: Christopher Dimech @ 2020-11-02 22:11 UTC (permalink / raw)
To: Vegard Vesterheim; +Cc: help-gnu-emacs, moasenwood
Have used Org Babel before. My situation is more complicated
because I use Org Commands in Source Files as well. To add
further complication, I also add rec commands that can be parsed
by Gnu Recutils, which is useful to we because I can compute some
metrics for my code, such as the Cyclomatic Complexity of each
function.
> Sent: Monday, November 02, 2020 at 10:31 PM
> From: "Vegard Vesterheim" <vegard.vesterheim@uninett.no>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: moasenwood@zoho.eu, help-gnu-emacs@gnu.org
> Subject: Re: Keybinding that loops through Major Modes
>
> On Mon, 2 Nov 2020 22:10:02 +0100 Christopher Dimech <dimech@gmx.com> wrote:
>
> > I shall explain better then. In my .texi files I customarily include commands
> > from other modes or want to use some hooks from other modes (e.g. org-mode).
> > So even after I load a file with the default mode, I would need to quickly
> > shift to another mode temporarily, then switch back to normal-mode.
>
> I realize this is not an answer to your original question. But have you
> considered writing your file in org-mode? Org-mode can export to
> several formats, also texi.
>
> Org-mode has this thing called babel
> (https://orgmode.org/worg/org-contrib/babel/) which allows you to embed
> (and even execute) blocks of code in your document.
>
> From the manual
> (https://orgmode.org/manual/Editing-Source-Code.html#Editing-Source-Code):
>
> Use C-c ' to edit the current code block. It opens a new major mode edit
> buffer containing the body of the source code block, ready for any edits.
>
> --
> Vennlig hilsen/Best regards
> Vegard Vesterheim
> Senior Software engineer
> +47 48 11 98 98
> vegard.vesterheim@uninett.no
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-02 20:59 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-11-02 21:10 ` Christopher Dimech
@ 2020-11-02 22:54 ` Christopher Dimech
2020-11-02 23:27 ` Emanuel Berg via Users list for the GNU Emacs text editor
1 sibling, 1 reply; 22+ messages in thread
From: Christopher Dimech @ 2020-11-02 22:54 UTC (permalink / raw)
To: moasenwood; +Cc: help-gnu-emacs
I think something similar to
(let ((modes (list
would work. But by forcing a mode change in the current buffer. not based on file extension.
> Sent: Monday, November 02, 2020 at 9:59 PM
> From: "Emanuel Berg via Users list for the GNU Emacs text editor" <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Keybinding that loops through Major Modes
>
> Christopher Dimech wrote:
>
> > Is it difficult to make an keybinding that if I continue to press
> > it, it will loop through a list of major modes in a predefined
> > order (e.g. text-mode, org-mode, normal-mode, text-mode, ...)
>
> Not difficult but perhaps not a good idea since it is probably better
> to let Emacs set the major mode automatically.
>
> If it doesn't do it to your liking there are many ways to set it up,
> depending on the situation.
>
> Based on file extension:
>
> (let ((modes (list
> '("\\.bal\\'" . balance-mode)
> '("\\.lu\\'" . lua-mode)
> '("\\.nqp\\'" . perl-mode)
> '("\\.php\\'" . html-mode)
> '("\\.pic\\'" . nroff-mode)
> '("\\.pl\\'" . prolog-mode)
> '("\\.tex\\'" . latex-mode)
> '("\\.xr\\'" . conf-xdefaults-mode)
> '("*" . text-mode) )))
> (setf auto-mode-alist (nconc modes auto-mode-alist)) )
>
> For scripts, use the hash-bang line, topmost. You probably want it
> anyway. For example, for zsh:
>
> #! /bin/zsh
>
> You can also force a mode like this, also topmost:
>
> ;;; -*- emacs-lisp -*-
>
> For the rare cases none of these methods will do, I think M-x
> perl-mode RET will do...
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-02 22:54 ` Christopher Dimech
@ 2020-11-02 23:27 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-11-02 23:29 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 22+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-11-02 23:27 UTC (permalink / raw)
To: help-gnu-emacs
Christopher Dimech wrote:
> I think something similar to
>
> (let ((modes (list
>
> would work. But by forcing a mode change in the current buffer.
> not based on file extension.
(defun iterate-major-mode ()
(interactive)
(let*((modes (list #'emacs-lisp-mode #'perl-mode #'text-mode))
(new-mode (or (cadr (member major-mode modes)) (car modes))) )
(apply `(,new-mode)) ))
;; (iterate-major-mode)
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-02 23:27 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-11-02 23:29 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 22+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-11-02 23:29 UTC (permalink / raw)
To: help-gnu-emacs
> (defun iterate-major-mode ()
> (interactive)
> (let*((modes (list #'emacs-lisp-mode #'perl-mode #'text-mode))
> (new-mode (or (cadr (member major-mode modes)) (car modes))) )
> (apply `(,new-mode)) ))
> ;; (iterate-major-mode)
Maybe this looks better:
(defun iterate-major-mode ()
(interactive)
(let*((modes (list #'emacs-lisp-mode #'perl-mode #'text-mode))
(new-mode (or (cadr (member major-mode modes)) (car modes))) )
(apply (list new-mode))) )
;; (iterate-major-mode)
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-02 21:10 ` Christopher Dimech
2020-11-02 21:31 ` Vegard Vesterheim
@ 2020-11-03 8:11 ` tomas
2020-11-03 8:49 ` Christopher Dimech
1 sibling, 1 reply; 22+ messages in thread
From: tomas @ 2020-11-03 8:11 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 923 bytes --]
On Mon, Nov 02, 2020 at 10:10:02PM +0100, Christopher Dimech wrote:
> I shall explain better then. In my .texi files I customarily include commands
> from other modes or want to use some hooks from other modes (e.g. org-mode).
> So even after I load a file with the default mode, I would need to quickly
> shift to another mode temporarily, then switch back to normal-mode.
Perhaps your problem becomes different [0] if you squint at it from
another angle (space vs time): do you really want your whole buffer
to "switch mode", or are you looking after some regions "having a
different mode"?
In the second case, look, e.g. for "multiple major modes" [1]. It's
a class of problems for which need exists (e.g. Org source snippets,
but also those PHP cum HTML cum Javascript thingies.
Cheers
[0] Not necessarily better, but perhaps exciting in a different
way?
[1] https://www.emacswiki.org/emacs/MultipleModes
- t
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-03 8:11 ` tomas
@ 2020-11-03 8:49 ` Christopher Dimech
2020-11-03 9:44 ` Jean Louis
0 siblings, 1 reply; 22+ messages in thread
From: Christopher Dimech @ 2020-11-03 8:49 UTC (permalink / raw)
To: tomas; +Cc: help-gnu-emacs
> Sent: Tuesday, November 03, 2020 at 9:11 AM
> From: tomas@tuxteam.de
> To: help-gnu-emacs@gnu.org
> Subject: Re: Keybinding that loops through Major Modes
>
> On Mon, Nov 02, 2020 at 10:10:02PM +0100, Christopher Dimech wrote:
> > I shall explain better then. In my .texi files I customarily include commands
> > from other modes or want to use some hooks from other modes (e.g. org-mode).
> > So even after I load a file with the default mode, I would need to quickly
> > shift to another mode temporarily, then switch back to normal-mode.
>
> Perhaps your problem becomes different [0] if you squint at it from
> another angle (space vs time): do you really want your whole buffer
> to "switch mode", or are you looking after some regions "having a
> different mode"?
That's what I had in mind, for the whole buffer
> In the second case, look, e.g. for "multiple major modes" [1]. It's
> a class of problems for which need exists (e.g. Org source snippets,
> but also those PHP cum HTML cum Javascript thingies.
Indeed. Customarily I would need to change mode on just a portion of the
code I would be working with.
>
> Cheers
>
> [0] Not necessarily better, but perhaps exciting in a different
> way?
> [1] https://www.emacswiki.org/emacs/MultipleModes
>
> - t
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-03 8:49 ` Christopher Dimech
@ 2020-11-03 9:44 ` Jean Louis
2020-11-03 11:27 ` Christopher Dimech
0 siblings, 1 reply; 22+ messages in thread
From: Jean Louis @ 2020-11-03 9:44 UTC (permalink / raw)
To: Christopher Dimech; +Cc: help-gnu-emacs
* Christopher Dimech <dimech@gmx.com> [2020-11-03 11:51]:
>
>
>
> > Sent: Tuesday, November 03, 2020 at 9:11 AM
> > From: tomas@tuxteam.de
> > To: help-gnu-emacs@gnu.org
> > Subject: Re: Keybinding that loops through Major Modes
> >
> > On Mon, Nov 02, 2020 at 10:10:02PM +0100, Christopher Dimech wrote:
> > > I shall explain better then. In my .texi files I customarily include commands
> > > from other modes or want to use some hooks from other modes (e.g. org-mode).
> > > So even after I load a file with the default mode, I would need to quickly
> > > shift to another mode temporarily, then switch back to normal-mode.
> >
> > Perhaps your problem becomes different [0] if you squint at it from
> > another angle (space vs time): do you really want your whole buffer
> > to "switch mode", or are you looking after some regions "having a
> > different mode"?
>
> That's what I had in mind, for the whole buffer
>
> > In the second case, look, e.g. for "multiple major modes" [1]. It's
> > a class of problems for which need exists (e.g. Org source snippets,
> > but also those PHP cum HTML cum Javascript thingies.
>
> Indeed. Customarily I would need to change mode on just a portion of the
> code I would be working with.
I do not know by which settings, but I do see that Org snippets with
programming language inside behave just as the mode:
If I have this in Org:
#+begin_src emacs-lisp :results output silent
Then I can see syntax highlighting and I get indentation as well. But
not all features.
Maybe soolution could be to narrow-to-region, change the mode, and
then by exiting from narrow to region to change it back to original
mode. It could be one function.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-03 9:44 ` Jean Louis
@ 2020-11-03 11:27 ` Christopher Dimech
2020-11-03 12:19 ` Michael Heerdegen
0 siblings, 1 reply; 22+ messages in thread
From: Christopher Dimech @ 2020-11-03 11:27 UTC (permalink / raw)
To: Jean Louis; +Cc: help-gnu-emacs
> Sent: Tuesday, November 03, 2020 at 10:44 AM
> From: "Jean Louis" <bugs@gnu.support>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Keybinding that loops through Major Modes
>
> * Christopher Dimech <dimech@gmx.com> [2020-11-03 11:51]:
> >
> >
> >
> > > Sent: Tuesday, November 03, 2020 at 9:11 AM
> > > From: tomas@tuxteam.de
> > > To: help-gnu-emacs@gnu.org
> > > Subject: Re: Keybinding that loops through Major Modes
> > >
> > > On Mon, Nov 02, 2020 at 10:10:02PM +0100, Christopher Dimech wrote:
> > > > I shall explain better then. In my .texi files I customarily include commands
> > > > from other modes or want to use some hooks from other modes (e.g. org-mode).
> > > > So even after I load a file with the default mode, I would need to quickly
> > > > shift to another mode temporarily, then switch back to normal-mode.
> > >
> > > Perhaps your problem becomes different [0] if you squint at it from
> > > another angle (space vs time): do you really want your whole buffer
> > > to "switch mode", or are you looking after some regions "having a
> > > different mode"?
> >
> > That's what I had in mind, for the whole buffer
> >
> > > In the second case, look, e.g. for "multiple major modes" [1]. It's
> > > a class of problems for which need exists (e.g. Org source snippets,
> > > but also those PHP cum HTML cum Javascript thingies.
> >
> > Indeed. Customarily I would need to change mode on just a portion of the
> > code I would be working with.
>
>
> I do not know by which settings, but I do see that Org snippets with
> programming language inside behave just as the mode:
>
> If I have this in Org:
>
> #+begin_src emacs-lisp :results output silent
>
> Then I can see syntax highlighting and I get indentation as well. But
> not all features.
The major power would not be the highlighting itself, but the operations
associated with the mode.
> Maybe soolution could be to narrow-to-region, change the mode, and
> then by exiting from narrow to region to change it back to original
> mode. It could be one function.
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-03 11:27 ` Christopher Dimech
@ 2020-11-03 12:19 ` Michael Heerdegen
2020-11-03 12:29 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-11-03 13:09 ` Joost Kremers
0 siblings, 2 replies; 22+ messages in thread
From: Michael Heerdegen @ 2020-11-03 12:19 UTC (permalink / raw)
To: help-gnu-emacs
Christopher Dimech <dimech@gmx.com> writes:
> The major power would not be the highlighting itself, but the operations
> associated with the mode.
A method that would be a bit cleaner in my eyes would be a command that
lets you edit a specified region in a temp buffer in the correct mode.
Michael.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-03 12:19 ` Michael Heerdegen
@ 2020-11-03 12:29 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-11-03 12:50 ` Michael Heerdegen
2020-11-03 14:19 ` Christopher Dimech
2020-11-03 13:09 ` Joost Kremers
1 sibling, 2 replies; 22+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-11-03 12:29 UTC (permalink / raw)
To: help-gnu-emacs
Michael Heerdegen wrote:
>> The major power would not be the highlighting itself, but the
>> operations associated with the mode.
>
> A method that would be a bit cleaner in my eyes would be a command
> that lets you edit a specified region in a temp buffer in the
> correct mode.
The best method:
- several files
- one file, one mode
- the "associated operations" belonging to one mode can easily enough
be made generic if indeed correct they are useful for another mode
BOOM
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-03 12:29 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-11-03 12:50 ` Michael Heerdegen
2020-11-03 14:19 ` Christopher Dimech
1 sibling, 0 replies; 22+ messages in thread
From: Michael Heerdegen @ 2020-11-03 12:50 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
> The best method:
>
> - several files
>
> - one file, one mode
Unfortunately that's not always an option.
Michael.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-03 12:19 ` Michael Heerdegen
2020-11-03 12:29 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-11-03 13:09 ` Joost Kremers
2020-11-03 13:22 ` Michael Heerdegen
1 sibling, 1 reply; 22+ messages in thread
From: Joost Kremers @ 2020-11-03 13:09 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
On Tue, Nov 03 2020, Michael Heerdegen wrote:
> Christopher Dimech <dimech@gmx.com> writes:
>
>> The major power would not be the highlighting itself, but the operations
>> associated with the mode.
>
> A method that would be a bit cleaner in my eyes would be a command that
> lets you edit a specified region in a temp buffer in the correct mode.
A narrowed, indirect buffer. (Basically the same idea, with a few things
automated.)
--
Joost Kremers
Life has its moments
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-03 13:09 ` Joost Kremers
@ 2020-11-03 13:22 ` Michael Heerdegen
2020-11-03 14:35 ` Stefan Monnier
` (2 more replies)
0 siblings, 3 replies; 22+ messages in thread
From: Michael Heerdegen @ 2020-11-03 13:22 UTC (permalink / raw)
To: help-gnu-emacs
Joost Kremers <joostkremers@fastmail.fm> writes:
> > A method that would be a bit cleaner in my eyes would be a command that
> > lets you edit a specified region in a temp buffer in the correct mode.
>
> A narrowed, indirect buffer. (Basically the same idea, with a few things
> automated.)
AFAIK the problem with indirect buffers is that AFAIK font-lock isn't
supported (unless you use the same mode and settings as the base
buffer).
Michael.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-03 12:29 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-11-03 12:50 ` Michael Heerdegen
@ 2020-11-03 14:19 ` Christopher Dimech
1 sibling, 0 replies; 22+ messages in thread
From: Christopher Dimech @ 2020-11-03 14:19 UTC (permalink / raw)
To: moasenwood; +Cc: help-gnu-emacs
> Sent: Tuesday, November 03, 2020 at 1:29 PM
> From: "Emanuel Berg via Users list for the GNU Emacs text editor" <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Keybinding that loops through Major Modes
>
> Michael Heerdegen wrote:
>
> >> The major power would not be the highlighting itself, but the
> >> operations associated with the mode.
> >
> > A method that would be a bit cleaner in my eyes would be a command
> > that lets you edit a specified region in a temp buffer in the
> > correct mode.
>
> The best method:
>
> - several files
>
> - one file, one mode
>
> - the "associated operations" belonging to one mode can easily enough
> be made generic if indeed correct they are useful for another mode
In principle you are correct. However, if one uses ogg and rec you want
those features available some of the time, because if the file is a fortran
file, I would be mainly working in fortran mode. Some modes are very rich
and not completely applicable to code.
>
> BOOM
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-03 13:22 ` Michael Heerdegen
@ 2020-11-03 14:35 ` Stefan Monnier
2020-11-03 14:52 ` Joost Kremers
2020-11-03 16:17 ` Drew Adams
2 siblings, 0 replies; 22+ messages in thread
From: Stefan Monnier @ 2020-11-03 14:35 UTC (permalink / raw)
To: help-gnu-emacs
> AFAIK the problem with indirect buffers is that AFAIK font-lock isn't
> supported (unless you use the same mode and settings as the base
> buffer).
I wish it were the only issue.
Stefan
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Keybinding that loops through Major Modes
2020-11-03 13:22 ` Michael Heerdegen
2020-11-03 14:35 ` Stefan Monnier
@ 2020-11-03 14:52 ` Joost Kremers
2020-11-03 16:17 ` Drew Adams
2 siblings, 0 replies; 22+ messages in thread
From: Joost Kremers @ 2020-11-03 14:52 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
On Tue, Nov 03 2020, Michael Heerdegen wrote:
> Joost Kremers <joostkremers@fastmail.fm> writes:
>
>> > A method that would be a bit cleaner in my eyes would be a command that
>> > lets you edit a specified region in a temp buffer in the correct mode.
>>
>> A narrowed, indirect buffer. (Basically the same idea, with a few things
>> automated.)
>
> AFAIK the problem with indirect buffers is that AFAIK font-lock isn't
> supported (unless you use the same mode and settings as the base
> buffer).
If that's the case then yes, that's a problem. The manual says an indirect
buffer can have its own major mode, and I assumed from that font lock wouldn't
be a problem.
--
Joost Kremers
Life has its moments
^ permalink raw reply [flat|nested] 22+ messages in thread
* RE: Keybinding that loops through Major Modes
2020-11-03 13:22 ` Michael Heerdegen
2020-11-03 14:35 ` Stefan Monnier
2020-11-03 14:52 ` Joost Kremers
@ 2020-11-03 16:17 ` Drew Adams
2 siblings, 0 replies; 22+ messages in thread
From: Drew Adams @ 2020-11-03 16:17 UTC (permalink / raw)
To: Michael Heerdegen, help-gnu-emacs
> > > A method that would be a bit cleaner in my eyes would be a command that
> > > lets you edit a specified region in a temp buffer in the correct mode.
> >
> > A narrowed, indirect buffer. (Basically the same idea, with a few things
> > automated.)
>
> AFAIK the problem with indirect buffers is that AFAIK font-lock isn't
> supported (unless you use the same mode and settings as the base
> buffer).
Correct. Indirect buffers only get you so far. Font
lock and other things are tied to the buffer. You can
change them in the indirect buffer AND the base buffer,
but you can't have them different between the two.
And current multiple-major-modes implementations also
only get you so far.
A flexible, robust implementation of multiple major
modes is a (big) feature that's really waiting for
some brilliant, dedicated, probably collaborative work
(IMHO). That grail would be welcomed by all.
___
Anyway, for using narrowed indirect buffers, I offer
library `narrow-indirect.el'.
Description:
https://www.emacswiki.org/emacs/NarrowIndirect
Code:
https://www.emacswiki.org/emacs/download/narrow-indirect.el
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2020-11-03 16:17 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-02 20:32 Keybinding that loops through Major Modes Christopher Dimech
2020-11-02 20:59 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-11-02 21:10 ` Christopher Dimech
2020-11-02 21:31 ` Vegard Vesterheim
2020-11-02 22:11 ` Christopher Dimech
2020-11-03 8:11 ` tomas
2020-11-03 8:49 ` Christopher Dimech
2020-11-03 9:44 ` Jean Louis
2020-11-03 11:27 ` Christopher Dimech
2020-11-03 12:19 ` Michael Heerdegen
2020-11-03 12:29 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-11-03 12:50 ` Michael Heerdegen
2020-11-03 14:19 ` Christopher Dimech
2020-11-03 13:09 ` Joost Kremers
2020-11-03 13:22 ` Michael Heerdegen
2020-11-03 14:35 ` Stefan Monnier
2020-11-03 14:52 ` Joost Kremers
2020-11-03 16:17 ` Drew Adams
2020-11-02 22:54 ` Christopher Dimech
2020-11-02 23:27 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-11-02 23:29 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-11-02 21:02 ` Stefan Monnier
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).