1 ;;; gnus-xmas.el --- Gnus functions for XEmacs
2 ;; Copyright (C) 1995,96 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
30 (defvar menu-bar-mode t)
31 (require 'message-xmas)
33 (defvar gnus-xmas-glyph-directory nil
34 "*Directory where Gnus logos and icons are located.
35 If this variable is nil, Gnus will try to locate the directory
38 ;;; Internal variables.
40 (defvar gnus-xmas-logo (make-glyph (make-specifier 'image)))
42 ;; Don't warn about these undefined variables.
44 (defvar gnus-group-mode-hook)
45 (defvar gnus-summary-mode-hook)
46 (defvar gnus-article-mode-hook)
49 (defvar gnus-active-hashtb)
50 (defvar gnus-article-buffer)
51 (defvar gnus-auto-center-summary)
52 (defvar gnus-buffer-list)
53 (defvar gnus-current-headers)
54 (defvar gnus-level-killed)
55 (defvar gnus-level-zombie)
56 (defvar gnus-newsgroup-bookmarks)
57 (defvar gnus-newsgroup-dependencies)
58 (defvar gnus-newsgroup-selected-overlay)
59 (defvar gnus-newsrc-hashtb)
60 (defvar gnus-read-mark)
61 (defvar gnus-refer-article-method)
62 (defvar gnus-reffed-article-number)
63 (defvar gnus-unread-mark)
65 (defvar gnus-view-pseudos)
66 (defvar gnus-view-pseudos-separately)
68 (defvar gnus-zombie-list)
69 ;;defined in gnus-msg.el
70 (defvar gnus-article-copy)
71 (defvar gnus-check-before-posting)
72 ;;defined in gnus-vis.el
73 (defvar gnus-article-button-face)
74 (defvar gnus-article-mouse-face)
75 (defvar gnus-summary-selected-face)
76 (defvar gnus-group-reading-menu)
77 (defvar gnus-group-group-menu)
78 (defvar gnus-group-misc-menu)
79 (defvar gnus-summary-article-menu)
80 (defvar gnus-summary-thread-menu)
81 (defvar gnus-summary-misc-menu)
82 (defvar gnus-summary-post-menu)
83 (defvar gnus-summary-kill-menu)
84 (defvar gnus-article-article-menu)
85 (defvar gnus-article-treatment-menu)
87 (defvar standard-display-table)
89 (defun gnus-xmas-set-text-properties (start end props &optional buffer)
90 "You should NEVER use this function. It is ideologically blasphemous.
91 It is provided only to ease porting of broken FSF Emacs programs."
94 (map-extents (lambda (extent ignored)
95 (remove-text-properties
97 (list (extent-property extent 'text-prop) nil)
99 buffer start end nil nil 'text-prop)
100 (add-text-properties start end props buffer)))
102 (defun gnus-xmas-highlight-selected-summary ()
103 ;; Highlight selected article in summary buffer
104 (if gnus-summary-selected-face
106 (if gnus-newsgroup-selected-overlay
107 (delete-extent gnus-newsgroup-selected-overlay))
108 (setq gnus-newsgroup-selected-overlay
109 (make-extent (gnus-point-at-bol) (gnus-point-at-eol)))
110 (set-extent-face gnus-newsgroup-selected-overlay
111 gnus-summary-selected-face))))
113 (defun gnus-xmas-summary-recenter ()
114 "Center point in the summary window.
115 If `gnus-auto-center-summary' is nil, or the article buffer isn't
116 displayed, no centering will be performed."
117 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
118 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
119 (let* ((top (cond ((< (window-height) 4) 0)
120 ((< (window-height) 7) 1)
122 (height (- (window-height) 3))
123 (bottom (save-excursion (goto-char (point-max))
124 (forward-line (- height))
126 (window (get-buffer-window (current-buffer))))
127 ;; The user has to want it.
128 (when gnus-auto-center-summary
129 (when (get-buffer-window gnus-article-buffer)
130 ;; Only do recentering when the article buffer is displayed,
131 ;; Set the window start to either `bottom', which is the biggest
132 ;; possible valid number, or the second line from the top,
133 ;; whichever is the least.
135 window (min bottom (save-excursion
136 (forward-line (- top)) (point)))))
137 ;; Do horizontal recentering while we're at it.
138 (when (and (get-buffer-window (current-buffer) t)
139 (not (eq gnus-auto-center-summary 'vertical)))
140 (let ((selected (selected-window)))
141 (select-window (get-buffer-window (current-buffer) t))
142 (gnus-summary-position-point)
143 (gnus-horizontal-recenter)
144 (select-window selected))))))
146 (defun gnus-xmas-group-remove-excess-properties ()
148 (beg (progn (forward-line -1) (point))))
149 (remove-text-properties (1+ beg) end '(gnus-group nil))
150 (remove-text-properties
152 '(gnus-topic nil gnus-topic-level nil gnus-topic-visible nil))
155 (defun gnus-xmas-topic-remove-excess-properties ()
157 (beg (progn (forward-line -1) (point))))
158 (remove-text-properties beg end '(gnus-group nil gnus-unread nil))
161 (defun gnus-xmas-extent-start-open (point)
162 (map-extents (lambda (extent arg)
163 (set-extent-property extent 'start-open t))
164 nil point (min (1+ (point)) (point-max))))
166 (defun gnus-xmas-copy-article-buffer (&optional article-buffer)
167 (setq gnus-article-copy (get-buffer-create " *gnus article copy*"))
168 (buffer-disable-undo gnus-article-copy)
169 (or (memq gnus-article-copy gnus-buffer-list)
170 (setq gnus-buffer-list (cons gnus-article-copy gnus-buffer-list)))
171 (let ((article-buffer (or article-buffer gnus-article-buffer))
173 (if (and (get-buffer article-buffer)
174 (buffer-name (get-buffer article-buffer)))
176 (set-buffer article-buffer)
178 (setq buf (buffer-substring (point-min) (point-max)))
179 (set-buffer gnus-article-copy)
181 (insert (format "%s" buf))))
184 (defun gnus-xmas-article-push-button (event)
185 "Check text under the mouse pointer for a callback function.
186 If the text under the mouse pointer has a `gnus-callback' property,
187 call it with the value of the `gnus-data' text property."
189 (set-buffer (window-buffer (event-window event)))
190 (let* ((pos (event-closest-point event))
191 (data (get-text-property pos 'gnus-data))
192 (fun (get-text-property pos 'gnus-callback)))
193 (if fun (funcall fun data))))
195 (defun gnus-xmas-move-overlay (extent start end &optional buffer)
196 (set-extent-endpoints extent start end))
198 ;; Fixed by Christopher Davis <ckd@loiosh.kei.com>.
199 (defun gnus-xmas-article-add-button (from to fun &optional data)
200 "Create a button between FROM and TO with callback FUN and data DATA."
201 (and gnus-article-button-face
202 (gnus-overlay-put (gnus-make-overlay from to)
203 'face gnus-article-button-face))
207 (and gnus-article-mouse-face
208 (list 'mouse-face gnus-article-mouse-face))
209 (list 'gnus-callback fun)
210 (and data (list 'gnus-data data))
211 (list 'highlight t))))
213 (defun gnus-xmas-window-top-edge (&optional window)
214 (nth 1 (window-pixel-edges window)))
216 (defun gnus-xmas-tree-minimize ()
217 (when (and gnus-tree-minimize-window
218 (not (one-window-p)))
219 (let* ((window-min-height 2)
220 (height (1+ (count-lines (point-min) (point-max))))
221 (min (max (1- window-min-height) height))
222 (tot (if (numberp gnus-tree-minimize-window)
223 (min gnus-tree-minimize-window min)
225 (win (get-buffer-window (current-buffer)))
226 (wh (and win (1- (window-height win)))))
229 (let ((selected (selected-window)))
231 (enlarge-window (- tot wh))
232 (select-window selected))))))
234 ;; Select the lowest window on the frame.
235 (defun gnus-xmas-appt-select-lowest-window ()
236 (let* ((lowest-window (selected-window))
237 (bottom-edge (car (cdr (cdr (cdr (window-pixel-edges))))))
238 (last-window (previous-window))
241 (let* ((this-window (next-window))
242 (next-bottom-edge (car (cdr (cdr (cdr
245 (if (< bottom-edge next-bottom-edge)
247 (setq bottom-edge next-bottom-edge)
248 (setq lowest-window this-window)))
250 (select-window this-window)
251 (if (eq last-window this-window)
253 (select-window lowest-window)
254 (setq window-search nil)))))))
256 (defmacro gnus-xmas-menu-add (type &rest menus)
257 `(gnus-xmas-menu-add-1 ',type ',menus))
258 (put 'gnus-xmas-menu-add 'lisp-indent-function 1)
259 (put 'gnus-xmas-menu-add 'lisp-indent-hook 1)
261 (defun gnus-xmas-menu-add-1 (type menus)
262 (when (and menu-bar-mode
263 (gnus-visual-p (intern (format "%s-menu" type)) 'menu))
265 (easy-menu-add (symbol-value (pop menus))))))
267 (defun gnus-xmas-group-menu-add ()
268 (gnus-xmas-menu-add group
269 gnus-group-reading-menu gnus-group-group-menu gnus-group-misc-menu))
271 (defun gnus-xmas-summary-menu-add ()
272 (gnus-xmas-menu-add summary
273 gnus-summary-article-menu gnus-summary-thread-menu
274 gnus-summary-misc-menu gnus-summary-post-menu gnus-summary-kill-menu))
276 (defun gnus-xmas-article-menu-add ()
277 (gnus-xmas-menu-add article
278 gnus-article-article-menu gnus-article-treatment-menu))
280 (defun gnus-xmas-pick-menu-add ()
281 (gnus-xmas-menu-add pick
284 (defun gnus-xmas-binary-menu-add ()
285 (gnus-xmas-menu-add binary
288 (defun gnus-xmas-tree-menu-add ()
289 (gnus-xmas-menu-add tree
292 (defun gnus-xmas-grouplens-menu-add ()
293 (gnus-xmas-menu-add grouplens
294 gnus-grouplens-menu))
296 (defun gnus-xmas-read-event-char ()
297 "Get the next event."
298 (let ((event (next-event)))
299 ;; We junk all non-key events. Is this naughty?
300 (while (not (key-press-event-p event))
301 (setq event (next-event)))
302 (cons (and (key-press-event-p event)
303 ; (numberp (event-key event))
304 (event-to-character event))
307 (defun gnus-xmas-seconds-since-epoch (date)
308 "Return a floating point number that says how many seconds have lapsed between Jan 1 12:00:00 1970 and DATE."
309 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
310 (timezone-parse-date date)))
311 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
313 (aref (timezone-parse-date date) 3))))
314 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
315 (timezone-parse-date "Jan 1 12:00:00 1970")))
316 (tday (- (timezone-absolute-from-gregorian
317 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
318 (timezone-absolute-from-gregorian
319 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
322 (* (float (nth 0 ttime)) 60 60)
323 (* (float tday) 60 60 24))))
325 (defun gnus-xmas-define ()
326 (setq gnus-mouse-2 [button2])
328 (or (memq 'underline (list-faces))
329 (and (fboundp 'make-face)
330 (funcall (intern "make-face") 'underline)))
331 ;; Must avoid calling set-face-underline-p directly, because it
332 ;; is a defsubst in emacs19, and will make the .elc files non
334 (or (face-differs-from-default-p 'underline)
335 (funcall (intern "set-face-underline-p") 'underline t))
337 (fset 'gnus-make-overlay 'make-extent)
338 (fset 'gnus-overlay-put 'set-extent-property)
339 (fset 'gnus-move-overlay 'gnus-xmas-move-overlay)
340 (fset 'gnus-overlay-end 'extent-end-position)
341 (fset 'gnus-extent-detached-p 'extent-detached-p)
343 (require 'text-props)
344 (if (< emacs-minor-version 14)
345 (fset 'gnus-set-text-properties 'gnus-xmas-set-text-properties))
347 (fset 'nnheader-find-file-noselect 'gnus-xmas-find-file-noselect)
349 (or (boundp 'standard-display-table) (setq standard-display-table nil))
351 (defvar gnus-mouse-face-prop 'highlight)
353 (unless (fboundp 'encode-time)
354 (defun encode-time (sec minute hour day month year &optional zone)
356 (gnus-xmas-seconds-since-epoch
357 (timezone-make-arpa-date
358 year month day (timezone-make-time-string hour minute sec)
360 (list (floor (/ seconds (expt 2 16)))
361 (round (mod seconds (expt 2 16)))))))
363 (defun gnus-byte-code (func)
364 "Return a form that can be `eval'ed based on FUNC."
365 (let ((fval (symbol-function func)))
366 (if (byte-code-function-p fval)
368 (cons 'progn (cdr (cdr fval))))))
370 ;; Fix by "jeff (j.d.) sparkes" <jsparkes@bnr.ca>.
371 (defvar gnus-display-type (device-class)
372 "A symbol indicating the display Emacs is running under.
373 The symbol should be one of `color', `grayscale' or `mono'. If Emacs
374 guesses this display attribute wrongly, either set this variable in
375 your `~/.emacs' or set the resource `Emacs.displayType' in your
376 `~/.Xdefaults'. See also `gnus-background-mode'.
378 This is a meta-variable that will affect what default values other
379 variables get. You would normally not change this variable, but
380 pounce directly on the real variables themselves.")
383 (fset 'gnus-x-color-values
384 (if (fboundp 'x-color-values)
387 (color-instance-rgb-components
388 (make-color-instance color)))))
390 (defvar gnus-background-mode
393 (x-get-resource ".backgroundMode" "BackgroundMode" 'string)
395 (params (frame-parameters))
396 (color (condition-case ()
397 (or (assq 'background-color params)
400 (face-background 'default))))
402 (cond (bg-resource (intern (downcase bg-resource)))
404 (< (apply '+ (gnus-x-color-values color))
405 (/ (apply '+ (gnus-x-color-values "white")) 3)))
408 "A symbol indicating the Emacs background brightness.
409 The symbol should be one of `light' or `dark'.
410 If Emacs guesses this frame attribute wrongly, either set this variable in
411 your `~/.emacs' or set the resource `Emacs.backgroundMode' in your
413 See also `gnus-display-type'.
415 This is a meta-variable that will affect what default values other
416 variables get. You would normally not change this variable, but
417 pounce directly on the real variables themselves.")
422 (defun gnus-xmas-redefine ()
423 "Redefine lots of Gnus functions for XEmacs."
424 (fset 'gnus-summary-make-display-table 'ignore)
425 (fset 'gnus-visual-turn-off-edit-menu 'identity)
426 (fset 'gnus-highlight-selected-summary
427 'gnus-xmas-highlight-selected-summary)
428 (fset 'gnus-summary-recenter 'gnus-xmas-summary-recenter)
429 (fset 'gnus-group-remove-excess-properties
430 'gnus-xmas-group-remove-excess-properties)
431 (fset 'gnus-topic-remove-excess-properties
432 'gnus-xmas-topic-remove-excess-properties)
433 (fset 'gnus-extent-start-open 'gnus-xmas-extent-start-open)
434 (fset 'gnus-copy-article-buffer 'gnus-xmas-copy-article-buffer)
435 (fset 'gnus-article-push-button 'gnus-xmas-article-push-button)
436 (fset 'gnus-article-add-button 'gnus-xmas-article-add-button)
437 (fset 'gnus-window-top-edge 'gnus-xmas-window-top-edge)
438 (fset 'gnus-read-event-char 'gnus-xmas-read-event-char)
439 (fset 'gnus-group-startup-message 'gnus-xmas-group-startup-message)
440 (fset 'gnus-tree-minimize 'gnus-xmas-tree-minimize)
441 (fset 'gnus-appt-select-lowest-window
442 'gnus-xmas-appt-select-lowest-window)
443 (fset 'gnus-mail-strip-quoted-names 'gnus-xmas-mail-strip-quoted-names)
444 (fset 'gnus-make-local-hook 'make-local-variable)
445 (fset 'gnus-character-to-event 'character-to-event)
447 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
448 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
449 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add)
451 (add-hook 'gnus-pick-mode-hook 'gnus-xmas-pick-menu-add)
452 (add-hook 'gnus-tree-mode-hook 'gnus-xmas-tree-menu-add)
453 (add-hook 'gnus-binary-mode-hook 'gnus-xmas-binary-menu-add)
454 (add-hook 'gnus-grouplens-mode-hook 'gnus-xmas-grouplens-menu-add)
456 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar)
457 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar))
460 ;;; XEmacs logo and toolbar.
462 (defun gnus-xmas-group-startup-message (&optional x y)
463 "Insert startup message in current buffer."
464 ;; Insert the message.
465 (setq gnus-xmas-glyph-directory (message-xmas-find-glyph-directory "gnus"))
467 (let ((file (and gnus-xmas-glyph-directory
469 (file-name-as-directory gnus-xmas-glyph-directory)
471 (if (and (featurep 'xpm)
472 (not (equal (device-type) 'tty))
473 file (file-exists-p file))
475 (set-glyph-property gnus-xmas-logo 'image file)
476 (set-glyph-image gnus-xmas-logo file 'global 'x)
479 (set-extent-begin-glyph (make-extent (point) (point)) gnus-xmas-logo)
480 (goto-char (point-min))
482 (insert (make-string (/ (max (- (window-width) (or x 35)) 0) 2)
485 (goto-char (point-min))
486 (let* ((pheight (+ 20 (count-lines (point-min) (point-max))))
487 (wheight (window-height))
488 (rest (- wheight pheight)))
489 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))))
494 _ ___ __ ___ __ _ ___
514 (gnus-indent-rigidly (point-min) (point-max)
515 (/ (max (- (window-width) (or x 46)) 0) 2))
516 (goto-char (point-min))
518 (let* ((pheight (count-lines (point-min) (point-max)))
519 (wheight (window-height))
520 (rest (- wheight pheight)))
521 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))))
523 (goto-char (point-min))
524 (and (search-forward "Praxis" nil t)
525 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
526 (goto-char (point-min))
527 (let* ((mode-string (gnus-group-set-mode-line)))
528 (setq mode-line-buffer-identification
529 (list (concat gnus-version (substring (car mode-string) 4))))
530 (set-buffer-modified-p t))))
535 (defvar gnus-use-toolbar 'default-toolbar
536 "*If nil, do not use a toolbar.
537 If it is non-nil, it must be a toolbar. The five legal values are
538 `default-toolbar', `top-toolbar', `bottom-toolbar',
539 `right-toolbar', and `left-toolbar'.")
541 (defvar gnus-group-toolbar
542 '([gnus-group-exit-icon gnus-group-exit t "Exit Gnus"]
543 [gnus-group-kill-group-icon gnus-group-kill-group t "Kill group"]
544 [gnus-group-get-new-news-icon gnus-group-get-new-news t "Get new news"]
545 [gnus-group-get-new-news-this-group-icon
546 gnus-group-get-new-news-this-group t "Get new news in this group"]
547 [gnus-group-catchup-current-icon
548 gnus-group-catchup-current t "Catchup group"]
549 [gnus-group-describe-group-icon
550 gnus-group-describe-group t "Describe group"])
551 "The group buffer toolbar.")
553 (defvar gnus-summary-toolbar
554 '([gnus-summary-post-news-icon
555 gnus-summary-post-news t "Post an article"]
556 [gnus-summary-save-article-file-icon
557 gnus-summary-save-article-file t "Save article in file"]
558 [gnus-summary-save-article-icon
559 gnus-summary-save-article t "Save article"]
560 [gnus-summary-reply-icon
561 gnus-summary-reply t "Mail a reply"]
562 [gnus-summary-reply-with-original-icon
563 gnus-summary-reply-with-original t "Mail a reply and yank the original"]
564 [gnus-summary-followup-icon
565 gnus-summary-followup t "Post a followup"]
566 [gnus-summary-followup-with-original-icon
567 gnus-summary-followup-with-original t
568 "Post a followup and yank the original"]
569 [gnus-uu-decode-uu-icon
570 gnus-uu-decode-uu t "Decode uuencoded articles"]
571 [gnus-uu-post-news-icon
572 gnus-uu-post-news t "Post an uuencoded article"]
573 [gnus-summary-caesar-message-icon
574 gnus-summary-caesar-message t "Rot 13"]
575 [gnus-summary-cancel-article-icon
576 gnus-summary-cancel-article t "Cancel article"])
577 "The summary buffer toolbar.")
579 (defun gnus-xmas-setup-group-toolbar ()
580 (and gnus-use-toolbar
581 (message-xmas-setup-toolbar gnus-group-toolbar nil "gnus")
582 (set-specifier (symbol-value gnus-use-toolbar)
583 (cons (current-buffer) gnus-group-toolbar))))
585 (defun gnus-xmas-setup-summary-toolbar ()
586 (and gnus-use-toolbar
587 (message-xmas-setup-toolbar gnus-summary-toolbar nil "gnus")
588 (set-specifier (symbol-value gnus-use-toolbar)
589 (cons (current-buffer) gnus-summary-toolbar))))
591 ;; Written by Erik Naggum <erik@naggum.no>.
592 ;; Saved by Steve Baur <steve@miranova.com>.
593 (or (fboundp 'insert-file-contents-literally)
594 (defun insert-file-contents-literally (filename &optional visit beg end replace)
595 "Like `insert-file-contents', q.v., but only reads in the file.
596 A buffer may be modified in several ways after reading into the buffer due
597 to advanced Emacs features, such as file-name-handlers, format decoding,
598 find-file-hooks, etc.
599 This function ensures that none of these modifications will take place."
600 (let ( ; (file-name-handler-alist nil)
602 (after-insert-file-functions nil)
603 (find-buffer-file-type-function
604 (if (fboundp 'find-buffer-file-type)
605 (symbol-function 'find-buffer-file-type)
609 (fset 'find-buffer-file-type (lambda (filename) t))
610 (insert-file-contents filename visit beg end replace))
611 (if find-buffer-file-type-function
612 (fset 'find-buffer-file-type find-buffer-file-type-function)
613 (fmakunbound 'find-buffer-file-type))))))
615 (defun gnus-xmas-find-file-noselect (filename &optional nowarn rawfile)
616 "Read file FILENAME into a buffer and return the buffer.
617 If a buffer exists visiting FILENAME, return that one, but
618 verify that the file has not changed since visited or saved.
619 The buffer is not selected, just returned to the caller."
621 (abbreviate-file-name
622 (expand-file-name filename)))
623 (if (file-directory-p filename)
624 (if find-file-run-dired
625 (dired-noselect filename)
626 (error "%s is a directory." filename))
627 (let* ((buf (get-file-buffer filename))
628 (truename (abbreviate-file-name (file-truename filename)))
629 (number (nthcdr 10 (file-attributes truename)))
630 ;; Find any buffer for a file which has same truename.
631 (other (and (not buf)
632 (if (fboundp 'find-buffer-visiting)
633 (find-buffer-visiting filename)
634 (get-file-buffer filename))))
636 ;; Let user know if there is a buffer with the same truename.
640 (string-equal filename (buffer-file-name other))
641 (message "%s and %s are the same file"
642 filename (buffer-file-name other)))
643 ;; Optionally also find that buffer.
644 (if (or (and (boundp 'find-file-existing-other-name)
645 find-file-existing-other-name)
646 find-file-visit-truename)
650 (verify-visited-file-modtime buf)
651 (cond ((not (file-exists-p filename))
652 (error "File %s no longer exists!" filename))
654 (if (string= (file-name-nondirectory filename)
657 (if (buffer-modified-p buf)
658 "File %s changed on disk. Discard your edits? "
659 "File %s changed on disk. Reread from disk? ")
660 (file-name-nondirectory filename))
662 (if (buffer-modified-p buf)
663 "File %s changed on disk. Discard your edits in %s? "
664 "File %s changed on disk. Reread from disk into %s? ")
665 (file-name-nondirectory filename)
669 (revert-buffer t t)))))
671 ;;; The truename stuff makes this obsolete.
672 ;;; (let* ((link-name (car (file-attributes filename)))
673 ;;; (linked-buf (and (stringp link-name)
674 ;;; (get-file-buffer link-name))))
675 ;;; (if (bufferp linked-buf)
676 ;;; (message "Symbolic link to file in buffer %s"
677 ;;; (buffer-name linked-buf))))
678 (setq buf (create-file-buffer filename))
679 ;; (set-buffer-major-mode buf)
684 (insert-file-contents-literally filename t)
686 ;; Unconditionally set error
689 (insert-file-contents filename t)
691 ;; Run find-file-not-found-hooks until one returns non-nil.
692 (or t ; (run-hook-with-args-until-success 'find-file-not-found-hooks)
693 ;; If they fail too, set error.
695 ;; Find the file's truename, and maybe use that as visited name.
696 (setq buffer-file-truename truename)
697 (setq buffer-file-number number)
698 ;; On VMS, we may want to remember which directory in a search list
699 ;; the file was found in.
700 (and (eq system-type 'vax-vms)
702 (if (string-match ":" (file-name-directory filename))
703 (setq logical (substring (file-name-directory filename)
704 0 (match-beginning 0))))
705 (not (member logical find-file-not-true-dirname-list)))
706 (setq buffer-file-name buffer-file-truename))
707 (if find-file-visit-truename
708 (setq buffer-file-name
710 (expand-file-name buffer-file-truename))))
711 ;; Set buffer's default directory to that of the file.
712 (setq default-directory (file-name-directory filename))
713 ;; Turn off backup files for certain file names. Since
714 ;; this is a permanent local, the major mode won't eliminate it.
715 (and (not (funcall backup-enable-predicate buffer-file-name))
717 (make-local-variable 'backup-inhibited)
718 (setq backup-inhibited t)))
721 (after-find-file error (not nowarn)))))
724 (defun gnus-xmas-mail-strip-quoted-names (address)
725 "Protect mail-strip-quoted-names from NIL input.
726 XEmacs compatibility workaround."
729 (mail-strip-quoted-names address)))
731 ;;; gnus-xmas.el ends here