[Top][All Lists]

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

Re: [RP] sketch: ratpoison-dired.el

From: Shawn Betts
Subject: Re: [RP] sketch: ratpoison-dired.el
Date: Fri, 4 May 2007 13:30:23 -0700

Hey Joe,

This is quite neat. If you get this solid, post it to the rp wiki or the emacs wiki :).


On 3/21/07, Joe Corneli < address@hidden> wrote:
Hi, this isn't done, but I thought I'd "release early" and get your

The point is to be able to manipulate ratpoison windows from Emacs as
if they were in dired.

Various quick and dirty moves are employed in this sketch.  It seems
to me this could be more elegant, particularly switching to all of the
windows that need to be deleted in `ratpoison-dired-delete-marked'
(I'd especially like a version of RP's `delete' that takes one
argument, the window to be deleted).


(define-minor-mode ratpoison-dired-mode "delete ratpoison windows" nil " RPD"
  :keymap '(("d" . ratpoison-dired-mark)
            ("d" . ratpoison-dired-unmark)
            ("x" . ratpoison-dired-delete-marked)))

(defun ratpoison-dired ()
  (switch-to-buffer (get-buffer-create "*rpd*"))
  (delete-region (point-min) (point-max))
    (insert "  " (replace-regexp-in-string "\n" "\n  " (ratpoison-windows)))
    (ratpoison-dired-mode 1)))

(defun ratpoison-dired-mark ()
    (goto-char (line-beginning-position))
    (delete-char 1)
    (insert "D"))

(defun ratpoison-dired-unmark ()
    (goto-char (line-beginning-position))
    (delete-char 1)
    (insert " "))

;; this could be done with ratpoison-info
(defun ratpoison-current-window ()
  (let ((contents (buffer-substring-no-properties (point-min) (point-max))))
    (with-temp-buffer (insert contents)
                      (goto-char (point-min))
                      (search-forward-regexp "^[ D] \\([0-9]\\)+\\+")
                      (match-string 1))))

(defun ratpoison-dired-delete-marked ()
  (let ((current (ratpoison-current-window)))
    (while (search-forward-regexp "^D \\([0-9]+\\)" nil t)
      (ratpoison-select (match-string 1))
      (replace-match "")
      (delete-char 1))
    (ratpoison-select current))
  (ratpoison-dired-mode -1))

Ratpoison-devel mailing list

reply via email to

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