unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Yaron Cohen-Tal <yaronct@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: While editing a CMake file, how to turn off smart indentation?
Date: Sat, 18 Jul 2015 20:58:01 +0300	[thread overview]
Message-ID: <CADKOXrA4YnZ89mnk1PB3E6Qmk0g+LcnhfOcCWyjpn6WLE-cPbQ@mail.gmail.com> (raw)
In-Reply-To: <87zj2ufgzr.fsf@nl106-137-147.student.uu.se>

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	other threads:[~2015-07-18 17:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-17  4:18 While editing a CMake file, how to turn off smart indentation? Yaron Cohen-Tal
2015-07-17  5:59 ` Vaidheeswaran C
2015-07-17 23:34 ` Emanuel Berg
2015-07-17 23:54   ` John Mastro
2015-07-18  0:26     ` Emanuel Berg
2015-07-18 17:58       ` Yaron Cohen-Tal [this message]
2015-07-18 19:18         ` John Mastro
2015-07-19 17:35           ` Yaron Cohen-Tal
  -- strict thread matches above, loose matches on Subject: below --
2015-07-16  7:23 Yaron Cohen-Tal
2015-07-16 22:55 ` Emanuel Berg
2015-07-16 23:55 ` Stefan Monnier
     [not found] ` <mailman.7023.1437087429.904.help-gnu-emacs@gnu.org>
2015-07-17  1:14   ` Dan Espen
2015-07-17  5:39 ` Vaidheeswaran C
2015-07-17 23:37   ` Emanuel Berg
2015-07-17  5:52 ` Vaidheeswaran C
2015-07-17 15:01 ` Ian Zimmerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADKOXrA4YnZ89mnk1PB3E6Qmk0g+LcnhfOcCWyjpn6WLE-cPbQ@mail.gmail.com \
    --to=yaronct@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).