Show
Ignore:
Timestamp:
2006年07月29日 07時48分34秒 (2 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lisp/tabify.el

    r4037 r4131  
    5151          (indent-to column)))))) 
    5252 
    53 (defvar tabify-regexp "[ \t][ \t]+" 
     53(defvar tabify-regexp " [ \t]+" 
    5454  "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.") 
     55Usually this will be \" [ \\t]+\" to match two or more spaces or tabs. 
     56\"^\\t* [ \\t]+\" is also useful, for tabifying only initial whitespace.") 
    5757 
    5858;;;###autoload 
     
    7373      (narrow-to-region (point) end) 
    7474      (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)))))))) 
    8091 
    8192(provide 'tabify) 
    8293 
    83 ;;; arch-tag: c83893b1-e0cc-4e57-8a09-73fd03466416 
     94;; arch-tag: c83893b1-e0cc-4e57-8a09-73fd03466416 
    8495;;; tabify.el ends here