Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add customization to turn off skipping whitespace when expanding

 - also turned off by default in python modes

Fixes #51
  • Loading branch information...
commit bf8f4a45710a3fbfef6fe22d84180521c4a570fd 1 parent ae05024
@magnars authored
View
3  expand-region-core.el
@@ -304,7 +304,8 @@ moving point or mark as little as possible."
(= end best-end))
(push (cons start end) er/history))
- (when (and (er--point-is-surrounded-by-white-space)
+ (when (and expand-region-skip-whitespace
+ (er--point-is-surrounded-by-white-space)
(= start end))
(skip-chars-forward er--space-str)
(setq start (point)))
View
6 expand-region-custom.el
@@ -55,6 +55,12 @@ always be copied to the register named after that character."
:group 'expand-region
:type 'string)
+(defcustom expand-region-skip-whitespace t
+ "If expand-region should skip past whitespace on initial expansion"
+ :group 'expand-region
+ :type '(choice (const :tag "Skip whitespace" t)
+ (const :tag "Do not skip whitespace" nil)))
+
(provide 'expand-region-custom)
;;; expand-region-custom.el ends here
View
5 python-el-expansions.el
@@ -81,7 +81,10 @@
(remove 'er/mark-outside-quotes
(append er/try-expand-list try-expand-list-additions))))))
-(add-hook 'python-mode-hook 'er/add-python-mode-expansions)
+(add-hook 'python-mode-hook
+ #'(lambda ()
+ (set (make-local-variable 'expand-region-skip-whitespace) nil)
+ (er/add-python-mode-expansions)))
(provide 'python-el-expansions)
View
13 python-el-fgallina-expansions.el
@@ -36,10 +36,10 @@
"'\""
"Characters that delimit a Python string.")
-; copied from @fgallina's python.el as a quick fix. The variable
-; `python-rx-constituents' is not bound when we use the python-rx
-; macro from here, so we have to construct the regular expression
-; manually.
+;; copied from @fgallina's python.el as a quick fix. The variable
+;; `python-rx-constituents' is not bound when we use the python-rx
+;; macro from here, so we have to construct the regular expression
+;; manually.
(defvar er--python-block-start-regex
(rx symbol-start
(or "def" "class" "if" "elif" "else" "try"
@@ -154,7 +154,10 @@ Command that wraps `er/mark-python-block'."
(append er/try-expand-list try-expand-list-additions))))))
-(add-hook 'python-mode-hook 'er/add-python-mode-expansions)
+(add-hook 'python-mode-hook
+ #'(lambda ()
+ (set (make-local-variable 'expand-region-skip-whitespace) nil)
+ (er/add-python-mode-expansions)))
(provide 'python-el-fgallina-expansions)
View
5 python-mode-expansions.el
@@ -131,7 +131,10 @@ line and selecting the surrounding block."
(append er/try-expand-list try-expand-list-additions))))))
-(add-hook 'python-mode-hook 'er/add-python-mode-expansions)
+(add-hook 'python-mode-hook
+ #'(lambda ()
+ (set (make-local-variable 'expand-region-skip-whitespace) nil)
+ (er/add-python-mode-expansions)))
(provide 'python-mode-expansions)
Please sign in to comment.
Something went wrong with that request. Please try again.