"Like `ffap', but put buffer in another window.
Only intended for interactive use."
(interactive)
- (let (value)
- (switch-to-buffer-other-window
- (save-window-excursion
- (setq value (call-interactively 'ffap))
- (unless (or (bufferp value) (bufferp (car-safe value)))
- (setq value (current-buffer)))
- (current-buffer)))
- value))
+ (pcase (save-window-excursion (call-interactively 'ffap))
+ ((or (and (pred bufferp) b) `(,(and (pred bufferp) b) . ,_))
+ (switch-to-buffer-other-window b))))
(defun ffap-other-frame ()
"Like `ffap', but put buffer in another frame.
;;; Code:
+(require 'cl-lib)
(require 'ert)
(require 'ffap)
(let ((ffap-gopher-regexp nil))
(should-not (ffap-gopher-at-point)))))
+(ert-deftest ffap-other-window--bug-25352 ()
+ "Test for Bug#25352. Checks that the window configuration is
+left alone when opening a URL in an external browser."
+ (cl-letf* ((old (current-window-configuration))
+ ((symbol-function 'ffap-prompter)
+ (lambda () "http://www.gnu.org"))
+ (urls nil)
+ (ffap-url-fetcher (lambda (url) (push url urls) nil)))
+ (should-not (ffap-other-window))
+ (should (equal (current-window-configuration) old))
+ (should (equal urls '("http://www.gnu.org")))))
+
(provide 'ffap-tests)
;;; ffap-tests.el ends here