3

My work uses GNU RCS for our version control system, but I don't think the specific VCS is relevant here. (I know RCS isn't the most modern system but it suits our needs fine and has the advantage of relative simplicity. Anyway, that's not the question.)

When I steal the lock on a file using C-x v v, emacs opens up a buffer so I can email the person from whom I stole it. I never need to do this, so I have to go to the trouble of killing the buffer and then confirming that I want to do so. This is a hassle I'd rather avoid.

So, how can I make emacs not open that buffer in the first place?

EDIT As pointed out in the comments, I could have included more relevant info.

The package is vc, and the keybinding C-x v v calls the function vc-next-action, which is a smart command that attempts to figure out what you want to do next.

In this case, RCS is an "old-style locking-based VCS", somebody else has locked the file and the function is attempting to steal the lock, as outlined in the function's documentation.

FURTHER EDIT Digging a little more deeply, it seems that vc-next-action is calling vc-steal-lock (surprise, surprise). This function contains the following chunk of code at the end:

;; Write mail after actually stealing, because if the stealing
;; goes wrong, we don't want to send any mail.
(compose-mail owner (format "Stolen lock on %s" file-description))
(setq default-directory (expand-file-name "~/"))
(goto-char (point-max))
(insert
 (format "I stole the lock on %s, " file-description)
 (current-time-string)
 ".\n")
(message "Please explain why you stole the lock.  Type C-c C-c when done."))

I assume that if I comment this out, the email buffer won't open. I know that just commenting out this chunk in the source code isn't the right way to go about things. But what is the right way to modify a built-in function in a way that will survive if I upgrade, reinstall, etc?

2
  • 1
    While there are surely people who are intimately familiar with this feature, there are a number of us who might be able to answer this question if we could just evaluate (require 'name-of-library) and then type M-x find-function RET name-of-function RET and follow the trail to see what makes it tick. If we had the name-of-function and name-of-library it sure would be a lot easier than figuring out what library has a keyboard shortcut of C-x v v relating to RCS/VCS. :)
    – lawlist
    Commented Aug 31, 2016 at 22:36
  • @lawlist Question updated, thank you very much for helping me improve it :)
    – MTS
    Commented Aug 31, 2016 at 23:48

1 Answer 1

2

I figured it out. Following method 2 outlined in this answer, I just redefined the function vc-steal-lock by commenting out the chunk of code that has to do with emailing the person from whom you stole the lock.

  (eval-after-load "vc"
  '(defun vc-steal-lock (file rev owner)
  "Steal the lock on FILE."
  (let (file-description)
    (if rev
    (setq file-description (format "%s:%s" file rev))
      (setq file-description file))
    (when (not (yes-or-no-p (format "Steal the lock on %s from %s? "
                    file-description owner)))
      (error "Steal canceled"))
    (message "Stealing lock on %s..." file)
    (with-vc-properties
     (list file)
     (vc-call steal-lock file rev)
     `((vc-state . edited)))
    (vc-resynch-buffer file t t)
    (message "Stealing lock on %s...done" file)
    ;; commented this chunk out to avoid emailing re: stealing the lock
    ;;
    ;; Write mail after actually stealing, because if the stealing
    ;; goes wrong, we don't want to send any mail.
    ;; (compose-mail owner (format "Stolen lock on %s" file-description))
    ;; (setq default-directory (expand-file-name "~/"))
    ;; (goto-char (point-max))
    ;; (insert
    ;;  (format "I stole the lock on %s, " file-description)
    ;;  (current-time-string)
    ;;  ".\n")
    ;; (message "Please explain why you stole the lock.  Type C-c C-c when done.")
    )))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.