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

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

[h-e-w] Need help with lisp function and comint interaction


From: Robert Mecklenburg
Subject: [h-e-w] Need help with lisp function and comint interaction
Date: Mon, 4 Feb 2002 15:40:43 -0700

I've got this function which will execute a cvs query to determine the
tags on a cvs controlled file and build a for loop to remove the cvs
tags on the file.  The function is very useful when renaming cvs
files.  Unfortunately, it "fails" for files with long tags lists
(precisely those where it would be most useful).  The failure, I
believe, is that it doesn't properly wait for the cvs process output
to complete before searching for tags.  I'm having trouble getting that
part right.  Any suggestions?


(defun build-tag-remover (file-name)
  "Query the tags on a cvs controlled file and build a bash for loop for 
deleting all tags."
  (interactive "fFile name: ")
  (setq file-name (file-name-nondirectory file-name))

  (let ((proc (get-buffer-process (current-buffer)))
        ;; Remember the current prompt for later searching...
        (prompt (save-excursion
                  (buffer-substring (progn (forward-line 0) (point))
                                    (progn (end-of-line 1) (point))))))

    ;; Go to the end of the buffer and execute a cvs status command.
    (comint-goto-process-mark)
    (insert "cvs status -v " file-name)
    (comint-send-input)

    ;; This is my lame attempt at waiting for the output and doesn't
    ;; work at all.
    ;;( while (and (accept-process-output proc 0 500)
    ;;  (or
    ;;   (save-excursion
    ;;     (forward-line 0)
    ;;     (not (re-search-forward comint-prompt-regexp (point-max) t)))
    ;;   (not (string-equal (string-match) prompt)))))

    ;; This waits, but not long enough when output is large.
    (accept-process-output proc 1)
    (comint-goto-process-mark)

    ;; Find the tag list.
    (search-backward "Existing Tags:")
    (let ((for-command "for f in"))
      (while (re-search-forward "^\\s-+\\([a-z_][a-z_0-9]*\\)" (point-max) t)
        (setq for-command 
              (concat for-command " " 
                      (buffer-substring (match-beginning 1) (match-end 1)))))
      (setq for-command (concat for-command "; do echo cvs tag -d $f " 
file-name "; done"))
      (goto-char (point-max))
      (insert for-command))
    (search-backward " echo ")))

Thanks,
-- 
Robert




reply via email to

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