unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* Visited-file-modtime bug
@ 2006-01-08 19:52 Whitfield Diffie
  0 siblings, 0 replies; only message in thread
From: Whitfield Diffie @ 2006-01-08 19:52 UTC (permalink / raw


[-- Attachment #1: Type: text/plain, Size: 1602 bytes --]

				Sunday  08 January 2006  at 11:49

    An attempt to find-file to root in an emacs in which there is already a
buffer containing the root directory produces the error:

		     Wrong type argument: listp, 21''.

    The error manifests in dired-internal-noselect (attached) which follows
the path:

    (if (not new-buffer-p)     ; existing buffer ...
		*		*		*
	      ((if (let ((attributes (file-attributes dirname))
			 (modtime (visited-file-modtime)))
		     (or (eq modtime 0)
			 (not (eq (car attributes) t))
			 (and (= (car (nth 5 attributes)) (car modtime))
			      (= (nth 1 (nth 5 attributes)) (cdr modtime)))))
		*		*		*

I presume that (visited-file-modtime) of the root directory is supposed to
be zero; it is actually 21, which fails the zero test and then errors two
lines later on the attempt to take its car.

    I have corrected this for my own use by adding (not (consp modtime)) to the
or, effectively replacing (eq modtime 0) but this does not correct the root cause.

    Visited-file-modtime is also used in:

fast-lock.el:	  (file-timestamp (visited-file-modtime)) (saved nil))
fast-lock.el:  (let ((buf-timestamp (visited-file-modtime))
files.el:		(old-modtime (visited-file-modtime)))
gnus/nnfolder.el:	  (setq newscantime (visited-file-modtime))
net/ange-ftp.el:              (buf-mdtm (with-current-buffer buf (visited-file-modtime))))

I don't know whether any of these uses produce errors or whether there are
errors associated with any of the associated functions
clear-visited-file-modtime, set-visited-file-modtime, and
verify-visited-file-modtime.

					Whit


[-- Attachment #2: dired-internal-noselect-from-gnu-emacs-21.4.el --]
[-- Type: application/octet-stream, Size: 3309 bytes --]

(defun dired-internal-noselect (dir-or-list &optional switches mode)
  ;; If there is an existing dired buffer for DIRNAME, just leave
  ;; buffer as it is (don't even call dired-revert).
  ;; This saves time especially for deep trees or with ange-ftp.
  ;; The user can type `g'easily, and it is more consistent with find-file.
  ;; But if SWITCHES are given they are probably different from the
  ;; buffer's old value, so call dired-sort-other, which does
  ;; revert the buffer.
  ;; A pity we can't possibly do "Directory has changed - refresh? "
  ;; like find-file does.
  ;; Optional argument MODE is passed to dired-find-buffer-nocreate,
  ;; see there.
  (let* ((dirname (if (consp dir-or-list) (car dir-or-list) dir-or-list))
	 ;; The following line used to use dir-or-list.
	 ;; That never found an existing buffer, in the case
	 ;; where it is a list.
	 (buffer (dired-find-buffer-nocreate dirname mode))
	 ;; note that buffer already is in dired-mode, if found
	 (new-buffer-p (not buffer))
	 (old-buf (current-buffer)))
    (or buffer
	(let ((default-major-mode 'fundamental-mode))
	  ;; We don't want default-major-mode to run hooks and set auto-fill
	  ;; or whatever, now that dired-mode does not
	  ;; kill-all-local-variables any longer.
	  (setq buffer (create-file-buffer (directory-file-name dirname)))))
    (set-buffer buffer)
    (if (not new-buffer-p)     ; existing buffer ...
	(cond (switches        ; ... but new switches     
	       ;; file list may have changed
	       (if (consp dir-or-list) 
		   (setq dired-directory dir-or-list))
	       ;; this calls dired-revert
	       (dired-sort-other switches))  
	      ;; If directory has changed on disk, offer to revert.
	      ((if (let ((attributes (file-attributes dirname))
			 (modtime (visited-file-modtime)))
		     (or (eq modtime 0)
			 (not (eq (car attributes) t))
			 (and (= (car (nth 5 attributes)) (car modtime))
			      (= (nth 1 (nth 5 attributes)) (cdr modtime)))))
		   nil
		 (message "%s"
			  (substitute-command-keys
			   "Directory has changed on disk; type \\[revert-buffer] to update Dired")))))
      ;; Else a new buffer
      (setq default-directory
	    ;; We can do this unconditionally
	    ;; because dired-noselect ensures that the name
	    ;; is passed in directory name syntax
	    ;; if it was the name of a directory at all.
	    (file-name-directory dirname))
      (or switches (setq switches dired-listing-switches))
      (if mode (funcall mode)
        (dired-mode dirname switches))
      ;; default-directory and dired-actual-switches are set now
      ;; (buffer-local), so we can call dired-readin:
      (let ((failed t))
	(unwind-protect
	    (progn (dired-readin dir-or-list buffer)
		   (setq failed nil))
	  ;; dired-readin can fail if parent directories are inaccessible.
	  ;; Don't leave an empty buffer around in that case.
	  (if failed (kill-buffer buffer))))
      ;; No need to narrow since the whole buffer contains just
      ;; dired-readin's output, nothing else.  The hook can
      ;; successfully use dired functions (e.g. dired-get-filename)
      ;; as the subdir-alist has been built in dired-readin.
      (run-hooks 'dired-after-readin-hook)
      (goto-char (point-min))
      (dired-initial-position dirname))
    (set-buffer old-buf)
    buffer))


[-- Attachment #3: Type: text/plain, Size: 149 bytes --]

_______________________________________________
bug-gnu-emacs mailing list
bug-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-01-08 19:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-08 19:52 Visited-file-modtime bug Whitfield Diffie

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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