annotate lisp/gnus/nnheaderxm.el @ 28:1917ad0d78d7 r19-15b97

Import from CVS: tag r19-15b97
author cvs
date Mon, 13 Aug 2007 08:51:55 +0200
parents 0293115a14e9
children ec9a17fef872
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; nnheaderxm.el --- making Gnus backends work under XEmacs
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
2 ;; Copyright (C) 1996,97 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: news
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (defun nnheader-xmas-run-at-time (time repeat function &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (start-itimer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 "nnheader-run-at-time"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 `(lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (,function ,@args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 time repeat))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (defun nnheader-xmas-cancel-timer (timer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (delete-itimer timer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
38 (defun nnheader-xmas-cancel-function-timers (function)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
39 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (defun nnheader-xmas-find-file-noselect (filename &optional nowarn rawfile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 "Read file FILENAME into a buffer and return the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 If a buffer exists visiting FILENAME, return that one, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 verify that the file has not changed since visited or saved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 The buffer is not selected, just returned to the caller."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (setq filename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (abbreviate-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (expand-file-name filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (if (file-directory-p filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (if find-file-run-dired
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (dired-noselect filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (error "%s is a directory." filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (let* ((buf (get-file-buffer filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (truename (abbreviate-file-name (file-truename filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (number (nthcdr 10 (file-attributes truename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; Find any buffer for a file which has same truename.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
57 (other (and (not buf)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (get-file-buffer filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; Let user know if there is a buffer with the same truename.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
61 (when other
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
62 (or nowarn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
63 (string-equal filename (buffer-file-name other))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
64 (message "%s and %s are the same file"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
65 filename (buffer-file-name other)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
66 ;; Optionally also find that buffer.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
67 (when (or (and (boundp 'find-file-existing-other-name)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
68 find-file-existing-other-name)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
69 find-file-visit-truename)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
70 (setq buf other)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (if buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (or nowarn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (verify-visited-file-modtime buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (cond ((not (file-exists-p filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (error "File %s no longer exists!" filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ((yes-or-no-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (if (string= (file-name-nondirectory filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (buffer-name buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (if (buffer-modified-p buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 "File %s changed on disk. Discard your edits? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 "File %s changed on disk. Reread from disk? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (file-name-nondirectory filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (if (buffer-modified-p buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 "File %s changed on disk. Discard your edits in %s? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 "File %s changed on disk. Reread from disk into %s? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (file-name-nondirectory filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (buffer-name buf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (revert-buffer t t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;; The truename stuff makes this obsolete.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;; (let* ((link-name (car (file-attributes filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;;; (linked-buf (and (stringp link-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;; (get-file-buffer link-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;; (if (bufferp linked-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;; (message "Symbolic link to file in buffer %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;; (buffer-name linked-buf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (setq buf (create-file-buffer filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;; (set-buffer-major-mode buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (if rawfile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (condition-case ()
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
107 (nnheader-insert-file-contents filename t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (file-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;; Unconditionally set error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (setq error t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (insert-file-contents filename t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (file-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;; Run find-file-not-found-hooks until one returns non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (or t ; (run-hook-with-args-until-success 'find-file-not-found-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; If they fail too, set error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (setq error t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;; Find the file's truename, and maybe use that as visited name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (setq buffer-file-truename truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (setq buffer-file-number number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;; On VMS, we may want to remember which directory in a search list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;; the file was found in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (and (eq system-type 'vax-vms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (let (logical)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
125 (when (string-match ":" (file-name-directory filename))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
126 (setq logical (substring (file-name-directory filename)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
127 0 (match-beginning 0))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (not (member logical find-file-not-true-dirname-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (setq buffer-file-name buffer-file-truename))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
130 (when find-file-visit-truename
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
131 (setq buffer-file-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
132 (setq filename
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
133 (expand-file-name buffer-file-truename))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;; Set buffer's default directory to that of the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (setq default-directory (file-name-directory filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; Turn off backup files for certain file names. Since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;; this is a permanent local, the major mode won't eliminate it.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
138 (when (not (funcall backup-enable-predicate buffer-file-name))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
139 (make-local-variable 'backup-inhibited)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
140 (setq backup-inhibited t))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (if rawfile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (after-find-file error (not nowarn)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (fset 'nnheader-run-at-time 'nnheader-xmas-run-at-time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (fset 'nnheader-cancel-timer 'nnheader-xmas-cancel-timer)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
148 (fset 'nnheader-cancel-function-timers 'nnheader-xmas-cancel-function-timers)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (fset 'nnheader-find-file-noselect 'nnheader-xmas-find-file-noselect)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (provide 'nnheaderxm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;;; nnheaderxm.el ends here.