Changeset 4131 for trunk/lisp/tabify.el
- Timestamp:
- 2006年07月29日 07時48分34秒 (2 years ago)
- Files:
-
- trunk/lisp/tabify.el (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lisp/tabify.el
r4037 r4131 51 51 (indent-to column)))))) 52 52 53 (defvar tabify-regexp " [ \t][ \t]+"53 (defvar tabify-regexp " [ \t]+" 54 54 "Regexp matching whitespace that tabify should consider. 55 Usually this will be \" [ \\t][ \\t]+\" to match two or more spaces or tabs.56 \"^ [ \\t]+\" is also useful, for tabifying only initial whitespace.")55 Usually this will be \" [ \\t]+\" to match two or more spaces or tabs. 56 \"^\\t* [ \\t]+\" is also useful, for tabifying only initial whitespace.") 57 57 58 58 ;;;###autoload … … 73 73 (narrow-to-region (point) end) 74 74 (goto-char start) 75 (while (re-search-forward tabify-regexp nil t) 76 (let ((column (current-column)) 77 (indent-tabs-mode t)) 78 (delete-region (match-beginning 0) (point)) 79 (indent-to column)))))) 75 (let ((indent-tabs-mode t)) 76 (while (re-search-forward tabify-regexp nil t) 77 ;; The region between (match-beginning 0) and (match-end 0) is just 78 ;; spacing which we want to adjust to use TABs where possible. 79 (let ((end-col (current-column)) 80 (beg-col (save-excursion (goto-char (match-beginning 0)) 81 (skip-chars-forward "\t") 82 (current-column)))) 83 (if (= (/ end-col tab-width) (/ beg-col tab-width)) 84 ;; The spacing (after some leading TABs which we wouldn't 85 ;; want to touch anyway) does not straddle a TAB boundary, 86 ;; so it neither contains a TAB, nor will we be able to use 87 ;; a TAB here anyway: there's nothing to do. 88 nil 89 (delete-region (match-beginning 0) (point)) 90 (indent-to end-col)))))))) 80 91 81 92 (provide 'tabify) 82 93 83 ;; ;arch-tag: c83893b1-e0cc-4e57-8a09-73fd0346641694 ;; arch-tag: c83893b1-e0cc-4e57-8a09-73fd03466416 84 95 ;;; tabify.el ends here
