help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: turning off all indentation


From: Scott Frazer
Subject: Re: turning off all indentation
Date: Wed, 08 Dec 2010 15:08:15 -0000
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4

On 5/12/10 8:31 PM, Tim X wrote:

Doing it for all possible modes is probably an impossible task as there
is no way to identify all possible modes - if not an infinite set, it
certainly wold be a very large one.

The best I suspect you can do is use hooks to ensure keys like enter and
tab are bound to their basic functions. This could be difficult as there
is no guarantee that a mode provides such a hook and there are some
modes that provide quite sophisticated behavior, such as behving
differently depending on how many time the key is pressed within a
certain interval etc. Re-binding such keys could easily result in the
loss of valuable functionality as well as indentation.

There is no simple way this can be done. It is very much working against
what the modes are desinged for. In many cases, once you remove custom
indentation behavior, all you are left with is font locking.

I use a minor-mode, defined at the end of my .emacs.d/init.el, that overrides
things in major-modes that annoy me:

(defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")

(defmacro my-keys-define (key fn)
  (list 'define-key 'my-keys-minor-mode-map (list 'kbd key) fn))

;; Example for OP, I don't do this myself :)

(my-keys-define "<return>" 'newline)

(define-minor-mode my-keys-minor-mode
  "A minor mode so that my key settings override annoying major modes."
  t " my-keys" 'my-keys-minor-mode-map)

(my-keys-minor-mode 1)

;; You probably don't want this in the minibuffer

(defun my-minibuffer-setup-hook ()
  (my-keys-minor-mode 0))

(add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)

You may have to add other turn-off-my-keys-minor-mode hooks for things where
<return> needs to do something other than insert a newline.  The set will
probably be relatively small.

Scott


reply via email to

[Prev in Thread] Current Thread [Next in Thread]