Use forward-line rather than goto-line.
[bpt/emacs.git] / lisp / ibuffer.el
index 539f88e..4339a29 100644 (file)
@@ -1,7 +1,7 @@
 ;;; ibuffer.el --- operate on buffers like dired
 
-;; Copyright (C) 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+;;   200 Free Software Foundation, Inc.
 
 ;; Author: Colin Walters <walters@verbum.org>
 ;; Maintainer: John Paul Wallington <jpw@gnu.org>
 (defvar ibuffer-tmp-hide-regexps)
 (defvar ibuffer-tmp-show-regexps)
 
-(declare-function ibuffer-mark-on-buffer "ibuf-ext" 
+(declare-function ibuffer-mark-on-buffer "ibuf-ext"
                  (func &optional ibuffer-mark-on-buffer-mark group))
 (declare-function ibuffer-format-qualifier "ibuf-ext" (qualifier))
-(declare-function ibuffer-generate-filter-groups "ibuf-ext" 
+(declare-function ibuffer-generate-filter-groups "ibuf-ext"
                  (bmarklist &optional noempty nodefault))
 (declare-function ibuffer-format-filter-group-data "ibuf-ext" (filter))
 
@@ -1093,7 +1093,8 @@ one window."
        (line (+ 1 (count-lines 1 (point)))))
     (bury-buffer buf)
     (ibuffer-update nil t)
-    (goto-line line)))
+    (goto-char (point-min))
+    (forward-line (1- line))))
 
 (defun ibuffer-visit-tags-table ()
   "Visit the tags table in the buffer on this line.  See `visit-tags-table'."
@@ -1153,6 +1154,9 @@ a new window in the current frame, splitting vertically."
     (ibuffer-redisplay t)))
 
 (defun ibuffer-shrink-to-fit (&optional owin)
+  ;; Make sure that redisplay is performed, otherwise there can be a
+  ;; bad interaction with code in the window-scroll-functions hook
+  (redisplay t)
   (fit-window-to-buffer nil (when owin (/ (frame-height)
                                          (length (window-list (selected-frame)))))))
 
@@ -1236,7 +1240,7 @@ a new window in the current frame, splitting vertically."
   (ibuffer-map-on-mark ibuffer-deletion-char func))
 
 (defsubst ibuffer-assert-ibuffer-mode ()
-  (assert (derived-mode-p 'ibuffer-mode))) 
+  (assert (derived-mode-p 'ibuffer-mode)))
 
 (defun ibuffer-buffer-file-name ()
   (or buffer-file-name
@@ -2063,7 +2067,7 @@ the value of point at the beginning of the line for that buffer."
                                  name)))
                  (when hmap
                    (setq
-                    strname 
+                    strname
                     (propertize strname 'mouse-face 'highlight 'keymap hmap)))
                  strname)))))
         (add-text-properties opos (point) `(ibuffer-title-header t))
@@ -2188,6 +2192,9 @@ If optional arg SILENT is non-nil, do not display progress messages."
              ibuffer-header-line-format)))
 
 (defun ibuffer-sort-bufferlist (bmarklist)
+  (unless ibuffer-sorting-functions-alist
+    ;; make sure the sorting functions are loaded
+    (require 'ibuf-ext))
   (let* ((sortdat (assq ibuffer-sorting-mode
                        ibuffer-sorting-functions-alist))
         (func (caddr sortdat)))
@@ -2274,7 +2281,8 @@ If optional arg SILENT is non-nil, do not display progress messages."
       (setq buffer-read-only t)
       (set-buffer-modified-p ibuffer-did-modification)
       (setq ibuffer-did-modification nil)
-      (goto-line (1+ orig)))))
+      (goto-char (point-min))
+      (forward-line orig))))
 
 (defun ibuffer-quit ()
   "Quit this `ibuffer' session.