* How can I enable minor mode, always?
@ 2010-10-21 19:46 paxxus
2010-10-23 10:57 ` PJ Weisberg
2010-10-26 23:49 ` paxxus
0 siblings, 2 replies; 8+ messages in thread
From: paxxus @ 2010-10-21 19:46 UTC (permalink / raw)
To: Help-gnu-emacs
Hi,
I want to always have the highlight-80+ mode enabled. In my .emacs file I
have:
(load "~/Emacs/highlight-80+.el")
(require 'highlight-80+)
(highlight-80+-mode 1)
However, when I start Emacs the highlight-80+ is not active, I have to
manually enable it for each new buffer I open.
My other modes, I want to always have enabled, are enabled as follows (and
it works for those modes):
(show-paren-mode 1)
(setq-default show-trailing-whitespace t)
(setq column-number-mode t)
As you can see each mode is enabled is slightly different ways, very
confusing. Unfortunately none of these methods works for highlight-80+.
--
View this message in context: http://old.nabble.com/How-can-I-enable-minor-mode%2C-always--tp30023005p30023005.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How can I enable minor mode, always?
2010-10-21 19:46 How can I enable minor mode, always? paxxus
@ 2010-10-23 10:57 ` PJ Weisberg
2010-10-23 15:15 ` Drew Adams
2010-10-26 23:49 ` paxxus
1 sibling, 1 reply; 8+ messages in thread
From: PJ Weisberg @ 2010-10-23 10:57 UTC (permalink / raw)
To: paxxus; +Cc: Help-gnu-emacs
On Thu, Oct 21, 2010 at 7:46 PM, paxxus <paxxus@hotmail.com> wrote:
>
> Hi,
>
> I want to always have the highlight-80+ mode enabled. In my .emacs file I
> have:
>
> (load "~/Emacs/highlight-80+.el")
> (require 'highlight-80+)
> (highlight-80+-mode 1)
>
> However, when I start Emacs the highlight-80+ is not active, I have to
> manually enable it for each new buffer I open.
>
> My other modes, I want to always have enabled, are enabled as follows (and
> it works for those modes):
> (show-paren-mode 1)
> (setq-default show-trailing-whitespace t)
> (setq column-number-mode t)
>
> As you can see each mode is enabled is slightly different ways, very
> confusing. Unfortunately none of these methods works for highlight-80+.
How about adding something to after-change-major-mode-hook? Use the
add-hook function.
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: How can I enable minor mode, always?
2010-10-23 10:57 ` PJ Weisberg
@ 2010-10-23 15:15 ` Drew Adams
0 siblings, 0 replies; 8+ messages in thread
From: Drew Adams @ 2010-10-23 15:15 UTC (permalink / raw)
To: 'PJ Weisberg', 'paxxus'; +Cc: Help-gnu-emacs
> > I have to manually enable it for each new buffer I open.
>
> How about adding something to after-change-major-mode-hook? Use the
> add-hook function.
Another suggestion: use `define-globalized-minor-mode' to define a global minor
mode. `highlight-80+-mode' is apparently a local minor mode. Just pass it as
the MODE arg to `define-globalized-minor-mode'.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How can I enable minor mode, always?
2010-10-21 19:46 How can I enable minor mode, always? paxxus
2010-10-23 10:57 ` PJ Weisberg
@ 2010-10-26 23:49 ` paxxus
2010-10-27 6:43 ` Oleksandr Gavenko
2010-10-27 16:07 ` PJ Weisberg
1 sibling, 2 replies; 8+ messages in thread
From: paxxus @ 2010-10-26 23:49 UTC (permalink / raw)
To: Help-gnu-emacs
Thanks for the suggestions.
I used fundamental-mode, always. It turns out that you can't add hooks to
that mode, so I changed my default mode to text-mode, and then added this
hook:
(add-hook 'text-mode-hook (lambda () (interactive) (highlight-80+-mode 1)))
The define-globalized-minor-mode also looks interesting, I'll try that out.
I have now worked a couple of days in text-mode instead of fundamental-mode,
and I can't detect any difference at all (which is good for what I want). Is
there a difference other than the hook stuff?
--
View this message in context: http://old.nabble.com/How-can-I-enable-minor-mode%2C-always--tp30023005p30062842.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How can I enable minor mode, always?
2010-10-26 23:49 ` paxxus
@ 2010-10-27 6:43 ` Oleksandr Gavenko
2010-10-27 16:07 ` PJ Weisberg
1 sibling, 0 replies; 8+ messages in thread
From: Oleksandr Gavenko @ 2010-10-27 6:43 UTC (permalink / raw)
To: help-gnu-emacs
On 27.10.2010 2:49, paxxus wrote:
>
> Thanks for the suggestions.
>
> I used fundamental-mode, always. It turns out that you can't add hooks to
> that mode, so I changed my default mode to text-mode, and then added this
> hook:
>
> (add-hook 'text-mode-hook (lambda () (interactive) (highlight-80+-mode 1)))
>
> The define-globalized-minor-mode also looks interesting, I'll try that out.
>
> I have now worked a couple of days in text-mode instead of fundamental-mode,
> and I can't detect any difference at all (which is good for what I want). Is
> there a difference other than the hook stuff?
Yes. Please refer to Emacs info: 29.7 Text Mode.
In Text mode, only blank lines and page delimiters separate
paragraphs. As a result, paragraphs can be indented, and adaptive
filling determines what indentation to use when filling a paragraph.
*Note Adaptive Fill::.
Text mode defines <TAB> to run `indent-relative' (*note
Indentation::), so that you can conveniently indent a line like the
previous line.
Text mode turns off the features concerned with comments except when
you explicitly invoke them.
.... .... ....
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How can I enable minor mode, always?
2010-10-26 23:49 ` paxxus
2010-10-27 6:43 ` Oleksandr Gavenko
@ 2010-10-27 16:07 ` PJ Weisberg
2010-10-28 8:57 ` Oleksandr Gavenko
1 sibling, 1 reply; 8+ messages in thread
From: PJ Weisberg @ 2010-10-27 16:07 UTC (permalink / raw)
To: paxxus; +Cc: Help-gnu-emacs
On Tue, Oct 26, 2010 at 11:49 PM, paxxus <paxxus@hotmail.com> wrote:
>
> Thanks for the suggestions.
>
> I used fundamental-mode, always. It turns out that you can't add hooks to
> that mode, so I changed my default mode to text-mode, and then added this
> hook:
>
> (add-hook 'text-mode-hook (lambda () (interactive) (highlight-80+-mode 1)))
>
> The define-globalized-minor-mode also looks interesting, I'll try that out.
>
> I have now worked a couple of days in text-mode instead of fundamental-mode,
> and I can't detect any difference at all (which is good for what I want). Is
> there a difference other than the hook stuff?
It looks like the most noticeable difference between text-mode and
fundamental-mode is that by default text-mode puts a newline at the
end of the file when you save if there isn't one already. It's the
simplest mode other than fundamental, after all.
And I would argue that after-change-major-mode-hook *is*
fundamental-mode's equivalent of text-mode-hook, since all major modes
are supposedly derived from fundamental-mode and those are the hooks
that get run when you switch into any mode.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How can I enable minor mode, always?
2010-10-27 16:07 ` PJ Weisberg
@ 2010-10-28 8:57 ` Oleksandr Gavenko
0 siblings, 0 replies; 8+ messages in thread
From: Oleksandr Gavenko @ 2010-10-28 8:57 UTC (permalink / raw)
To: help-gnu-emacs
On 27.10.2010 19:07, PJ Weisberg wrote:
> On Tue, Oct 26, 2010 at 11:49 PM, paxxus<paxxus@hotmail.com> wrote:
>>
>> Thanks for the suggestions.
>>
>> I used fundamental-mode, always. It turns out that you can't add hooks to
>> that mode, so I changed my default mode to text-mode, and then added this
>> hook:
>>
>> (add-hook 'text-mode-hook (lambda () (interactive) (highlight-80+-mode 1)))
>>
>> The define-globalized-minor-mode also looks interesting, I'll try that out.
>>
>> I have now worked a couple of days in text-mode instead of fundamental-mode,
>> and I can't detect any difference at all (which is good for what I want). Is
>> there a difference other than the hook stuff?
>
> It looks like the most noticeable difference between text-mode and
> fundamental-mode is that by default text-mode puts a newline at the
> end of the file when you save if there isn't one already.
I dislike this behavior so wrote:
;; See also 'mode-require-final-newline'.
(add-hook 'text-mode-hook (lambda () (setq require-final-newline nil)))
^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <mailman.3.1287810110.20231.help-gnu-emacs@gnu.org>]
* Re: How can I enable minor mode, always?
[not found] <mailman.3.1287810110.20231.help-gnu-emacs@gnu.org>
@ 2010-10-29 18:20 ` Stefan Monnier
0 siblings, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2010-10-29 18:20 UTC (permalink / raw)
To: help-gnu-emacs
> I want to always have the highlight-80+ mode enabled. In my .emacs file I
> have:
> (load "~/Emacs/highlight-80+.el")
> (require 'highlight-80+)
The require and the load are two different ways to do the same thing:
you can remove either of them.
> (highlight-80+-mode 1)
> However, when I start Emacs the highlight-80+ is not active, I have to
> manually enable it for each new buffer I open.
From what you say, it seems that this mode is buffer-local, so you need
to (re)enable it in each buffer rather than enabling it like this in
your .emacs (which will only end up enabling it in the buffer that
happens to be current when your .emacs is executed).
I suggest you try
(add-hook 'find-file-hook 'highlight-80+-mode)
> My other modes, I want to always have enabled, are enabled as follows (and
> it works for those modes):
> (show-paren-mode 1)
> (setq-default show-trailing-whitespace t)
> (setq column-number-mode t)
> As you can see each mode is enabled is slightly different ways, very
> confusing. Unfortunately none of these methods works for highlight-80+.
Yes, that's unfortunate. Some settings are controlled by functions
others by variables. So there are basically two ways to control
a global setting: calling the function with a an argument 1 or -1, or
applying `setq-default' with a value nil or t. You did it right for the
first two lines:
> (show-paren-mode 1)
> (setq-default show-trailing-whitespace t)
The last line:
> (setq column-number-mode t)
happens to work as well, but I'd recommend you change it to either of
the two (for column-number-mode they both happen to work as well):
(column-number-mode 1)
or
(setq-default column-number-mode t)
The use of `setq-default' makes it explicit that you want the setting to
be global rather than per-buffer.
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-10-29 18:20 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-21 19:46 How can I enable minor mode, always? paxxus
2010-10-23 10:57 ` PJ Weisberg
2010-10-23 15:15 ` Drew Adams
2010-10-26 23:49 ` paxxus
2010-10-27 6:43 ` Oleksandr Gavenko
2010-10-27 16:07 ` PJ Weisberg
2010-10-28 8:57 ` Oleksandr Gavenko
[not found] <mailman.3.1287810110.20231.help-gnu-emacs@gnu.org>
2010-10-29 18:20 ` 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).