emacs - If frame named "xyz" exists, then switch to that frame -
could please give me hand function detects whether frame named "xyz" exists, , if so, switch frame. i'm using frame-cmds
give each frame user-defined name: http://www.emacswiki.org/emacs/frame-cmds.el
i imagine similar buffer, i'm not finding on google. here buffer function:
(defun buffer-exists (bufname) (not (eq nil (get-buffer bufname)))) (defun lawlist-switch-to-buffer-xyz () (interactive) (if (buffer-exists "xyz") (switch-to-buffer "xyz") ))
here semi-related post: https://superuser.com/questions/358037/emacsclient-create-a-frame-if-a-frame-does-not-exist
edit (september 15, 2014): modified function ido-switch-frame
make frame-to
let-bound variable, , removed message
. removed previous edits functions get-a-frame
, get-frame-name
written drew adams sufficient when used in conjunction select-frame-set-input-focus
-- see answer below.
(defun ido-switch-frame () (interactive) (when (not (minibufferp)) (let* ( (frames (frame-list)) (frame-to (ido-completing-read "select frame: " (mapcar (lambda (frame) (frame-parameter frame 'name)) frames)))) (catch 'break (while frames (let ((frame (car frames))) (if (equal (frame-parameter frame 'name) frame-to) (throw 'break (select-frame-set-input-focus frame)) (setq frames (cdr frames)))))))))
there may more elegant solutions gets job done:
(defun switch-to-frame (frame-name) (interactive "sframe name:") (let ((frames (frame-list))) (catch 'break (while frames (let ((frame (car frames))) (if (equal (frame-parameter frame 'name) frame-name) (throw 'break (select-frame-set-input-focus frame)) (setq frames (cdr frames))))))))
Comments
Post a Comment