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: Yaron Cohen-Tal
Subject: Re: While editing a CMake file, how to turn off smart indentation?
Date: Sat, 18 Jul 2015 20:58:01 +0300

Thanx guys,

The shortcuts to (un)indent 4 spaces work perfectly. What I still don't
manage is to make "RET" simply start a new line with indentation identical
to the previous line. In C++ mode I arranged it so behave this way. I tried
changing the code in "cmake-mode.el" from:

  (make-local-variable 'indent-line-function)
  (setq indent-line-function 'cmake-indent)

to:

  (make-local-variable 'indent-line-function)
  (setq indent-line-function 'c-indent-line-or-region)

Because "c-indent-line-or-region" is what's called when pressing TAB in C++
mode, and I want the same behavior. But instead, with CMake files, RET now
starts a new line with no indentation at all.

Btw u can get the "cmake-mode.el" file from the "cmake-data" package (in
Debian). I also uploaded it here
<https://www.dropbox.com/s/jl2w6okpt91e8zs/cmake-mode.el?dl=0>.

On Sat, Jul 18, 2015 at 3:26 AM, Emanuel Berg <embe8573@student.uu.se>
wrote:

> John Mastro <john.b.mastro@gmail.com> writes:
>
> > Yaron will actually need something like this for the
> > second one:
> >
> > (global-set-key [backtab] 'remove-four-chars)
>
> Right, it was shift, not Meta! Yes, Mastro is right.
>
> > 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.
>
> This
>
>     (global-set-key [C-tab] 'insert-four-spaces)
>
> works for me as well. The reason I put it the other
> way is I first put it this way:
>
>     (global-set-key [C-TAB] 'insert-four-spaces)
>
> And then it says:
>
>     To bind the key C-TAB, use [?\\C-\\t], not [C-TAB]
>
> But neither, nor
>
>     (global-set-key [?\C-\t]   'insert-four-spaces)
>     (global-set-key [?\\C-\\t] 'insert-four-spaces)
>
> works what I can see (and the second don't even eval).
>
> What does it mean?
>
> > 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.
>
> Yes, of course, I thought that was self-evident.
> Ehm... Anyway, another way to do it is to `defvar'
> the cmake-mode-map, and then set the keys up in
> a hook. Like this, but not with IELM but cmake:
>
> (defvar ielm-map)
>
> ;; (setq ielm-mode-hook nil) ; use to reset hook
> (defun ielm-mode-hook-f ()
>   (let ((the-map ielm-map))
>     (define-key the-map "\C-xk" 'bury-buffer)
>     (define-key the-map "\C-p"  'comint-previous-input)
>     (define-key the-map "\C-n"  'comint-next-input) ))
> (add-hook 'ielm-mode-hook 'ielm-mode-hook-f)
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
>
>
>


reply via email to

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