help-gnu-emacs
[Top][All Lists]
Advanced

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

RE: [External] : Re: Proposal: "C-z <letter>" reserved for users


From: Drew Adams
Subject: RE: [External] : Re: Proposal: "C-z <letter>" reserved for users
Date: Thu, 11 Feb 2021 16:58:52 +0000

> (defun move-frame-right ()
>   "Move the current frame right 200 pixels"
>   (interactive)
>   (let* ((p (frame-position))
>        (x (car p))
>        (y (cdr p)))
>     (set-frame-position (selected-frame) (+ x 200) y)))

FWIW, `frame-cmds.el' uses this:

(defun move-frame-right (&optional n frame)
  "Move frame to the right.
Move it N times `frame-char-width', where N is the prefix arg.
In Lisp code, FRAME is the frame to move."
  (interactive "p")
  (unless n (setq n  1))
  (setq n  (* n (frame-char-width frame)))
  (modify-frame-parameters frame
                           (list
                             (list 'left
                                   '+
                                   (frcmds-new-frame-position
                                     frame 'left n)))))

`frcmds-new-frame-position' increments frame
position, handling the various position formats.
___

https://www.emacswiki.org/emacs/download/frame-cmds.el
___

> (defun kill-buffer-and-frame ()
>   "Kill the current buffer and the current frame."
>   (interactive)
>   ;; do this trick in case of dedicated window in special frame
>   ;; in that case kill-buffer will delete-frame too can't check
>   ;; after kill buffer since selected-frame will have changed
>   (if (window-dedicated-p (selected-window))
>       (kill-buffer (current-buffer))
>     (kill-buffer (current-buffer))
>     (delete-frame)))

FWIW, this is a bit similar (from `misc-cmds.el'):

;; Candidate as a replacement for `kill-buffer', at least
;; when used interactively.
;;
;; E.g.: (define-key global-map [remap kill-buffer]
;;                   'kill-buffer-and-its-windows)
;;
;; Can't just redefine `kill-buffer', because some programs
;; count on a specific other buffer taking the place of the
;; killed buffer (in the window).
;;
(defun kill-buffer-and-its-windows (buffer)
  "Kill BUFFER and delete its windows.  Default is `current-buffer'.
BUFFER may be either a buffer or its name (a string)."
  (interactive (list (read-buffer "Kill buffer: " (current-buffer)
                                  'existing)))
  (setq buffer  (get-buffer buffer))
  (if (buffer-live-p buffer)
      (let ((wins  (get-buffer-window-list
            buffer nil t))) ; On all frames.
        (when (kill-buffer buffer) ; Delete wins only if buf killed.
          (dolist (win  wins) ; User might keep buffer if modified.
            (when (window-live-p win)
              ;; Ignore error, in particular, "Attempt to delete
              ;; the sole visible or iconified frame".
              (ignore-errors (delete-window win))))))
    (when (interactive-p)
      (error "Can't kill - not a live buffer: `%s'" buffer))))
___

https://www.emacswiki.org/emacs/download/misc-cmds.el

reply via email to

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