unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Enabling modes
@ 2017-09-09 17:12 Robert Thorpe
  2017-09-09 17:50 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Robert Thorpe @ 2017-09-09 17:12 UTC (permalink / raw)
  To: help-gnu-emacs

I use global-visual-line mode.  I've found a problem with it for one
file type that I use (tab-separated values).

So, what I want to do is set visual-line-mode in all buffers except
those particular ones.

Usually modes are set up the other way around, by including things.
Mode X is triggered for languages Y and Z, for example.  I want it the
opposite way around, I want visual-line-mode to be always enabled unless
I have a tab-separated-value file.

Is that possible?

BR,
Robert Thorpe



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

* Re: Enabling modes
       [not found] <mailman.198.1504977154.14750.help-gnu-emacs@gnu.org>
@ 2017-09-09 17:27 ` Emanuel Berg
  0 siblings, 0 replies; 8+ messages in thread
From: Emanuel Berg @ 2017-09-09 17:27 UTC (permalink / raw)
  To: help-gnu-emacs

Robert Thorpe wrote:

> Usually modes are set up the other way around,
> by including things. Mode X is triggered for
> languages Y and Z, for example. I want it the
> opposite way around, I want visual-line-mode to
> be always enabled unless I have
> a tab-separated-value file.

`setq-default' then disable in
mode hooks.

Or enable in every mode is what I would do.
E.g., I don't know how many programming modes
have have enabled line number in the mode bar.
But it is many. But not many enough for it be
a burden to do.

On the contrary it is very fast.

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: Enabling modes
  2017-09-09 17:12 Enabling modes Robert Thorpe
@ 2017-09-09 17:50 ` Eli Zaretskii
  2017-09-12 22:35   ` Robert Thorpe
  2017-09-11  2:41 ` Nick Helm
       [not found] ` <mailman.294.1505097738.14750.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2017-09-09 17:50 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Robert Thorpe <rt@robertthorpeconsulting.com>
> Date: Sat, 09 Sep 2017 18:12:18 +0100
> 
> Usually modes are set up the other way around, by including things.
> Mode X is triggered for languages Y and Z, for example.  I want it the
> opposite way around, I want visual-line-mode to be always enabled unless
> I have a tab-separated-value file.
> 
> Is that possible?

Did you try to do this in the mode hook?



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

* Re: Enabling modes
  2017-09-09 17:12 Enabling modes Robert Thorpe
  2017-09-09 17:50 ` Eli Zaretskii
@ 2017-09-11  2:41 ` Nick Helm
  2017-09-12 22:30   ` Robert Thorpe
       [not found] ` <mailman.294.1505097738.14750.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 8+ messages in thread
From: Nick Helm @ 2017-09-11  2:41 UTC (permalink / raw)
  To: help-gnu-emacs

Robert Thorpe <rt@robertthorpeconsulting.com> writes:

> I use global-visual-line mode.  I've found a problem with it for one
> file type that I use (tab-separated values).
>
> So, what I want to do is set visual-line-mode in all buffers except
> those particular ones.
>
> Usually modes are set up the other way around, by including things.
> Mode X is triggered for languages Y and Z, for example.  I want it the
> opposite way around, I want visual-line-mode to be always enabled unless
> I have a tab-separated-value file.
>
> Is that possible?

You could use mode hooks, but if you'd prefer to turn it off just for
files with a TSV extension you could add an entry to auto-mode-alist.
Something like this in your init should work:

(global-visual-line-mode)
(add-to-list 'auto-mode-alist '("\\.tsv\\'" . (lambda () (visual-line-mode -1))))

Alternatively, you could use magic-mode-alist to detect the tabbed
format itself, which would work for any extension.



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

* Re: Enabling modes
       [not found] ` <mailman.294.1505097738.14750.help-gnu-emacs@gnu.org>
@ 2017-09-11  2:57   ` Emanuel Berg
  0 siblings, 0 replies; 8+ messages in thread
From: Emanuel Berg @ 2017-09-11  2:57 UTC (permalink / raw)
  To: help-gnu-emacs

Nick Helm wrote:

> You could use mode hooks, but if you'd prefer
> to turn it off just for files with a TSV
> extension you could add an entry to
> auto-mode-alist. Something like this in your
> init should work:
>
> (global-visual-line-mode) (add-to-list
> 'auto-mode-alist '("\\.tsv\\'" . (lambda ()
> (visual-line-mode -1))))
>
> Alternatively, you could use magic-mode-alist
> to detect the tabbed format itself, which
> would work for any extension.

Indeed, great idea!

Here are some examples what you can do with
both magic-mode-alist and auto-mode-alist:

    http://user.it.uu.se/~embe8573/emacs-init/mode-by-filename.el

Beware some of that code is for display
purposes ONLY :)

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: Enabling modes
  2017-09-11  2:41 ` Nick Helm
@ 2017-09-12 22:30   ` Robert Thorpe
  0 siblings, 0 replies; 8+ messages in thread
From: Robert Thorpe @ 2017-09-12 22:30 UTC (permalink / raw)
  To: Nick Helm; +Cc: help-gnu-emacs

Nick Helm <nick@tenpoint.co.nz> writes:

> Robert Thorpe <rt@robertthorpeconsulting.com> writes:
...
>> Is that possible?
>
> You could use mode hooks, but if you'd prefer to turn it off just for
> files with a TSV extension you could add an entry to auto-mode-alist.
> Something like this in your init should work:
>
> (global-visual-line-mode)
> (add-to-list 'auto-mode-alist '("\.tsv\'" . (lambda () (visual-line-mode -1))))
>
> Alternatively, you could use magic-mode-alist to detect the tabbed
> format itself, which would work for any extension.

That seems like a good idea.

BR,
Robert Thorpe



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

* Re: Enabling modes
  2017-09-09 17:50 ` Eli Zaretskii
@ 2017-09-12 22:35   ` Robert Thorpe
  2017-09-12 22:45     ` Emanuel Berg
  0 siblings, 1 reply; 8+ messages in thread
From: Robert Thorpe @ 2017-09-12 22:35 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Robert Thorpe <rt@robertthorpeconsulting.com>
>> Date: Sat, 09 Sep 2017 18:12:18 +0100
>> 
>> Usually modes are set up the other way around, by including things.
>> Mode X is triggered for languages Y and Z, for example.  I want it the
>> opposite way around, I want visual-line-mode to be always enabled unless
>> I have a tab-separated-value file.
>> 
>> Is that possible?
>
> Did you try to do this in the mode hook?

Do you mean something like this?

(add-hook 'text-mode-hook
            (lambda ()                  
              (unless <Detect TSV file>
               (visual-line-mode 1))))

Is that better than disabling it afterwards as Nick Helm suggested?

BR,
Robert Thorpe




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

* Re: Enabling modes
  2017-09-12 22:35   ` Robert Thorpe
@ 2017-09-12 22:45     ` Emanuel Berg
  0 siblings, 0 replies; 8+ messages in thread
From: Emanuel Berg @ 2017-09-12 22:45 UTC (permalink / raw)
  To: help-gnu-emacs

Robert Thorpe wrote:

> (add-hook 'text-mode-hook (lambda () (unless
> <Detect TSV file> (visual-line-mode 1))))
>
> Is that better than disabling it afterwards as
> Nick Helm suggested?

It is more what one is used to. But should
amount to the same if done correctly.

By the way I didn't read Mr. Helm's suggestion
as "disabling it afterwards" but rather yet
another place (or two actually) where either
enabling or disabling can be done.

-- 
underground experts united
http://user.it.uu.se/~embe8573




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

end of thread, other threads:[~2017-09-12 22:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-09 17:12 Enabling modes Robert Thorpe
2017-09-09 17:50 ` Eli Zaretskii
2017-09-12 22:35   ` Robert Thorpe
2017-09-12 22:45     ` Emanuel Berg
2017-09-11  2:41 ` Nick Helm
2017-09-12 22:30   ` Robert Thorpe
     [not found] ` <mailman.294.1505097738.14750.help-gnu-emacs@gnu.org>
2017-09-11  2:57   ` Emanuel Berg
     [not found] <mailman.198.1504977154.14750.help-gnu-emacs@gnu.org>
2017-09-09 17:27 ` Emanuel Berg

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