nex3 / sass-mode

Emacs mode for Sass

Home Page:http://sass-lang.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Backspace and c-j problem

lorensr opened this issue · comments

When I hit backspace, for instance after c-j, which always goes to one level deeper instead of the same level, nothing happens except for the control buffer giving the message "Mark set". When I check I see it's bound to haml-electric-backspace. Thus the only two ways I can create a new line and move my cursor to the same level of indentation as the last line is ret tab tab or c-j followed by c-b c-b or tab tab. I think c-j should default to the same level and that backspace should have the default emacs behavior.

Heya, I just did some work on haml-mode, which sass-mode uses under the covers.

And with the latest version of haml-mode, the backspace problem is gone. :-)

Hi, @purcell

I had a fresh installion of Emacs 24.2 from http://emacsforosx.com, put only following content into user-init-file to install el-get

(add-to-list 'load-path "~/.emacs.d/el-get/el-get")

(unless (require 'el-get nil 'noerror)
  (with-current-buffer
      (url-retrieve-synchronously
       "https://raw.github.com/dimitri/el-get/master/el-get-install.el")
    (goto-char (point-max))
    (eval-print-last-sexp)))

(el-get 'sync)

After installed el-get, M-x el-get-install sass-mode, first haml-mode then sass-mode installed.

As https://github.com/dimitri/el-get/blob/4.stable/recipes/haml-mode.rcp and https://github.com/dimitri/el-get/blob/4.stable/recipes/sass-mode.rcp describe, el-get install these two mode from default branch aka master, so I think i got newest code.

After all, I opened a sass file with following content:

.testme
  width: 44px
  height: 44px

when I move my cursor to end of line 1, and hit C-j, the cursor has the same indentation level like other rules:

.testme
  | <- okay, this is the cursor.
  width: 44px
  height: 44px

when I move my cursor to end of line 2 or 3 or any rules, hit C-j, I got the following behavior:

.testme
  width: 44px
    | <- fake cursor again
  height: 44px

but what we expect when hit C-j are like this:

.testme
  | <- cursor here
  width: 44px
  | <- and here
  height: 44px
  | <- also here

@L42y Right, I see. I misunderstood -- I thought you were still seeing a hard error, but you're actually confirming that the behaviour of C-j is still undesirable. I agree, and I'll see if I can make it more intuitive by modifying haml-indent-line.

In the meantime, at least backspace will now work correctly to move the cursor back to the desired indentation level.

-Steve

The following definition prevents extra indentation after property assignment:

(defun sass-indent-p ()
  "Return t if the current line can have lines nested beneath it."
  (unless (or (looking-at "^.* :.*$")
              (looking-at "^.*: .*$"))
    (loop for opener in sass-non-block-openers
          if (looking-at opener) return nil
          finally return t)))

@orivej Thanks, this works perfectly for me. Perhaps you could issue a pull request to integrate this change?

I've filed a fix in #12.