]> git.eshelyaron.com Git - emacs.git/commitdiff
(tabify-regexp): Use more specific regexps.
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 25 Jul 2006 18:06:13 +0000 (18:06 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Tue, 25 Jul 2006 18:06:13 +0000 (18:06 +0000)
(tabify): Avoid modifying the buffer unnecessarily.

lisp/ChangeLog
lisp/gnus/ChangeLog
lisp/tabify.el

index e06f191f4e041c74efa11f514ce3cef487c898a3..dd36a89d0a76d77545b2abdf56b806ae9be881a6 100644 (file)
@@ -1,3 +1,8 @@
+2006-07-25  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * tabify.el (tabify-regexp): Use more specific regexps.
+       (tabify): Avoid modifying the buffer unnecessarily.
+
 2006-07-25  Mathias Dahl  <mathias.dahl@gmail.com>
 
        * tumme.el (tumme-track-original-file): Add `buffer-live-p' check.
index cdedab0007d259dd05053aaa0541d5fb7bada215..beccd918c3e9e67ace6e8c829277a0aeaaa02818 100644 (file)
        (mm-display-part): Simplify.
        (mm-inlinable-p): Add optional arg `type'.
 
-       * gnus-art.el (gnus-mime-view-part-as-type): Add optional PRED
-       argument.
+       * gnus-art.el (gnus-mime-view-part-as-type): Add optional PRED arg.
        (gnus-mime-view-part-externally, gnus-mime-view-part-internally):
        Try harder to show the attachment internally or externally using
        gnus-mime-view-part-as-type.
        * gnus-art.el (gnus-mime-view-part-as-type-internal): Try to fetch
        `filename' from Content-Disposition if Content-Type doesn't
        provide `name'.
-       (gnus-mime-view-part-as-type): Set default instead of
-       initial-input.
+       (gnus-mime-view-part-as-type): Set default instead of initial-input.
 
 2006-04-28  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 
        * mml-sec.el (mml-secure-method): New internal variable.
        (mml-secure-sign, mml-secure-encrypt, mml-secure-message-sign)
-       (mml-secure-message-sign-encrypt, mml-secure-message-encrypt): New
-       functions using mml-secure-method.  Sync from the trunk.
+       (mml-secure-message-sign-encrypt, mml-secure-message-encrypt):
+       New functions using mml-secure-method.  Sync from the trunk.
 
        * mml.el (mml-mode-map): Add key bindings for those functions.
        (mml-menu): Simplify security menu entries.  Suggested by Jesper
 
 2006-04-20  Reiner Steib  <Reiner.Steib@gmx.de>
 
-       * gnus-util.el (gnus-replace-in-string): Prefer
-       replace-regexp-in-string over of replace-in-string.
+       * gnus-util.el (gnus-replace-in-string):
+       Prefer replace-regexp-in-string over of replace-in-string.
 
 2006-04-20  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 
        * gnus-sum.el: Ditto.
 
-       * gnus-util.el (gnus-select-frame-set-input-focus): Use
-       select-frame-set-input-focus if it is available in XEmacs; use
+       * gnus-util.el (gnus-select-frame-set-input-focus):
+       Use select-frame-set-input-focus if it is available in XEmacs; use
        definition defined in Emacs 22 for old Emacsen.
 
 2006-04-17  Reiner Steib  <Reiner.Steib@gmx.de>
        (mm-charset-to-coding-system): Use it.
        (mm-codepage-setup): New helper function.
        (mm-charset-eval-alist): New variable.
-       (mm-charset-to-coding-system): Use mm-charset-eval-alist.  Warn
-       about unknown charsets.  Add allow-override.  Use
-       `mm-charset-override-alist' only when decoding.
+       (mm-charset-to-coding-system): Use mm-charset-eval-alist.
+       Warn about unknown charsets.  Add allow-override.
+       Use `mm-charset-override-alist' only when decoding.
        (mm-detect-mime-charset-region): Use :mime-charset.
 
-       * mm-bodies.el (mm-decode-body, mm-decode-string): Call
-       `mm-charset-to-coding-system' with allow-override argument.
+       * mm-bodies.el (mm-decode-body, mm-decode-string):
+       Call `mm-charset-to-coding-system' with allow-override argument.
 
        * message.el (message-tool-bar-zap-list, message-tool-bar)
        (message-tool-bar-gnome, message-tool-bar-retro): New variables.
        `gmm-tool-bar-from-list'.
 
        * gnus-group.el (gnus-group-tool-bar, gnus-group-tool-bar-gnome)
-       (gnus-group-tool-bar-retro, gnus-group-tool-bar-zap-list): New
-       variables.
+       (gnus-group-tool-bar-retro, gnus-group-tool-bar-zap-list):
+       New variables.
        (gnus-group-make-tool-bar): Complete rewrite using
        `gmm-tool-bar-from-list'.
        (gnus-group-tool-bar-update): New function.
 
 2006-04-12  Reiner Steib  <Reiner.Steib@gmx.de>
 
-       * gnus-art.el (gnus-article-mode): Set
-       cursor-in-non-selected-windows to nil.
+       * gnus-art.el (gnus-article-mode):
+       Set cursor-in-non-selected-windows to nil.
 
 2006-04-12  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 
 2006-04-11  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
-       * nnslashdot.el (nnslashdot-retrieve-headers-1): Fix up to new
-       layout.
+       * nnslashdot.el (nnslashdot-retrieve-headers-1): Fix up to new layout.
 
        * rfc2047.el (rfc2047-decode-encoded-words): Don't message about
        unknown charset.
 
        * gnus-agent.el (gnus-agent-queue-mail): Fix custom tag for `t'.
 
-       * spam.el (spam-mark-new-messages-in-spam-group-as-spam): Add
-       comment on version.
+       * spam.el (spam-mark-new-messages-in-spam-group-as-spam):
+       Add comment on version.
 
 2006-03-20  Teodor Zlatanov  <tzz@lifelogs.com>
 
-       * spam.el (spam-mark-new-messages-in-spam-group-as-spam): New
-       variable.
+       * spam.el (spam-mark-new-messages-in-spam-group-as-spam): New variable.
        (spam-mark-junk-as-spam-routine): Use it.  Allow to disable
        assigning the spam-mark to new messages.
 
 
        * gnus-art.el (gnus-article-only-boring-p):
        Bind inhibit-point-motion-hooks to avoid infinite loop when entering
-       intangible text.  Reported by Ralf Wachinger
-       <rwnewsmampfer@geekmail.de>.
+       intangible text.
+       Reported by Ralf Wachinger <rwnewsmampfer@geekmail.de>.
 
 2006-03-14  Simon Josefsson  <jas@extundo.com>
 
        * message.el (message-unique-id): Don't use message-number-base36
-       if (user-uid) is a float.  Reported by Bjorn Solberg
-       <bjorn_ding1@hekneby.org>.
+       if (user-uid) is a float.
+       Reported by Bjorn Solberg <bjorn_ding1@hekneby.org>.
 
 2006-03-13  Katsumi Yamaoka  <yamaoka@jpl.org>
 
index 6e12270bf47c758b2cc5a62bb4596bf5eae8056c..de37f281eda051d7f3282055a408d46bca0f7d11 100644 (file)
@@ -50,10 +50,10 @@ The variable `tab-width' controls the spacing of tab stops."
          (delete-region tab-beg (point))
          (indent-to column))))))
 
-(defvar tabify-regexp "[ \t][ \t]+"
+(defvar tabify-regexp " [ \t]+"
   "Regexp matching whitespace that tabify should consider.
-Usually this will be \"[ \\t][ \\t]+\" to match two or more spaces or tabs.
-\"^[ \\t]+\" is also useful, for tabifying only initial whitespace.")
+Usually this will be \" [ \\t]+\" to match two or more spaces or tabs.
+\"^\\t* [ \\t]+\" is also useful, for tabifying only initial whitespace.")
 
 ;;;###autoload
 (defun tabify (start end)
@@ -72,13 +72,24 @@ The variable `tab-width' controls the spacing of tab stops."
       (beginning-of-line)
       (narrow-to-region (point) end)
       (goto-char start)
-      (while (re-search-forward tabify-regexp nil t)
-       (let ((column (current-column))
-             (indent-tabs-mode t))
-         (delete-region (match-beginning 0) (point))
-         (indent-to column))))))
+      (let ((indent-tabs-mode t))
+        (while (re-search-forward tabify-regexp nil t)
+          ;; The region between (match-beginning 0) and (match-end 0) is just
+          ;; spacing which we want to adjust to use TABs where possible.
+          (let ((end-col (current-column))
+                (beg-col (save-excursion (goto-char (match-beginning 0))
+                                         (skip-chars-forward "\t")
+                                         (current-column))))
+            (if (= (/ end-col tab-width) (/ beg-col tab-width))
+                ;; The spacing (after some leading TABs which we wouldn't
+                ;; want to touch anyway) does not straddle a TAB boundary,
+                ;; so it neither contains a TAB, nor will we be able to use
+                ;; a TAB here anyway: there's nothing to do.
+                nil
+              (delete-region (match-beginning 0) (point))
+              (indent-to end-col))))))))
 
 (provide 'tabify)
 
-;;; arch-tag: c83893b1-e0cc-4e57-8a09-73fd03466416
+;; arch-tag: c83893b1-e0cc-4e57-8a09-73fd03466416
 ;;; tabify.el ends here