ratpoison-devel
[Top][All Lists]
Advanced

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

-Shawn

On 3/21/07, Joe Corneli < address@hidden> wrote:
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))




_______________________________________________
Ratpoison-devel mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/ratpoison-devel


reply via email to

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