unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Aleš Bizjak" <ales.bizjak0@gmail.com>
To: Andrew Pennebaker <andrew.pennebaker@gmail.com>
Cc: Emacs Help <help-gnu-emacs@gnu.org>
Subject: Re: Indent one level deeper rather than smart indent?
Date: Fri, 22 Mar 2013 21:12:38 +0100	[thread overview]
Message-ID: <CAKVLaw6ha4rFD46YA6pg3Uo=pNzuyi50pDa7sRMWwS9+ijo3oA@mail.gmail.com> (raw)
In-Reply-To: <CAHXt_SU4+RywMr-PXXuo6VKbkeU-T4Ms1n2FuTn6L6c4nzLyAg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1597 bytes --]

On 22 March 2013 17:06, Andrew Pennebaker <andrew.pennebaker@gmail.com>wrote:

> When in markdown-mode, I would like to disable smart indent. Instead, when
> I highlight a block of code and press TAB, I would like the block to be
> indented one level deeper, like how Sublime does it.
>
> What goes in my ~/.emacs to achieve this?
>
>
Which markdown-mode are you using? If the one at
http://jblevins.org/projects/markdown-mode/ then I think something like

(defadvice markdown-cycle (around indent-active-region-rigidly (&optional
arg shift) activate)
  (if (use-region-p)
      (save-excursion
        (let ((rb (region-beginning))
              (re (region-end)))
          (goto-char rb)
          (beginning-of-line)
          (indent-rigidly (point)
                          re
                          (if shift (- tab-width) tab-width))
          (setq deactivate-mark nil)))
    ad-do-it))

should do it. If you don't have an active region TAB will behave the same
as before, but if you have an active region, it will indent the whole
region for tab-width. I have never used sublime-text so I don't know
whether this is what you actually want. If you always want to indent and
never want to cycle the visibility then the solution is simpler.

If you want Shift+TAB to indent regions to the left then also put

(add-hook 'markdown-mode-hook
          (lambda ()
            (fset 'markdown-shifttab
                  (lambda ()
                    (interactive)
                    (markdown-cycle t t)))))

into your .emacs.

-- Cheers, Aleš

[-- Attachment #2: Type: text/html, Size: 2472 bytes --]

  reply	other threads:[~2013-03-22 20:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-22 16:06 Indent one level deeper rather than smart indent? Andrew Pennebaker
2013-03-22 20:12 ` Aleš Bizjak [this message]
2013-03-26 13:18   ` Andrew Pennebaker

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='CAKVLaw6ha4rFD46YA6pg3Uo=pNzuyi50pDa7sRMWwS9+ijo3oA@mail.gmail.com' \
    --to=ales.bizjak0@gmail.com \
    --cc=andrew.pennebaker@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).