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

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

Re: While editing a CMake file, how to turn off smart indentation?


From: John Mastro
Subject: Re: While editing a CMake file, how to turn off smart indentation?
Date: Fri, 17 Jul 2015 16:54:03 -0700

>> Emanuel, let's say I borrow your idea. can u plz
>> give me the ELisp code to make "ctrl+TAB" (without
>> numeric argument) insert exactly 4 spaces, and make
>> "shift+TAB" (without numeric argument) remove
>> exactly 4 spaces (or any 4 characters)?

> Still, you can try this. If it doesn't work, someone
> else has to help you:
>
> (global-set-key [\C-\t] 'insert-four-spaces)
> (global-set-key [\M-\t] 'remove-four-chars)

Yaron will actually need something like this for the second one:

(global-set-key [backtab] 'remove-four-chars)

The \M in [\M-\t] if for the "meta" (usually labeled "alt"). I know
Emanuel knows this but I'm mentioning it for Yaron's benefit.

I also had to change the key for the first one to (kbd "<C-tab>") or
[C-tab] for it to work on my system.

One more thing - I'd recommend binding the keys in cmake-mode's keymap
rather than the global map, in case you want to do things differently in
other modes.

Putting that all together, and making some assumptions about cmake-mode
(that its feature is `cmake-mode' and its mode map is `cmake-mode-map'),
we'd end up with:

(eval-after-load 'cmake-mode
  '(progn
     (define-key cmake-mode-map (kbd "<C-tab>") 'insert-four-spaces)
     (define-key cmake-mode-map (kbd "<backtab>") 'remove-four-chars)))

-- 
john



reply via email to

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