unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* While editing a CMake file, how to turn off smart indentation?
@ 2015-07-16  7:23 Yaron Cohen-Tal
  2015-07-16 22:55 ` Emanuel Berg
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Yaron Cohen-Tal @ 2015-07-16  7:23 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

I just want each line to get the same indentation as the previous line, and
that TAB would indent 4 spaces. For C++ I managed it with:

    (setq-default indent-tabs-mode nil)
    (setq-default c-syntactic-indentation nil)
    (setq-default c-basic-offset 4)

In my `.emacs`, but for CMake files Emacs just indents the lines
automatically according to its own rules, and TAB has no effect at all.

Thanx,
Yaron


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: While editing a CMake file, how to turn off smart indentation?
  2015-07-16  7:23 While editing a CMake file, how to turn off smart indentation? Yaron Cohen-Tal
@ 2015-07-16 22:55 ` Emanuel Berg
  2015-07-16 23:55 ` Stefan Monnier
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 16+ messages in thread
From: Emanuel Berg @ 2015-07-16 22:55 UTC (permalink / raw)
  To: help-gnu-emacs

Yaron Cohen-Tal <yaronct@gmail.com> writes:

> I just want each line to get the same indentation as
> the previous line, and that TAB would indent 4
> spaces. For C++ I managed it with:
>
>     (setq-default indent-tabs-mode nil)

This (not having tabs) is a good idea!

>     (setq-default c-syntactic-indentation nil)

But why not have automatic indentation? C++ (and C)
are very straightforward when it comes to structure
and how nestedness is expressed in code, so why not
have the code display that visually, as well?

And, because it is so easy to do and looks the same
all the time (almost), one might just leave it to the
computer. E.g., fully automatized:

void Sporadic_Task::run(ms_t duration) {
  if (!quiet) {
    std::cout << "task " << id << " executes: " << program << std::endl;
  }
  // for extern processes, this is implicit
  if (!fork_processes) { run_program(program, program_args); }
}

This would save you six TAB strokes if you were to
disable automatic indentation! Why do it? Remember, in
special cases, you might still *change* the
indentation (using other keys than TAB). It is not
Python! But in 9*% of the cases, you don't want it so
why not automatize the common case?

If you want an "alternative TAB" for manual
indentation, why not bind say M-TAB, backtab (S-TAB),
or even write a defun that checks for a prefix
argument - if there is one, don't do
(semi-)automatized indentation, instead insert that
many number of whitespaces!

Like this:

    (defun tab-auto-or-manual (&optional spaces)
      (interactive "p")
      (if (> spaces 1) (insert-char ?\  spaces)
        (indent-for-tab-command) ))
    (global-set-key "\t" 'tab-auto-or-manual)

It is even more powerful than your idea because now
you can do `C-u C-u TAB' to get 4**2 = 16 whitespaces
and so on. (You can also use the variable
`c-basic-offset' that you mention but that is making
it less powerful.)

Of course, this is only if you are bound and
determined to do this with the TAB key. Otherwise, for
example `C-u C-u SPC' works just as well! Which is
what I do (sometimes), in the rare cases auto
indentation isn't what I want.

> In my `.emacs`, but for CMake files Emacs just
> indents the lines automatically according to its own
> rules, and TAB has no effect at all.

What is CMake? I don't get any apropos matches and
there isn't anything in the Emacs documentation
according to my razor-sharp tools for finding out.
But if it is something different (from C and C++)
altogether, it isn't strange that doing that
won't help. You need to examine the Emacs mode not for
the programming, but for the "cmake and CMakefile"
system, and set it there. To find out what TAB does,
hit `C-h k TAB' while in a buffer with that kind of
file. If you don't like what it does, you can change
that, of course.

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: While editing a CMake file, how to turn off smart indentation?
  2015-07-16  7:23 While editing a CMake file, how to turn off smart indentation? 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>
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 16+ messages in thread
From: Stefan Monnier @ 2015-07-16 23:55 UTC (permalink / raw)
  To: help-gnu-emacs

> In my `.emacs`, but for CMake files Emacs just indents the lines
> automatically according to its own rules, and TAB has no effect at all.

What major mode does Emacs use for those files?


        Stefan




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: While editing a CMake file, how to turn off smart indentation?
       [not found] ` <mailman.7023.1437087429.904.help-gnu-emacs@gnu.org>
@ 2015-07-17  1:14   ` Dan Espen
  0 siblings, 0 replies; 16+ messages in thread
From: Dan Espen @ 2015-07-17  1:14 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> Yaron Cohen-Tal <yaronct@gmail.com> writes:
>> In my `.emacs`, but for CMake files Emacs just
>> indents the lines automatically according to its own
>> rules, and TAB has no effect at all.
>
> What is CMake? I don't get any apropos matches and
> there isn't anything in the Emacs documentation
> according to my razor-sharp tools for finding out.

CMake files have the suffix ".cmake".
Emacs does not appear to handle them, you end up in Fundamental mode.

GNU Emacs 24.5.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.14.12) of 2015-05-07 on buildvm-08.phx2.fedoraproject.org

They look like a script with '#' comments so there might be a mode that
would come close:

  # Install script for directory: /home/me/src/libomron

  # Set the install prefix
  IF(NOT DEFINED CMAKE_INSTALL_PREFIX)
    SET(CMAKE_INSTALL_PREFIX "/usr/local")
  ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX)
  STRING(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")

So, tab should just self insert.

For the original poster:

In Emacs, the tab key works differently depending on the mode.
The mode is often set automatically based on the file extension.
You can see the mode inside () on the mode line, its the first word.

If you are in fundamental mode, the tab key should insert a tab.
Emacs by default tabs by 8.

All of this can be changed, but don't do it to fundamental mode.

Try this:

http://www.emacswiki.org/emacs/CMakeMode


-- 
Dan Espen


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: While editing a CMake file, how to turn off smart indentation?
@ 2015-07-17  4:18 Yaron Cohen-Tal
  2015-07-17  5:59 ` Vaidheeswaran C
  2015-07-17 23:34 ` Emanuel Berg
  0 siblings, 2 replies; 16+ messages in thread
From: Yaron Cohen-Tal @ 2015-07-17  4:18 UTC (permalink / raw)
  To: help-gnu-emacs

CMake files come with extension ".cmake" or with name "CMakeLists.txt". My
emacs seems to identify them correctly as CMAKE mode, and highlight them
accordingly.

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)? Sorry but I'm not experienced with ELisp.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: While editing a CMake file, how to turn off smart indentation?
  2015-07-16  7:23 While editing a CMake file, how to turn off smart indentation? Yaron Cohen-Tal
                   ` (2 preceding siblings ...)
       [not found] ` <mailman.7023.1437087429.904.help-gnu-emacs@gnu.org>
@ 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
  5 siblings, 1 reply; 16+ messages in thread
From: Vaidheeswaran C @ 2015-07-17  5:39 UTC (permalink / raw)
  To: help-gnu-emacs

On Thursday 16 July 2015 12:53 PM, Yaron Cohen-Tal wrote:
> Hi,
> 
> I just want each line to get the same indentation as the previous line, and
> that TAB would indent 4 spaces. For C++ I managed it with:
> 
>     (setq-default indent-tabs-mode nil)
>     (setq-default c-syntactic-indentation nil)
>     (setq-default c-basic-offset 4)
> 
> In my `.emacs`, but for CMake files Emacs just indents the lines
> automatically according to its own rules, and TAB has no effect at all.
> 
> Thanx,
> Yaron
> 

cmake is absent in

    http://www.emacswiki.org/emacs/List_Of_Major_And_Minor_Modes

This suggests that with a __very high__ probablity that Cmake is not
part of GNU Emacs proper.

cmake-mode comes from


http://www.cmake.org/gitweb?p=cmake.git;a=blob_plain;f=Auxiliary/cmake-mode.el;hb=HEAD

Do they have a discussion list?  May be you can write to one of the
recent committers or put a note in emacswiki (and cross your fingers):


http://www.cmake.org/gitweb?p=cmake.git;a=history;f=Auxiliary/cmake-mode.el;h=51663a8e10772a598f15acbcab9545be2cb3a3c8;hb=HEAD




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: While editing a CMake file, how to turn off smart indentation?
  2015-07-16  7:23 While editing a CMake file, how to turn off smart indentation? Yaron Cohen-Tal
                   ` (3 preceding siblings ...)
  2015-07-17  5:39 ` Vaidheeswaran C
@ 2015-07-17  5:52 ` Vaidheeswaran C
  2015-07-17 15:01 ` Ian Zimmerman
  5 siblings, 0 replies; 16+ messages in thread
From: Vaidheeswaran C @ 2015-07-17  5:52 UTC (permalink / raw)
  To: help-gnu-emacs

On Thursday 16 July 2015 12:53 PM, Yaron Cohen-Tal wrote:

> In my `.emacs`, but for CMake files Emacs just indents the lines
> automatically according to its own rules, and TAB has no effect at all.

You may have to help yourself.

A quick look at the .el file suggests, that you have to focus on these
lines:

    ;; Indentation increment.
    225 ;;
    226 (defvar cmake-tab-width 2)

    ; Setup indentation function.
    254   (make-local-variable 'indent-line-function)
    255   (setq indent-line-function 'cmake-indent)


A good way to understand elisp code, is by just focusing on the
comments in source code or if you are adventurous, look at the elisp
code as though it is a non-native speaker of English trying to make
itself understood to you.





^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: While editing a CMake file, how to turn off smart indentation?
  2015-07-17  4:18 Yaron Cohen-Tal
@ 2015-07-17  5:59 ` Vaidheeswaran C
  2015-07-17 23:34 ` Emanuel Berg
  1 sibling, 0 replies; 16+ messages in thread
From: Vaidheeswaran C @ 2015-07-17  5:59 UTC (permalink / raw)
  To: Yaron Cohen-Tal, help-gnu-emacs

On Friday 17 July 2015 09:48 AM, Yaron Cohen-Tal wrote:

> plz give me the ELisp code to make "ctrl+TAB" (without numeric
> argument) insert exactly 4 spaces

For indentation

    C-u 4 C-x TAB (which is same as C-4 C-x TAB)

For de-indentation

    C-u - 4 C-x TAB

(Note the minus prefix)

----------------------------------------------------------------

One another way to indent or de-indent is via rectangle editing.

For indentation

    C-x r o

For de-indentation

    C-x r k





^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: While editing a CMake file, how to turn off smart indentation?
  2015-07-16  7:23 While editing a CMake file, how to turn off smart indentation? Yaron Cohen-Tal
                   ` (4 preceding siblings ...)
  2015-07-17  5:52 ` Vaidheeswaran C
@ 2015-07-17 15:01 ` Ian Zimmerman
  5 siblings, 0 replies; 16+ messages in thread
From: Ian Zimmerman @ 2015-07-17 15:01 UTC (permalink / raw)
  To: help-gnu-emacs

On 2015-07-16 10:23 +0300, Yaron Cohen-Tal wrote:

> I just want each line to get the same indentation as the previous
> line, and that TAB would indent 4 spaces.

My ancient mindent.el module - now on github [1] - may be helpful for
this.  It is not totally plug and play, though; to make use of it you
need to understand Emacs concepts such as modes and keymaps.

[1]
https://github.com/nobrowser/mindent

-- 
Please *no* private copies of mailing list or newsgroup messages.
Rule 420: All persons more than eight miles high to leave the court.




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: While editing a CMake file, how to turn off smart indentation?
  2015-07-17  4:18 Yaron Cohen-Tal
  2015-07-17  5:59 ` Vaidheeswaran C
@ 2015-07-17 23:34 ` Emanuel Berg
  2015-07-17 23:54   ` John Mastro
  1 sibling, 1 reply; 16+ messages in thread
From: Emanuel Berg @ 2015-07-17 23:34 UTC (permalink / raw)
  To: help-gnu-emacs

Yaron Cohen-Tal <yaronct@gmail.com> writes:

> Sorry but I'm not experienced with ELisp.

Well, start today! "What you once feared, now makes
you free."

> 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)?

My idea isn't that, but on the contrary:

    1. Use the default, syntactic and
       automatic indentation.

    2. If you don't want to do that, use `C-u SPC' and
       `C-u DEL' to do what you want.

But OK, the functions would look like this:

(defun insert-four-spaces ()
  (interactive)
  (insert-char ?\  4) )

(defun remove-four-chars ()
  (interactive)
  (backward-delete-char 4) )

The shortcuts on the other hand is the tricky part.
I do this in a special way (which is easy), however
you probably won't be helped by that as you don't use
the ttys (also known as the console or "Linux VTs") -
you use the GUI Emacs of X, right? (If I'm wrong, I'm
happy to help you my way.)

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)

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: While editing a CMake file, how to turn off smart indentation?
  2015-07-17  5:39 ` Vaidheeswaran C
@ 2015-07-17 23:37   ` Emanuel Berg
  0 siblings, 0 replies; 16+ messages in thread
From: Emanuel Berg @ 2015-07-17 23:37 UTC (permalink / raw)
  To: help-gnu-emacs

Vaidheeswaran C <vaidheeswaran.chinnaraju@gmail.com>
writes:

> cmake-mode comes from ... Do they have
> a discussion list?

On Gmane, there are these mentions of "cmake":

    gmane.comp.lib.boost.cmake
    gmane.comp.programming.tools.cmake.devel
    gmane.comp.programming.tools.cmake.scm
    gmane.comp.programming.tools.cmake.user

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: While editing a CMake file, how to turn off smart indentation?
  2015-07-17 23:34 ` Emanuel Berg
@ 2015-07-17 23:54   ` John Mastro
  2015-07-18  0:26     ` Emanuel Berg
  0 siblings, 1 reply; 16+ messages in thread
From: John Mastro @ 2015-07-17 23:54 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

>> 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



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: While editing a CMake file, how to turn off smart indentation?
  2015-07-17 23:54   ` John Mastro
@ 2015-07-18  0:26     ` Emanuel Berg
  2015-07-18 17:58       ` Yaron Cohen-Tal
  0 siblings, 1 reply; 16+ messages in thread
From: Emanuel Berg @ 2015-07-18  0:26 UTC (permalink / raw)
  To: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: While editing a CMake file, how to turn off smart indentation?
  2015-07-18  0:26     ` Emanuel Berg
@ 2015-07-18 17:58       ` Yaron Cohen-Tal
  2015-07-18 19:18         ` John Mastro
  0 siblings, 1 reply; 16+ messages in thread
From: Yaron Cohen-Tal @ 2015-07-18 17:58 UTC (permalink / raw)
  To: help-gnu-emacs

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
>
>
>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: While editing a CMake file, how to turn off smart indentation?
  2015-07-18 17:58       ` Yaron Cohen-Tal
@ 2015-07-18 19:18         ` John Mastro
  2015-07-19 17:35           ` Yaron Cohen-Tal
  0 siblings, 1 reply; 16+ messages in thread
From: John Mastro @ 2015-07-18 19:18 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org; +Cc: Yaron Cohen-Tal

> 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:

Try this (in your init file; no need to modify cmake-mode.el):

    (defun my-set-relative-indent ()
      (setq-local indent-line-function #'indent-relative))

    (add-hook 'cmake-mode-hook #'my-set-relative-indent)

-- 
john



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: While editing a CMake file, how to turn off smart indentation?
  2015-07-18 19:18         ` John Mastro
@ 2015-07-19 17:35           ` Yaron Cohen-Tal
  0 siblings, 0 replies; 16+ messages in thread
From: Yaron Cohen-Tal @ 2015-07-19 17:35 UTC (permalink / raw)
  To: John Mastro; +Cc: help-gnu-emacs@gnu.org

That did the trick, thanx!

On Sat, Jul 18, 2015 at 10:18 PM, John Mastro <john.b.mastro@gmail.com>
wrote:

> > 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:
>
> Try this (in your init file; no need to modify cmake-mode.el):
>
>     (defun my-set-relative-indent ()
>       (setq-local indent-line-function #'indent-relative))
>
>     (add-hook 'cmake-mode-hook #'my-set-relative-indent)
>
> --
> john
>


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-07-19 17:35 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-16  7:23 While editing a CMake file, how to turn off smart indentation? 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
  -- strict thread matches above, loose matches on Subject: below --
2015-07-17  4:18 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
2015-07-18 19:18         ` John Mastro
2015-07-19 17:35           ` Yaron Cohen-Tal

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).