changeset 108043:d55e807557fc

Merge from mainline.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Tue, 06 Apr 2010 21:56:56 +0000
parents 31459e4835b5 (current diff) f56b90a69fac (diff)
children c2a207021794
files
diffstat 7 files changed, 176 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/etc/NEWS	Mon Apr 05 22:01:58 2010 +0000
+++ b/etc/NEWS	Tue Apr 06 21:56:56 2010 +0000
@@ -65,6 +65,13 @@
 ** GTK scroll-bars are now placed on the right by default.
 Use `set-scroll-bar-mode' to change this.
 
+** New scrolling commands `scroll-up-command' and `scroll-down-command'
+(bound to [next] and [prior]) does not signal errors at top/bottom
+of buffer at first key-press (instead moves to top/bottom of buffer).
+
+** New scrolling commands `scroll-up-line' and `scroll-down-line'
+scroll a line instead of full screen.
+
 
 * Editing Changes in Emacs 24.1
 
--- a/lisp/ChangeLog	Mon Apr 05 22:01:58 2010 +0000
+++ b/lisp/ChangeLog	Tue Apr 06 21:56:56 2010 +0000
@@ -1,3 +1,51 @@
+2010-04-06  John Wiegley  <jwiegley@gmail.com>
+
+	* ido.el (ido-add-virtual-buffers-to-list): Fix duplicated names
+	appearing in buffer list (if a live buffer name matched a recentf
+	file basename).  Should use uniquify to offer a real solution.
+
+2010-04-06  John Wiegley  <jwiegley@gmail.com>
+
+	* ido.el (ido-use-virtual-buffers, ido-virtual): Move a ChangeLog
+	comment to code, and add a :version tag.
+	(ido-virtual-buffers): Move defvar to fix byte-compiler warning.
+
+2010-04-06  Juanma Barranquero  <lekktu@gmail.com>
+
+	Enable recentf-mode if using virtual buffers.
+	* ido.el (recentf-list): Declare for byte-compiler.
+	(ido-virtual-buffers): Move up to silence byte-compiler.  Add docstring.
+	(ido-make-buffer-list): Simplify.
+	(ido-add-virtual-buffers-to-list): Simplify.  Enable recentf-mode.
+
+2010-04-05  Juri Linkov  <juri@jurta.org>
+
+	Scrolling commands which scroll a line instead of full screen.
+	http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg01452.html
+
+	* simple.el (scroll-up-line, scroll-down-line): New commands.
+	Put property isearch-scroll=t on them.
+
+	* emulation/ws-mode.el (scroll-down-line, scroll-up-line):
+	Remove commands.
+
+2010-04-05  Juri Linkov  <juri@jurta.org>
+
+	Scrolling commands which do not signal errors at top/bottom.
+	http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg01452.html
+
+	* simple.el (scroll-up-command, scroll-down-command): New commands.
+	Put property isearch-scroll=t on them.
+
+	* bindings.el (global-map): Rebind [prior] from `scroll-down' to
+	`scroll-down-command' and [next] from `scroll-up' to
+	`scroll-up-command'.
+
+	* emulation/cua-base.el: Put property CUA=move on
+	`scroll-up-command' and `scroll-down-command'.
+	(cua--init-keymaps): Remap `scroll-up-command' to `cua-scroll-up'
+	and `scroll-down-command' to `cua-scroll-down'.
+
 2010-04-05  Juanma Barranquero  <lekktu@gmail.com>
 
 	* help.el (describe-mode): Return nil.
@@ -5,18 +53,7 @@
 2010-04-04  John Wiegley  <jwiegley@gmail.com>
 
 	* ido.el (ido-use-virtual-buffers): New variable to indicate
-	whether "virtual buffer" support is enabled for IDO.  Essentially
-	it works as follows: Say you are visiting a file and the buffer
-	gets cleaned up by mignight.el.  Later, you want to switch to that
-	buffer, but find it's no longer open.  With virtual buffers
-	enabled, the buffer name stays in the buffer list (using the
-	ido-virtual face, and always at the end), and if you select it, it
-	opens the file back up again.  This allows you to think less about
-	whether recently opened files are still open or not.  Most of the
-	time you can quit Emacs, restart, and then switch to a file buffer
-	that was previously open as if it still were.  NOTE: This feature
-	has been present in iswitchb for several years now, and I'm
-	porting the same logic to IDO.
+	whether "virtual buffer" support is enabled for IDO.
 	(ido-virtual): Face used to indicate virtual buffers in the list.
 	(ido-buffer-internal): If a buffer is chosen, and no such buffer
 	exists, but a virtual buffer of that name does (which would be why
--- a/lisp/bindings.el	Mon Apr 05 22:01:58 2010 +0000
+++ b/lisp/bindings.el	Tue Apr 06 21:56:56 2010 +0000
@@ -873,8 +873,8 @@
 (define-key global-map [up]		'previous-line)
 (define-key global-map [right]		'forward-char)
 (define-key global-map [down]		'next-line)
-(define-key global-map [prior]		'scroll-down)
-(define-key global-map [next]		'scroll-up)
+(define-key global-map [prior]		'scroll-down-command)
+(define-key global-map [next]		'scroll-up-command)
 (define-key global-map [C-up]		'backward-paragraph)
 (define-key global-map [C-down]		'forward-paragraph)
 (define-key global-map [C-prior]	'scroll-right)
--- a/lisp/emulation/cua-base.el	Mon Apr 05 22:01:58 2010 +0000
+++ b/lisp/emulation/cua-base.el	Tue Apr 06 21:56:56 2010 +0000
@@ -1440,6 +1440,8 @@
   ;; scrolling
   (define-key cua-global-keymap [remap scroll-up]	'cua-scroll-up)
   (define-key cua-global-keymap [remap scroll-down]	'cua-scroll-down)
+  (define-key cua-global-keymap [remap scroll-up-command]   'cua-scroll-up)
+  (define-key cua-global-keymap [remap scroll-down-command] 'cua-scroll-down)
 
   (define-key cua--cua-keys-keymap [(control x) timeout] 'kill-region)
   (define-key cua--cua-keys-keymap [(control c) timeout] 'copy-region-as-kill)
@@ -1499,6 +1501,7 @@
    move-end-of-line move-beginning-of-line
    end-of-buffer beginning-of-buffer
    scroll-up scroll-down
+   scroll-up-command scroll-down-command
    up-list down-list backward-up-list
    end-of-defun beginning-of-defun
    forward-sexp backward-sexp
--- a/lisp/emulation/ws-mode.el	Mon Apr 05 22:01:58 2010 +0000
+++ b/lisp/emulation/ws-mode.el	Tue Apr 06 21:56:56 2010 +0000
@@ -339,16 +339,6 @@
        (+ left-margin
 	  (/ (- fill-column left-margin line-length) 2))))))
 
-(defun scroll-down-line ()
-  "Scroll one line down."
-  (interactive)
-  (scroll-down 1))
-
-(defun scroll-up-line ()
-  "Scroll one line up."
-  (interactive)
-  (scroll-up 1))
-
 ;;;;;;;;;;;
 ;; wordstar special variables:
 
--- a/lisp/ido.el	Mon Apr 05 22:01:58 2010 +0000
+++ b/lisp/ido.el	Tue Apr 06 21:56:56 2010 +0000
@@ -323,6 +323,7 @@
 ;;; Code:
 
 (defvar cua-inhibit-cua-keys)
+(defvar recentf-list)
 
 ;;; User Variables
 ;;
@@ -776,8 +777,19 @@
 
 (defcustom ido-use-virtual-buffers nil
   "If non-nil, refer to past buffers as well as existing ones.
-This feature relies upon the `recentf' package, which will be
+Essentially it works as follows: Say you are visiting a file and
+the buffer gets cleaned up by mignight.el.  Later, you want to
+switch to that buffer, but find it's no longer open.  With
+virtual buffers enabled, the buffer name stays in the buffer
+list (using the ido-virtual face, and always at the end), and if
+you select it, it opens the file back up again.  This allows you
+to think less about whether recently opened files are still open
+or not.  Most of the time you can quit Emacs, restart, and then
+switch to a file buffer that was previously open as if it still
+were.
+    This feature relies upon the `recentf' package, which will be
 enabled if this variable is configured to a non-nil value."
+  :version "24.1"
   :type 'boolean
   :group 'ido)
 
@@ -807,6 +819,7 @@
 
 (defface ido-virtual '((t (:inherit font-lock-builtin-face)))
   "Face used by ido for matching virtual buffer names."
+  :version "24.1"
   :group 'ido)
 
 (defface ido-indicator  '((((min-colors 88) (class color))
@@ -1041,6 +1054,11 @@
   "Non-nil means to explicitly cursor on entry to minibuffer.
 Value is an integer which is number of chars to right of prompt.")
 
+(defvar ido-virtual-buffers nil
+  "List of virtual buffers, that is, past visited files.
+This is a copy of `recentf-list', pared down and with faces applied.
+Only used if `ido-use-virtual-buffers' is non-nil.")
+
 ;;; Variables with dynamic bindings.
 ;;; Declared here to keep the byte compiler quiet.
 
@@ -3366,37 +3384,31 @@
     (if ido-temp-list
 	(nconc ido-temp-list ido-current-buffers)
       (setq ido-temp-list ido-current-buffers))
-    (if (and default (buffer-live-p (get-buffer default)))
-	(progn
-	  (setq ido-temp-list
-		(delete default ido-temp-list))
-	  (setq ido-temp-list
-		(cons default ido-temp-list))))
+    (when (and default (buffer-live-p (get-buffer default)))
+      (setq ido-temp-list
+	    (cons default (delete default ido-temp-list))))
     (if ido-use-virtual-buffers
 	(ido-add-virtual-buffers-to-list))
     (run-hooks 'ido-make-buffer-list-hook)
     ido-temp-list))
 
-(defvar ido-virtual-buffers nil)
-
 (defun ido-add-virtual-buffers-to-list ()
   "Add recently visited files, and bookmark files, to the buffer list.
 This is to make them appear as if they were \"virtual buffers\"."
   ;; If no buffers matched, and virtual buffers are being used, then
   ;; consult the list of past visited files, to see if we can find
   ;; the file which the user might thought was still open.
+  (unless recentf-mode (recentf-mode 1))
   (setq ido-virtual-buffers nil)
-  (let ((head recentf-list) name)
-    (while head
-      (if (and (setq name (file-name-nondirectory (car head)))
-	       (null (get-file-buffer (car head)))
-	       (not (assoc name ido-virtual-buffers))
-	       (not (ido-ignore-item-p name ido-ignore-buffers))
-	       ;;(file-exists-p (car head))
-	       )
-	  (setq ido-virtual-buffers
-		(cons (cons name (car head)) ido-virtual-buffers)))
-      (setq head (cdr head))))
+  (let (name)
+    (dolist (head recentf-list)
+      (and (setq name (file-name-nondirectory head))
+           (null (get-file-buffer head))
+           (not (assoc name ido-virtual-buffers))
+           (not (member name ido-temp-list))
+           (not (ido-ignore-item-p name ido-ignore-buffers))
+           ;;(file-exists-p head)
+           (push (cons name head) ido-virtual-buffers))))
   (when ido-virtual-buffers
     (if ido-use-faces
 	(dolist (comp ido-virtual-buffers)
--- a/lisp/simple.el	Mon Apr 05 22:01:58 2010 +0000
+++ b/lisp/simple.el	Tue Apr 06 21:56:56 2010 +0000
@@ -4738,6 +4738,89 @@
   visual-line-mode turn-on-visual-line-mode
   :lighter " vl")
 
+;;; Scrolling commands.
+
+;;; Scrolling commands which does not signal errors at top/bottom
+;;; of buffer at first key-press (instead moves to top/bottom
+;;; of buffer).
+
+(defun scroll-up-command (&optional arg)
+  "Scroll text of selected window upward ARG lines; or near full screen if no ARG.
+If `scroll-up' cannot scroll window further, move cursor to the bottom line.
+When point is already on that position, then signal an error.
+A near full screen is `next-screen-context-lines' less than a full screen.
+Negative ARG means scroll downward.
+If ARG is the atom `-', scroll downward by nearly full screen."
+  (interactive "^P")
+  (cond
+   ((eq arg '-) (scroll-down-command nil))
+   ((< (prefix-numeric-value arg) 0)
+    (scroll-down-command (- (prefix-numeric-value arg))))
+   ((eobp)
+    (scroll-up arg))  ; signal error
+   (t
+    (condition-case nil
+	(scroll-up arg)
+      (end-of-buffer
+       (if arg
+	   ;; When scrolling by ARG lines can't be done,
+	   ;; move by ARG lines instead.
+	   (forward-line arg)
+	 ;; When ARG is nil for full-screen scrolling,
+	 ;; move to the bottom of the buffer.
+	 (goto-char (point-max))))))))
+
+(put 'scroll-up-command 'isearch-scroll t)
+
+(defun scroll-down-command (&optional arg)
+  "Scroll text of selected window down ARG lines; or near full screen if no ARG.
+If `scroll-down' cannot scroll window further, move cursor to the top line.
+When point is already on that position, then signal an error.
+A near full screen is `next-screen-context-lines' less than a full screen.
+Negative ARG means scroll upward.
+If ARG is the atom `-', scroll upward by nearly full screen."
+  (interactive "^P")
+  (cond
+   ((eq arg '-) (scroll-up-command nil))
+   ((< (prefix-numeric-value arg) 0)
+    (scroll-up-command (- (prefix-numeric-value arg))))
+   ((bobp)
+    (scroll-down arg))  ; signal error
+   (t
+    (condition-case nil
+	(scroll-down arg)
+      (beginning-of-buffer
+       (if arg
+	   ;; When scrolling by ARG lines can't be done,
+	   ;; move by ARG lines instead.
+	   (forward-line (- arg))
+	 ;; When ARG is nil for full-screen scrolling,
+	 ;; move to the top of the buffer.
+	 (goto-char (point-min))))))))
+
+(put 'scroll-down-command 'isearch-scroll t)
+
+;;; Scrolling commands which scroll a line instead of full screen.
+
+(defun scroll-up-line (&optional arg)
+  "Scroll text of selected window upward ARG lines; or one line if no ARG.
+If ARG is omitted or nil, scroll upward by one line.
+This is different from `scroll-up-command' that scrolls a full screen."
+  (interactive "p")
+  (scroll-up (or arg 1)))
+
+(put 'scroll-up-line 'isearch-scroll t)
+
+(defun scroll-down-line (&optional arg)
+  "Scroll text of selected window down ARG lines; or one line if no ARG.
+If ARG is omitted or nil, scroll down by one line.
+This is different from `scroll-down-command' that scrolls a full screen."
+  (interactive "p")
+  (scroll-down (or arg 1)))
+
+(put 'scroll-down-line 'isearch-scroll t)
+
+
 (defun scroll-other-window-down (lines)
   "Scroll the \"other window\" down.
 For more details, see the documentation for `scroll-other-window'."