ratpoison-devel
[Top][All Lists]
Advanced

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

[RP] sketch: ratpoison-dired.el


From: Joe Corneli
Subject: [RP] sketch: ratpoison-dired.el
Date: Wed, 21 Mar 2007 14:26:45 -0400 (EDT)

Hi, this isn't done, but I thought I'd "release early" and get your
thoughts.

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).

Opinions?

(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 ()
  (interactive)
  (switch-to-buffer (get-buffer-create "*rpd*"))
  (delete-region (point-min) (point-max))
  (save-excursion
    (insert "  " (replace-regexp-in-string "\n" "\n  " (ratpoison-windows)))
    (ratpoison-dired-mode 1)))

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

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

;; 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 ()
  (interactive)
  (let ((current (ratpoison-current-window)))
    (while (search-forward-regexp "^D \\([0-9]+\\)" nil t)
      (ratpoison-select (match-string 1))
      (ratpoison-delete)
      (replace-match "")
      (delete-char 1))
    (ratpoison-select current))
  (ratpoison-dired-mode -1))






reply via email to

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