(py-comment-indent-function): A replacement for
comment-indent-function's default lambda value (in simple.el), this version finally kills this nit: auto-filling a comment that starts in column zero with filladapt turned off would cascade the #'s to the right. Now auto-filling seems to work with or without filladapt, and with the comment starting in any column. (python-mode): Set comment-indent-function.
This commit is contained in:
parent
9d865e1a30
commit
003932a508
|
@ -979,24 +979,26 @@ py-beep-if-tab-change\t\tring the bell if tab-width is changed"
|
||||||
(make-local-variable 'comment-end)
|
(make-local-variable 'comment-end)
|
||||||
(make-local-variable 'comment-start-skip)
|
(make-local-variable 'comment-start-skip)
|
||||||
(make-local-variable 'comment-column)
|
(make-local-variable 'comment-column)
|
||||||
|
(make-local-variable 'comment-indent-function)
|
||||||
(make-local-variable 'indent-region-function)
|
(make-local-variable 'indent-region-function)
|
||||||
(make-local-variable 'indent-line-function)
|
(make-local-variable 'indent-line-function)
|
||||||
(make-local-variable 'add-log-current-defun-function)
|
(make-local-variable 'add-log-current-defun-function)
|
||||||
;;
|
;;
|
||||||
(set-syntax-table py-mode-syntax-table)
|
(set-syntax-table py-mode-syntax-table)
|
||||||
(setq major-mode 'python-mode
|
(setq major-mode 'python-mode
|
||||||
mode-name "Python"
|
mode-name "Python"
|
||||||
local-abbrev-table python-mode-abbrev-table
|
local-abbrev-table python-mode-abbrev-table
|
||||||
font-lock-defaults '(python-font-lock-keywords)
|
font-lock-defaults '(python-font-lock-keywords)
|
||||||
paragraph-separate "^[ \t]*$"
|
paragraph-separate "^[ \t]*$"
|
||||||
paragraph-start "^[ \t]*$"
|
paragraph-start "^[ \t]*$"
|
||||||
require-final-newline t
|
require-final-newline t
|
||||||
comment-start "# "
|
comment-start "# "
|
||||||
comment-end ""
|
comment-end ""
|
||||||
comment-start-skip "# *"
|
comment-start-skip "# *"
|
||||||
comment-column 40
|
comment-column 40
|
||||||
indent-region-function 'py-indent-region
|
comment-indent-function 'py-comment-indent-function
|
||||||
indent-line-function 'py-indent-line
|
indent-region-function 'py-indent-region
|
||||||
|
indent-line-function 'py-indent-line
|
||||||
;; tell add-log.el how to find the current function/method/variable
|
;; tell add-log.el how to find the current function/method/variable
|
||||||
add-log-current-defun-function 'py-current-defun
|
add-log-current-defun-function 'py-current-defun
|
||||||
)
|
)
|
||||||
|
@ -1884,6 +1886,23 @@ it's tried again going backward."
|
||||||
py-indent-offset))
|
py-indent-offset))
|
||||||
))
|
))
|
||||||
|
|
||||||
|
(defun py-comment-indent-function ()
|
||||||
|
;; A better value for comment-indent-function in Python source, this
|
||||||
|
;; actually works when filladapt is turned off. Without this, in
|
||||||
|
;; that case, comments which start in column zero cascade one
|
||||||
|
;; character to the right
|
||||||
|
(save-excursion
|
||||||
|
(beginning-of-line)
|
||||||
|
(let ((eol (py-point 'eol)))
|
||||||
|
(and comment-start-skip
|
||||||
|
(re-search-forward comment-start-skip eol t)
|
||||||
|
(setq eol (match-beginning 0)))
|
||||||
|
(goto-char eol)
|
||||||
|
(skip-chars-backward " \t")
|
||||||
|
(max comment-column (+ (current-column) (if (bolp) 0 1)))
|
||||||
|
)))
|
||||||
|
|
||||||
|
|
||||||
(defun py-shift-region (start end count)
|
(defun py-shift-region (start end count)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char end) (beginning-of-line) (setq end (point))
|
(goto-char end) (beginning-of-line) (setq end (point))
|
||||||
|
|
Loading…
Reference in New Issue