LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 04-13-2009, 03:25 PM   #1
nb85
LQ Newbie
 
Registered: Apr 2009
Posts: 2

Rep: Reputation: 0
Emacs: Enable minor mode in all buffers


Hi all,

Does anyone know how to enable an emacs minor mode by default for all buffers?

For example, I have the minor mode highlight-80+-mode that I can toggle with M-x highlight-80+mode, however I would like this to be on by default.

Any pointers to documentation/config/lisp stuff appreciated.

Many thanks,

Nick
 
Old 04-13-2009, 04:14 PM   #2
kandiru
Member
 
Registered: Mar 2009
Location: Genoa, Italy
Distribution: Slackware
Posts: 33

Rep: Reputation: 16
Hello,

may be you can find something useful here

http://www.linuxjournal.com/node/2801/print

in the section related to "Using hooks"

Hope this could help you

Bye

David
 
Old 04-13-2009, 04:56 PM   #3
nb85
LQ Newbie
 
Registered: Apr 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by kandiru View Post
Hello,

may be you can find something useful here

http://www.linuxjournal.com/node/2801/print

in the section related to "Using hooks"

Hope this could help you

Bye

David
Thanks for your reply. The site you provided was very useful indeed. I have added a hook to my .emacs for c-mode that does exactly what was required.

Thanks again,

Nick
 
Old 12-18-2014, 08:03 AM   #4
just-a-guest
LQ Newbie
 
Registered: Apr 2014
Posts: 10

Rep: Reputation: Disabled
I am wonder why the author was satisfied with the answer that isn't an answer to the question at all… It took me for a while to find a way, so I am decided to share a real answer:

Emacs have the macro «define-global-minor-mode». It was a bit hard to me to figure out the right way of passing arguments — I all the time thought that the first arg is a string, and the second should be quoted. Until I found an example in a mailing list — then I saw: it's a macro, not a function! So, an example with one useful minor mode:

Code:
(define-global-minor-mode global-highlight-symbol-mode ;;the name of the new global mode
  highlight-symbol-mode ;;the name of the minor mode you want to turn on
  (lambda () (highlight-symbol-mode t) ;;the function to turn on the mode
	))
I didn't quite understood, though, what is the need of the second argument, since the mode is enabled in the last one.
Don't forget to enable it with «M-x global-highlight-symbol-mode» (or whatever the name you used).
 
Old 12-18-2014, 11:32 AM   #5
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 2,543

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
Quote:
Originally Posted by just-a-guest View Post
I didn't quite understood, though, what is the need of the second argument, since the mode is enabled in the last one.
You can pass a function that only sometimes enables the mode. But regardless, the macro needs to know the name of the mode, which it learns from the second argument.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I enable emacs Backspace on remote logins? jkcunningham Linux - General 18 09-21-2009 04:51 PM
LXer: Emacs tips: Windows and buffers LXer Syndicated Linux News 0 06-01-2006 10:03 AM
Emacs: sgml mode lackluster Programming 4 04-23-2006 09:50 PM
.emacs file and Scheme buffers jrdioko Linux - Software 0 10-01-2005 12:22 AM
emacs: continuous newline (minor mode?) tek1024 Linux - Software 1 08-11-2004 03:09 PM


All times are GMT -5. The time now is 09:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration