\f
* Incompatible Lisp Changes in Emacs 25.1
+** read-buffer-function can now be called with a 4th argument (`predicate').
+
** completion-table-dynamic stays in the minibuffer.
If you want the old behavior of calling the function in the buffer
from which the minibuffer was entered, call it with the new argument
\f
* Lisp Changes in Emacs 25.1
+** `read-buffer' takes a new `predicate' argument.
+
** Emacs Lisp now supports generators.
** New finalizer facility for running code when objects
+2015-03-16 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * obsolete/iswitchb.el (iswitchb-read-buffer): Add `predicate' arg.
+ * isearchb.el (isearchb-iswitchb): Adjust accordingly.
+ * ido.el (ido-read-buffer): Add `predicate' argument.
+ * misearch.el (unload-function-defs-list): Declare before use.
+
2015-03-16 Vibhav Pant <vibhavp@gmail.com>
* net/browse-url.el (browse-url-browser-function): Add "Conkeror".
:type 'boolean
:group 'viper)
-(defcustom viper-read-buffer-function 'read-buffer
+(defcustom viper-read-buffer-function #'read-buffer
"Function to use for prompting the user for a buffer name."
:type 'symbol
:group 'viper)
+2015-03-16 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * erc.el (erc-switch-to-buffer): Rename from erc-iswitchb and rewrite
+ using read-buffer (bug#20116).
+ (erc--buffer-p): New function, extracted from erc-buffer-filter.
+ (erc-buffer-filter): Use it.
+ (erc-with-all-buffers-of-server): Silence compile warning if the return
+ value is unused.
+ (erc-is-valid-nick-p, erc-common-server-suffixes, erc-get-arglist)
+ (erc-command-name, erc-popup-input-buffer): Use \` and \' to match
+ beg/end of string.
+
2015-03-03 Kelvin White <kwhite@gnu.org>
* erc.el: Add old version string back to file header for
(define-key map "\C-a" 'erc-bol)
(define-key map [home] 'erc-bol)
(define-key map "\C-c\C-a" 'erc-bol)
- (define-key map "\C-c\C-b" 'erc-iswitchb)
+ (define-key map "\C-c\C-b" 'erc-switch-to-buffer)
(define-key map "\C-c\C-c" 'erc-toggle-interpret-controls)
(define-key map "\C-c\C-d" 'erc-input-action)
(define-key map "\C-c\C-e" 'erc-toggle-ctcp-autoresponse)
(throw 'buffer (current-buffer)))))
proc))))
+(defun erc--buffer-p (buf predicate proc)
+ (with-current-buffer buf
+ (and (derived-mode-p 'erc-mode)
+ (or (not proc)
+ (eq proc erc-server-process))
+ (funcall predicate)
+ buf)))
+
(defun erc-buffer-filter (predicate &optional proc)
"Return a list of `erc-mode' buffers matching certain criteria.
PREDICATE is a function executed with each buffer, if it returns t, that buffer
nil
(mapcar (lambda (buf)
(when (buffer-live-p buf)
- (with-current-buffer buf
- (and (eq major-mode 'erc-mode)
- (or (not proc)
- (eq proc erc-server-process))
- (funcall predicate)
- buf))))
+ (erc--buffer-p buf predicate proc)))
(buffer-list)))))
(defun erc-buffer-list (&optional predicate proc)
,pro))))
;; Silence the byte-compiler by binding the result of mapcar to
;; a variable.
+ (ignore res)
res)))
-;; (iswitchb-mode) will autoload iswitchb.el
-(defvar iswitchb-temp-buflist)
-(declare-function iswitchb-read-buffer "iswitchb"
- (prompt &optional default require-match start matches-set))
-(defvar iswitchb-make-buflist-hook)
-
-(defun erc-iswitchb (&optional arg)
- "Use `iswitchb-read-buffer' to prompt for a ERC buffer to switch to.
+(define-obsolete-function-alias 'erc-iswitchb 'erc-switch-to-buffer "25.1")
+(defun erc-switch-to-buffer (&optional arg)
+ "Prompt for a ERC buffer to switch to.
When invoked with prefix argument, use all erc buffers. Without prefix
ARG, allow only buffers related to same session server.
If `erc-track-mode' is in enabled, put the last element of
-`erc-modified-channels-alist' in front of the buffer list.
-
-Due to some yet unresolved reason, global function `iswitchb-mode'
-needs to be active for this function to work."
+`erc-modified-channels-alist' in front of the buffer list."
(interactive "P")
- (let ((enabled (bound-and-true-p iswitchb-mode)))
- (or enabled (iswitchb-mode 1))
- (unwind-protect
- (let ((iswitchb-make-buflist-hook
- (lambda ()
- (setq iswitchb-temp-buflist
- (mapcar 'buffer-name
- (erc-buffer-list
- nil
- (when arg erc-server-process)))))))
- (switch-to-buffer
- (iswitchb-read-buffer
- "Switch-to: "
- (if (boundp 'erc-modified-channels-alist)
- (buffer-name (caar (last erc-modified-channels-alist)))
- nil)
- t)))
- (or enabled (iswitchb-mode -1)))))
+ (switch-to-buffer
+ (read-buffer "Switch to ERC buffer: "
+ (when (boundp 'erc-modified-channels-alist)
+ (buffer-name (caar (last erc-modified-channels-alist))))
+ t
+ ;; Only allow ERC buffers in the same session.
+ (let ((proc (unless arg erc-server-process)))
+ (lambda (bufname)
+ (let ((buf (get-buffer bufname)))
+ (when buf
+ (erc--buffer-p buf (lambda () t) proc)
+ (with-current-buffer buf
+ (and (derived-mode-p 'erc-mode)
+ (or (null proc)
+ (eq proc erc-server-process)))))))))))
(defun erc-channel-list (proc)
"Return a list of channel buffers.
Arguments are the same as for `erc'."
(interactive (erc-select-read-args))
(let ((erc-server-connect-function 'erc-open-tls-stream))
- (apply 'erc r)))
+ (apply #'erc r)))
(defun erc-open-tls-stream (name buffer host port)
"Open an TLS stream to an IRC server.
(defun erc-is-valid-nick-p (nick)
"Check if NICK is a valid IRC nickname."
- (string-match (concat "^" erc-valid-nick-regexp "$") nick))
+ (string-match (concat "\\`" erc-valid-nick-regexp "\\'") nick))
(defun erc-display-line (string &optional buffer)
"Display STRING in the ERC BUFFER.
erc-lurker-threshold-time))))
(defcustom erc-common-server-suffixes
- '(("openprojects.net$" . "OPN")
- ("freenode.net$" . "freenode")
- ("oftc.net$" . "OFTC"))
+ '(("openprojects.net\\'" . "OPN")
+ ("freenode.net\\'" . "freenode")
+ ("oftc.net\\'" . "OFTC"))
"Alist of common server name suffixes.
This variable is used in mode-line display to save screen
real estate. Set it to nil if you want to avoid changing
See also `erc-format-message' and `erc-display-line'."
(let ((string (if (symbolp msg)
- (apply 'erc-format-message msg args)
+ (apply #'erc-format-message msg args)
msg)))
(setq string
(cond
(defun erc-get-arglist (fun)
"Return the argument list of a function without the parens."
(let ((arglist (format "%S" (erc-function-arglist fun))))
- (if (string-match "^(\\(.*\\))$" arglist)
+ (if (string-match "\\`(\\(.*\\))\\'" arglist)
(match-string 1 arglist)
arglist)))
"For CMD being the function name of a ERC command, something like
erc-cmd-FOO, this returns a string /FOO."
(let ((command-name (symbol-name cmd)))
- (if (string-match "^erc-cmd-\\(.*\\)$" command-name)
+ (if (string-match "\\`erc-cmd-\\(.*\\)\\'" command-name)
(concat "/" (match-string 1 command-name))
command-name)))
(erc-display-line
(concat "Available user variables:\n"
(apply
- 'concat
+ #'concat
(mapcar
(lambda (var)
(let ((val (symbol-value var)))
t)))
(erc-server-send (format "MODE %s b" chnl)))))
- (t (let ((bans (mapcar 'cdr erc-channel-banlist)))
+ (t (let ((bans (mapcar #'cdr erc-channel-banlist)))
(when bans
;; Glob the bans into groups of three, and carry out the unban.
;; eg. /mode #foo -bbb a*!*@* b*!*@* c*!*@*
(concat "Set topic of " (erc-default-target) ": ")
(when erc-channel-topic
(let ((ss (split-string erc-channel-topic "\C-o")))
- (cons (apply 'concat (if (cdr ss) (butlast ss) ss))
+ (cons (apply #'concat (if (cdr ss) (butlast ss) ss))
0))))))
(let ((topic-list (split-string topic "\C-o"))) ; strip off the topic setter
(erc-cmd-TOPIC (concat (erc-default-target) " " (car topic-list)))))
(MODE-CHAR ON/OFF ARGUMENT)."
(if (string-match "^\\s-*\\(\\S-+\\)\\(\\s-.*$\\|$\\)" mode-string)
- (let ((chars (mapcar 'char-to-string (match-string 1 mode-string)))
+ (let ((chars (mapcar #'char-to-string (match-string 1 mode-string)))
;; arguments in channel modes
(args-str (match-string 2 mode-string))
(args nil)
(if (> minutes 0)
`("%d minutes, %d seconds" ,minutes ,seconds)
`("%d seconds" ,seconds))))
- output (apply 'format format-args))
+ output (apply #'format format-args))
;; Change all "1 units" to "1 unit".
(while (string-match "\\([^0-9]\\|^\\)1 \\S-+\\(s\\)" output)
(setq output (erc-replace-match-subexpression-in-string
(defun erc-format-channel-modes ()
"Return the current channel's modes."
- (concat (apply 'concat
+ (concat (apply #'concat
"+" erc-channel-modes)
(cond ((and erc-channel-user-limit erc-channel-key)
(if erc-show-channel-key-p
"Mode: "
(mapcar (lambda (e)
(list (symbol-name e)))
- (apropos-internal "-mode$" 'commandp))
+ (apropos-internal "-mode\\'" 'commandp))
nil t))))
(pop-to-buffer (make-indirect-buffer (current-buffer) buffer-name))
(funcall mode)
(error "No format spec for message %s" msg))
(when (functionp entry)
(setq entry (apply entry args)))
- (format-spec entry (apply 'format-spec-make args))))
+ (format-spec entry (apply #'format-spec-make args))))
;;; Various hook functions
(when ido-everywhere
(when (memq ido-mode '(both file))
(put 'ido-everywhere 'file (cons read-file-name-function nil))
- (setq read-file-name-function 'ido-read-file-name))
+ (setq read-file-name-function #'ido-read-file-name))
(when (memq ido-mode '(both buffer))
(put 'ido-everywhere 'buffer (cons read-buffer-function nil))
- (setq read-buffer-function 'ido-read-buffer))))
+ (setq read-buffer-function #'ido-read-buffer))))
(defvar ido-minor-mode-map-entry nil)
(put 'dired-do-rename 'ido 'ignore)
;;;###autoload
-(defun ido-read-buffer (prompt &optional default require-match)
+(defun ido-read-buffer (prompt &optional default require-match predicate)
"Ido replacement for the built-in `read-buffer'.
Return the name of a buffer selected.
PROMPT is the prompt to give to the user. DEFAULT if given is the default
(if (eq ido-exit 'fallback)
(let ((read-buffer-function nil))
(run-hook-with-args 'ido-before-fallback-functions 'read-buffer)
- (read-buffer prompt default require-match))
+ (read-buffer prompt default require-match predicate))
buf)))
;;;###autoload
;; killing iswitchb.el and then trying to switch back is broken
;; make sure TAB isn't broken
-(require 'iswitchb)
+;;; Code:
+
+(require 'iswitchb) ;FIXME: Don't rely on iswitchb!
(defgroup isearchb nil
"Switch between buffers using a mechanism like isearch."
(interactive)
(let* ((prompt "iswitch ")
(iswitchb-method 'samewindow)
- (buf (iswitchb-read-buffer prompt nil nil iswitchb-text t)))
+ (buf (iswitchb-read-buffer prompt nil nil nil iswitchb-text t)))
(if (eq iswitchb-exit 'findfile)
(call-interactively 'find-file)
(when buf
(ido-ignore-item-temp-list bufs))
(while (not (string-equal
(setq buf (read-buffer
- (if (eq read-buffer-function 'ido-read-buffer)
+ (if (eq read-buffer-function #'ido-read-buffer)
"Next buffer to search (C-j to end): "
"Next buffer to search (RET to end): ")
nil t))
(goto-char (if isearch-forward (point-min) (point-max)))
(isearch-forward-regexp nil t)))
+(defvar unload-function-defs-list)
+
(defun multi-isearch-unload-function ()
"Remove autoloaded variables from `unload-function-defs-list'.
Also prevent the feature from being reloaded via `isearch-mode-hook'."
;; iswitchb-read-buffer has been written to be a drop in replacement
;; for the normal buffer selection routine `read-buffer'. To use
;; iswitch for all buffer selections in Emacs, add:
-;; (setq read-buffer-function 'iswitchb-read-buffer)
+;; (setq read-buffer-function #'iswitchb-read-buffer)
;; (This variable was introduced in Emacs 20.3.)
;; XEmacs users can get the same behavior by doing:
-;; (defalias 'read-buffer 'iswitchb-read-buffer)
+;; (defalias 'read-buffer #'iswitchb-read-buffer)
;; since `read-buffer' is defined in lisp.
;; Using iswitchb for other completion tasks.
))))
(defun iswitchb-read-buffer (prompt &optional default require-match
- start matches-set)
+ _predicate start matches-set)
"Replacement for the built-in `read-buffer'.
Return the name of a buffer selected.
PROMPT is the prompt to give to the user.
(ido-ignore-item-temp-list bufs))
(while (not (string-equal
(setq buf (read-buffer
- (if (eq read-buffer-function 'ido-read-buffer)
+ (if (eq read-buffer-function #'ido-read-buffer)
"Next buffer to search (C-j to end): "
"Next buffer to search (RET to end): ")
nil t))
+2015-03-16 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * minibuf.c (Fread_buffer): Add `predicate' argument.
+ * callint.c (Fcall_interactively): Adjust calls accordingly.
+
2015-03-15 Eli Zaretskii <eliz@gnu.org>
* xdisp.c (handle_invisible_prop): Fix up it->position even when
args[i] = Fcurrent_buffer ();
if (EQ (selected_window, minibuf_window))
args[i] = Fother_buffer (args[i], Qnil, Qnil);
- args[i] = Fread_buffer (callint_message, args[i], Qt);
+ args[i] = Fread_buffer (callint_message, args[i], Qt, Qnil);
break;
case 'B': /* Name of buffer, possibly nonexistent. */
args[i] = Fread_buffer (callint_message,
Fother_buffer (Fcurrent_buffer (), Qnil, Qnil),
- Qnil);
+ Qnil, Qnil);
break;
case 'c': /* Character. */
return Fintern (name, Qnil);
}
-DEFUN ("read-buffer", Fread_buffer, Sread_buffer, 1, 3, 0,
+DEFUN ("read-buffer", Fread_buffer, Sread_buffer, 1, 4, 0,
doc: /* Read the name of a buffer and return as a string.
Prompt with PROMPT.
Optional second arg DEF is value to return if user enters an empty line.
If `read-buffer-completion-ignore-case' is non-nil, completion ignores
case while reading the buffer name.
If `read-buffer-function' is non-nil, this works by calling it as a
-function, instead of the usual behavior. */)
- (Lisp_Object prompt, Lisp_Object def, Lisp_Object require_match)
+function, instead of the usual behavior.
+Optional arg PREDICATE if non-nil is a function limiting the buffers that can
+be considered. */)
+ (Lisp_Object prompt, Lisp_Object def, Lisp_Object require_match,
+ Lisp_Object predicate)
{
Lisp_Object result;
char *s;
}
result = Fcompleting_read (prompt, intern ("internal-complete-buffer"),
- Qnil, require_match, Qnil,
+ predicate, require_match, Qnil,
Qbuffer_name_history, def, Qnil);
}
else
- result = call3 (Vread_buffer_function, prompt, def, require_match);
+ result = (NILP (predicate)
+ /* Partial backward compatibility for older read_buffer_functions
+ which don't expect a `predicate' argument. */
+ ? call3 (Vread_buffer_function, prompt, def, require_match)
+ : call4 (Vread_buffer_function, prompt, def, require_match,
+ predicate));
return unbind_to (count, result);
}
\f