unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* NTemacs doesn't understand RCS
@ 2004-11-04 16:19 Scott Thibault
  2004-11-04 18:46 ` Kevin Rodgers
  0 siblings, 1 reply; 7+ messages in thread
From: Scott Thibault @ 2004-11-04 16:19 UTC (permalink / raw)


Hi,

I'm using a version of RCS that allows you to create a text file
called RCS that contains a pointer to the RCS directory rather than a
real directory - a work around for not having links on Windows.

So, the question is how do I get emacs to understand these link files?
 Out-of-the-box, when I try C-x v v, the ci command fails with the
message \src\RCS\file.c,v already exists.  I assume because emacs
doesn't recognize the RCS "link" and tries to do a ci -i.

Any ideas??

--Scott

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: NTemacs doesn't understand RCS
  2004-11-04 16:19 NTemacs doesn't understand RCS Scott Thibault
@ 2004-11-04 18:46 ` Kevin Rodgers
  2004-11-09 20:29   ` Scott Thibault
  0 siblings, 1 reply; 7+ messages in thread
From: Kevin Rodgers @ 2004-11-04 18:46 UTC (permalink / raw)


Scott Thibault wrote:
 > I'm using a version of RCS that allows you to create a text file
 > called RCS that contains a pointer to the RCS directory rather than a
 > real directory - a work around for not having links on Windows.
 >
 > So, the question is how do I get emacs to understand these link files?
 >  Out-of-the-box, when I try C-x v v, the ci command fails with the
 > message \src\RCS\file.c,v already exists.  I assume because emacs
 > doesn't recognize the RCS "link" and tries to do a ci -i.

Try this (untested!):

(defun gmvhdl-rcs-template (directory file)
   "Return non-nil if FILE in DIRECTORY is under RCS control."
   (if (file-regular-p (expand-file-name "RCS" directory))
       (let ((rcs-directory
              (with-temp-buffer
                (insert-file-contents (expand-file-name "RCS" directory))
                (buffer-string))))
         ;; in case rcs-directory is relative:
         (setq rcs-directory
               (expand-file-name rcs-directory directory))
         ;; check rcs-directory/FILE against the default templates:
         (if (file-directory-p rcs-directory)
             (vc-check-master-templates (expand-file-name file 
rcs-directory)
                                        (remq 'gmvhdl-rcs-template
                                              vc-rcs-master-templates))))))

(setq vc-rcs-master-templates
       (cons 'gmvhdl-rcs-template vc-rcs-master-templates))

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: NTemacs doesn't understand RCS
  2004-11-04 18:46 ` Kevin Rodgers
@ 2004-11-09 20:29   ` Scott Thibault
  2004-11-09 23:03     ` Stefan Monnier
  2004-11-10  0:45     ` Kevin Rodgers
  0 siblings, 2 replies; 7+ messages in thread
From: Scott Thibault @ 2004-11-09 20:29 UTC (permalink / raw)


I'm still getting the same message, so I guess it is not working.  I
put it in my .emacs file and just to be sure copied it to *scratch*
and did an eval-buffer.  What is vc-rcs-master-templates?  The look
like they should be file specs.  Is there a way to debug this code?

Thanks
--Scott

Kevin Rodgers <ihs_4664@yahoo.com> wrote in message news:<2uvbniF2f1357U1@uni-berlin.de>...
> Scott Thibault wrote:
>  > I'm using a version of RCS that allows you to create a text file
>  > called RCS that contains a pointer to the RCS directory rather than a
>  > real directory - a work around for not having links on Windows.
>  >
>  > So, the question is how do I get emacs to understand these link files?
>  >  Out-of-the-box, when I try C-x v v, the ci command fails with the
>  > message \src\RCS\file.c,v already exists.  I assume because emacs
>  > doesn't recognize the RCS "link" and tries to do a ci -i.
> 
> Try this (untested!):
> 
> (defun gmvhdl-rcs-template (directory file)
>    "Return non-nil if FILE in DIRECTORY is under RCS control."
>    (if (file-regular-p (expand-file-name "RCS" directory))
>        (let ((rcs-directory
>               (with-temp-buffer
>                 (insert-file-contents (expand-file-name "RCS" directory))
>                 (buffer-string))))
>          ;; in case rcs-directory is relative:
>          (setq rcs-directory
>                (expand-file-name rcs-directory directory))
>          ;; check rcs-directory/FILE against the default templates:
>          (if (file-directory-p rcs-directory)
>              (vc-check-master-templates (expand-file-name file 
> rcs-directory)
>                                         (remq 'gmvhdl-rcs-template
>                                               vc-rcs-master-templates))))))
> 
> (setq vc-rcs-master-templates
>        (cons 'gmvhdl-rcs-template vc-rcs-master-templates))

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: NTemacs doesn't understand RCS
  2004-11-09 20:29   ` Scott Thibault
@ 2004-11-09 23:03     ` Stefan Monnier
  2004-11-10  0:45     ` Kevin Rodgers
  1 sibling, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2004-11-09 23:03 UTC (permalink / raw)


> I'm still getting the same message, so I guess it is not working.  I
> put it in my .emacs file and just to be sure copied it to *scratch*
> and did an eval-buffer.  What is vc-rcs-master-templates?  The look
> like they should be file specs.  Is there a way to debug this code?

Put the code in a scratch buffer, place the cursor inside the
gmvhdl-rcs-template and do C-u M-C-x (i.e. "eval defun using edebug").

Then C-x C-f one of those RCS-controlled files : you'll be put inside the
Edebug debugger where you can execute the function step by step (`n' or SPC
advances one step, `q' quits).  See the edebug manual for more.


        Stefan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: NTemacs doesn't understand RCS
  2004-11-09 20:29   ` Scott Thibault
  2004-11-09 23:03     ` Stefan Monnier
@ 2004-11-10  0:45     ` Kevin Rodgers
  2004-11-10 11:22       ` Scott Thibault
  1 sibling, 1 reply; 7+ messages in thread
From: Kevin Rodgers @ 2004-11-10  0:45 UTC (permalink / raw)


[Please don't top-post.]

Scott Thibault wrote:
 > I'm still getting the same message, so I guess it is not working.  I
 > put it in my .emacs file and just to be sure copied it to *scratch*
 > and did an eval-buffer.

Saving it in your .emacs file will affect future invocations.  Eval'ing
it in the *scratch* buffer will affect the current invocation -- but you
have to beware that Emacs caches version control info, so you might need
to do the following before revisiting the file with e.g `C-x C-v':

M-: (vc-file-clearprops buffer-file-name) RET

 > What is vc-rcs-master-templates?  The look like they should be file
 > specs.

`C-h v' should answer that.

I see a potential bug that might prevent it from working: if the RCS
file's contents have any leading or trailing whitespace, it will be
taken as a literal part of the RCS directory name.  Try replacing:

                (buffer-string))))
with:
                (buffer-substring (progn
                                    (goto-char (point-min))
                                    (point))
                                  (if (re-search-forward "\n+\\'" nil t)
                                      (match-beginning 0)
                                    (point-max))))))

 > Is there a way to debug this code?

See Stefan's response.

-- 
Kevin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: NTemacs doesn't understand RCS
  2004-11-10  0:45     ` Kevin Rodgers
@ 2004-11-10 11:22       ` Scott Thibault
  0 siblings, 0 replies; 7+ messages in thread
From: Scott Thibault @ 2004-11-10 11:22 UTC (permalink / raw)


> I see a potential bug that might prevent it from working: if the RCS
> file's contents have any leading or trailing whitespace, it will be
> taken as a literal part of the RCS directory name.  Try replacing:
> 
>                 (buffer-string))))
> with:
>                 (buffer-substring (progn
>                                     (goto-char (point-min))
>                                     (point))
>                                   (if (re-search-forward "\n+\\'" nil t)
>                                       (match-beginning 0)
>                                     (point-max))))))
> 
>  > Is there a way to debug this code?
> 
> See Stefan's response.

It's working!  Thanks for the help.  Using the debugger I could see
that it was in fact picking up a \n character as part of the filename.

--Scott

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: NTemacs doesn't understand RCS
@ 2004-12-22  5:47 Jonathan Freidin
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Freidin @ 2004-12-22  5:47 UTC (permalink / raw)


;;; Inspired by a post from Kevin Rodgers.

;;; Fix a problem in Kevin's code, that the paths in vc-rcs-master-templates
;;; are relative to the parent of the file or directory in the RCS link.
This
;;; causes "%sRCS/%s,v" and "%sRCS/%s" templates to fail because of the
extra
;;; "RCS". A "%s%s" (not in vc-rcs-master-templates) also fails because
;;; vc-check-master-templates ensures that the master file isn't the same as
;;; the source file, and it is in the way Kevin used it. Most everything
else
;;; is the way Kevin wrote it.

(defun vc-rcs-template-fn (directory file)
  "Return non-nil if FILE in DIRECTORY is under RCS control."
  (if (file-regular-p (expand-file-name "RCS" directory))
      (let ((rcs-directory
	     ;; Start in the parent directory so the template doesn't fail
on
	     ;; the check for the identical file. This also allows using
	     ;; vc-rcs-master-templates.
	     (concat
	      (with-temp-buffer
		(insert-file-contents (expand-file-name "RCS" directory))
		(buffer-substring (goto-char (point-min))
				  (progn (end-of-line) (point))))
	      "/..")))
	;; in case rcs-directory is relative:
	(setq rcs-directory
	      (expand-file-name rcs-directory directory))
	;; check rcs-directory/FILE against the default templates:
	(if (file-directory-p rcs-directory)
	    (vc-check-master-templates (expand-file-name file rcs-directory)
				       (remq 'vc-rcs-template-fn
					     vc-rcs-master-templates))))))

(setq vc-rcs-master-templates
      (cons 'vc-rcs-template-fn vc-rcs-master-templates))

Jonathan

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-12-22  5:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-04 16:19 NTemacs doesn't understand RCS Scott Thibault
2004-11-04 18:46 ` Kevin Rodgers
2004-11-09 20:29   ` Scott Thibault
2004-11-09 23:03     ` Stefan Monnier
2004-11-10  0:45     ` Kevin Rodgers
2004-11-10 11:22       ` Scott Thibault
  -- strict thread matches above, loose matches on Subject: below --
2004-12-22  5:47 Jonathan Freidin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).