mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Added a handy backspace binding to the haml-mode.el.
git-svn-id: svn://hamptoncatlin.com/haml/trunk@401 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
parent
e7555b40db
commit
04cd02784b
1 changed files with 25 additions and 1 deletions
|
@ -25,6 +25,11 @@
|
||||||
:type 'integer
|
:type 'integer
|
||||||
:group 'haml)
|
:group 'haml)
|
||||||
|
|
||||||
|
(defcustom haml-backspace-function 'backward-delete-char-untabify
|
||||||
|
"*Function called by `haml-electric-backspace' when deleting backwards."
|
||||||
|
:type 'function
|
||||||
|
:group 'haml)
|
||||||
|
|
||||||
;; Helper Functions
|
;; Helper Functions
|
||||||
|
|
||||||
(defun string-* (str i)
|
(defun string-* (str i)
|
||||||
|
@ -42,7 +47,7 @@
|
||||||
(defconst haml-blank-line-re "^[ \t]*$"
|
(defconst haml-blank-line-re "^[ \t]*$"
|
||||||
"Regexp matching a line containing only whitespace.")
|
"Regexp matching a line containing only whitespace.")
|
||||||
|
|
||||||
(defconst haml-tag-re (hre "[%\\.#][^ \t]*\\({.*}\\)?\\(\\[.*\\]\\).?[ \t]*$")
|
(defconst haml-tag-re (hre "[%\\.#][^ \t]*\\({.*}\\)?\\(\\[.*\\]\\)?.?[ \t]*$")
|
||||||
"Regexp matching a Haml tag.")
|
"Regexp matching a Haml tag.")
|
||||||
|
|
||||||
(defconst haml-block-re (hre "[-=].*do[ \t]*\\(|.*|[ \t]*\\)?$")
|
(defconst haml-block-re (hre "[-=].*do[ \t]*\\(|.*|[ \t]*\\)?$")
|
||||||
|
@ -70,6 +75,9 @@
|
||||||
(if haml-mode-map
|
(if haml-mode-map
|
||||||
nil
|
nil
|
||||||
(setq haml-mode-map (make-sparse-keymap))
|
(setq haml-mode-map (make-sparse-keymap))
|
||||||
|
(define-key haml-mode-map [backspace] 'haml-electric-backspace)
|
||||||
|
(define-key haml-mode-map "\C-?" 'haml-electric-backspace)
|
||||||
|
(define-key haml-mode-map "\C-a" 'haml-electric-backspace)
|
||||||
(define-key haml-mode-map "\C-j" 'newline-and-indent))
|
(define-key haml-mode-map "\C-j" 'newline-and-indent))
|
||||||
|
|
||||||
;(defvar haml-mode-syntax-table nil
|
;(defvar haml-mode-syntax-table nil
|
||||||
|
@ -129,6 +137,22 @@ back-dent the line by `haml-indent-offset' spaces. On reaching column
|
||||||
(if (< (current-column) (current-indentation))
|
(if (< (current-column) (current-indentation))
|
||||||
(forward-to-indentation 0))))
|
(forward-to-indentation 0))))
|
||||||
|
|
||||||
|
(defun haml-electric-backspace (arg)
|
||||||
|
"Delete characters or back-dent the current line.
|
||||||
|
If invoked following only whitespace on a line, will back-dent to the
|
||||||
|
immediately previous multiple of `haml-indent-offset' spaces."
|
||||||
|
(interactive "*p")
|
||||||
|
(if (or (/= (current-indentation) (current-column)) (bolp))
|
||||||
|
(funcall haml-backspace-function arg)
|
||||||
|
(let ((ci (current-column)))
|
||||||
|
(beginning-of-line)
|
||||||
|
(delete-horizontal-space)
|
||||||
|
(indent-to (* (/ (- ci (* arg haml-indent-offset))
|
||||||
|
haml-indent-offset)
|
||||||
|
haml-indent-offset)))))
|
||||||
|
|
||||||
|
;; Setup/Activation
|
||||||
|
|
||||||
(defun haml-mode-version ()
|
(defun haml-mode-version ()
|
||||||
"Diplay version of `haml-mode'."
|
"Diplay version of `haml-mode'."
|
||||||
(interactive)
|
(interactive)
|
||||||
|
|
Loading…
Add table
Reference in a new issue