emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how about a find-library-other-window command?


From: Juri Linkov
Subject: Re: how about a find-library-other-window command?
Date: Fri, 22 Jun 2007 22:29:32 +0300
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

> + (defun find-library-other-window (library)
> +   "Find the elisp source of LIBRARY in another window."
> +   (interactive
> +    (list
> +     (completing-read "Library name: "
> +                  'locate-file-completion
> +                  (cons (or find-function-source-path load-path)
> +                        (find-library-suffixes)))))
> +   (let ((buf (find-file-noselect (find-library-name library))))
> +     (condition-case nil (switch-to-buffer-other-window buf)
> +       (error (pop-to-buffer buf)))))
> +
> + ;;;###autoload
> + (defun find-library-other-frame (library)
> +   "Find the elisp source of LIBRARY in another frame."
> +   (interactive
> +    (list
> +     (completing-read "Library name: "
> +                  'locate-file-completion
> +                  (cons (or find-function-source-path load-path)
> +                        (find-library-suffixes)))))
> +   (let ((buf (find-file-noselect (find-library-name library))))
> +     (condition-case nil (switch-to-buffer-other-frame buf)
> +       (error (pop-to-buffer buf)))))

This duplicates the same code in three places.  If we are going to keep
the practice of using three commands with different suffixes, then we can
at least simplify the definition of window/frame commands?  These commands
could just let-bind a variable indicating the scope of the commands, and
call-interactively the basic command allowing `switch-to-buffer' to decide
where to display the buffer.

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]