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
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
28 (eval-when-compile (require 'cl))
29 (defvar menu-bar-mode t)
31 (defvar gnus-xmas-glyph-directory nil
32 "*Directory where Gnus logos and icons are located.
33 If this variable is nil, Gnus will try to locate the directory
36 ;;; Internal variables.
38 (defvar gnus-xmas-logo (make-glyph (make-specifier 'image)))
40 ;; Don't warn about these undefined variables.
42 (defvar gnus-group-mode-hook)
43 (defvar gnus-summary-mode-hook)
44 (defvar gnus-article-mode-hook)
47 (defvar gnus-active-hashtb)
48 (defvar gnus-article-buffer)
49 (defvar gnus-auto-center-summary)
50 (defvar gnus-buffer-list)
51 (defvar gnus-current-headers)
52 (defvar gnus-level-killed)
53 (defvar gnus-level-zombie)
54 (defvar gnus-newsgroup-bookmarks)
55 (defvar gnus-newsgroup-dependencies)
56 (defvar gnus-newsgroup-selected-overlay)
57 (defvar gnus-newsrc-hashtb)
58 (defvar gnus-read-mark)
59 (defvar gnus-refer-article-method)
60 (defvar gnus-reffed-article-number)
61 (defvar gnus-unread-mark)
63 (defvar gnus-view-pseudos)
64 (defvar gnus-view-pseudos-separately)
66 (defvar gnus-zombie-list)
67 ;;defined in gnus-msg.el
68 (defvar gnus-article-copy)
69 (defvar gnus-check-before-posting)
70 ;;defined in gnus-vis.el
71 (defvar gnus-article-button-face)
72 (defvar gnus-article-mouse-face)
73 (defvar gnus-summary-selected-face)
74 (defvar gnus-group-reading-menu)
75 (defvar gnus-group-group-menu)
76 (defvar gnus-group-misc-menu)
77 (defvar gnus-summary-article-menu)
78 (defvar gnus-summary-thread-menu)
79 (defvar gnus-summary-misc-menu)
80 (defvar gnus-summary-post-menu)
81 (defvar gnus-summary-kill-menu)
82 (defvar gnus-article-article-menu)
83 (defvar gnus-article-treatment-menu)
85 (defvar standard-display-table)
87 (defun gnus-xmas-set-text-properties (start end props &optional buffer)
88 "You should NEVER use this function. It is ideologically blasphemous.
89 It is provided only to ease porting of broken FSF Emacs programs."
90 (if (and (stringp buffer) (not (setq buffer (get-buffer buffer))))
92 (map-extents (lambda (extent ignored)
93 (remove-text-properties
95 (list (extent-property extent 'text-prop) nil)
97 buffer start end nil nil 'text-prop)
98 (add-text-properties start end props buffer)))
100 (defun gnus-xmas-highlight-selected-summary ()
101 ;; Highlight selected article in summary buffer
102 (if gnus-summary-selected-face
104 (if gnus-newsgroup-selected-overlay
105 (delete-extent gnus-newsgroup-selected-overlay))
106 (setq gnus-newsgroup-selected-overlay
107 (make-extent (gnus-point-at-bol) (gnus-point-at-eol)))
108 (set-extent-face gnus-newsgroup-selected-overlay
109 gnus-summary-selected-face))))
111 (defun gnus-xmas-summary-recenter ()
112 (let* ((top (cond ((< (window-height) 4) 0)
113 ((< (window-height) 7) 1)
115 (height (- (window-height) 2))
116 (bottom (save-excursion (goto-char (point-max))
117 (forward-line (- height))
119 (window (get-buffer-window (current-buffer))))
121 ;; The user has to want it,
122 gnus-auto-center-summary
123 ;; the article buffer must be displayed,
124 (get-buffer-window gnus-article-buffer)
125 ;; Set the window start to either `bottom', which is the biggest
126 ;; possible valid number, or the second line from the top,
127 ;; whichever is the least.
129 window (min bottom (save-excursion
130 (forward-line (- top)) (point)))))))
132 (defun gnus-xmas-group-remove-excess-properties ()
134 (beg (progn (forward-line -1) (point))))
135 (remove-text-properties (1+ beg) end '(gnus-group nil))
136 (remove-text-properties
138 '(gnus-topic nil gnus-topic-level nil gnus-topic-visible nil))
141 (defun gnus-xmas-topic-remove-excess-properties ()
143 (beg (progn (forward-line -1) (point))))
144 (remove-text-properties beg end '(gnus-group nil))
147 (defun gnus-xmas-extent-start-open (point)
148 (map-extents (lambda (extent arg)
149 (set-extent-property extent 'start-open t))
150 nil point (min (1+ (point)) (point-max))))
152 (defun gnus-xmas-copy-article-buffer (&optional article-buffer)
153 (setq gnus-article-copy (get-buffer-create " *gnus article copy*"))
154 (buffer-disable-undo gnus-article-copy)
155 (or (memq gnus-article-copy gnus-buffer-list)
156 (setq gnus-buffer-list (cons gnus-article-copy gnus-buffer-list)))
157 (let ((article-buffer (or article-buffer gnus-article-buffer))
159 (if (and (get-buffer article-buffer)
160 (buffer-name (get-buffer article-buffer)))
162 (set-buffer article-buffer)
164 (setq buf (buffer-substring (point-min) (point-max)))
165 (set-buffer gnus-article-copy)
167 (insert (format "%s" buf))))))
169 (defun gnus-xmas-article-push-button (event)
170 "Check text under the mouse pointer for a callback function.
171 If the text under the mouse pointer has a `gnus-callback' property,
172 call it with the value of the `gnus-data' text property."
174 (set-buffer (window-buffer (event-window event)))
175 (let* ((pos (event-closest-point event))
176 (data (get-text-property pos 'gnus-data))
177 (fun (get-text-property pos 'gnus-callback)))
178 (if fun (funcall fun data))))
180 (defun gnus-xmas-move-overlay (extent start end &optional buffer)
181 (set-extent-endpoints extent start end))
183 ;; Fixed by Christopher Davis <ckd@loiosh.kei.com>.
184 (defun gnus-xmas-article-add-button (from to fun &optional data)
185 "Create a button between FROM and TO with callback FUN and data DATA."
186 (and gnus-article-button-face
187 (gnus-overlay-put (gnus-make-overlay from to)
188 'face gnus-article-button-face))
192 (and gnus-article-mouse-face
193 (list 'mouse-face gnus-article-mouse-face))
194 (list 'gnus-callback fun)
195 (and data (list 'gnus-data data))
196 (list 'highlight t))))
198 (defun gnus-xmas-window-top-edge (&optional window)
199 (nth 1 (window-pixel-edges window)))
201 (defun gnus-xmas-tree-minimize ()
202 (when (and gnus-tree-minimize-window
203 (not (one-window-p)))
204 (let* ((window-min-height 2)
205 (height (1+ (count-lines (point-min) (point-max))))
206 (min (max (1- window-min-height) height))
207 (tot (if (numberp gnus-tree-minimize-window)
208 (min gnus-tree-minimize-window min)
210 (win (get-buffer-window (current-buffer)))
211 (wh (and win (1- (window-height win)))))
214 (let ((selected (selected-window)))
216 (enlarge-window (- tot wh))
217 (select-window selected))))))
219 ;; Select the lowest window on the frame.
220 (defun gnus-xmas-appt-select-lowest-window ()
221 (let* ((lowest-window (selected-window))
222 (bottom-edge (car (cdr (cdr (cdr (window-pixel-edges))))))
223 (last-window (previous-window))
226 (let* ((this-window (next-window))
227 (next-bottom-edge (car (cdr (cdr (cdr
230 (if (< bottom-edge next-bottom-edge)
232 (setq bottom-edge next-bottom-edge)
233 (setq lowest-window this-window)))
235 (select-window this-window)
236 (if (eq last-window this-window)
238 (select-window lowest-window)
239 (setq window-search nil)))))))
241 (defun gnus-xmas-group-menu-add ()
242 (easy-menu-add gnus-group-reading-menu)
243 (easy-menu-add gnus-group-group-menu)
244 (easy-menu-add gnus-group-misc-menu))
246 (defun gnus-xmas-summary-menu-add ()
247 (easy-menu-add gnus-summary-article-menu)
248 (easy-menu-add gnus-summary-thread-menu)
249 (easy-menu-add gnus-summary-misc-menu)
250 (easy-menu-add gnus-summary-post-menu)
251 (easy-menu-add gnus-summary-kill-menu))
253 (defun gnus-xmas-article-menu-add ()
254 (easy-menu-add gnus-article-article-menu)
255 (easy-menu-add gnus-article-treatment-menu))
257 (defun gnus-xmas-read-event-char ()
258 "Get the next event."
259 (let ((event (next-event)))
260 ;; We junk all non-key events. Is this naughty?
261 (while (not (key-press-event-p event))
262 (setq event (next-event)))
263 (cons (and (key-press-event-p event)
264 ; (numberp (event-key event))
265 (event-to-character event))
268 (defun gnus-xmas-seconds-since-epoch (date)
269 "Return a floating point number that says how many seconds have lapsed between Jan 1 12:00:00 1970 and DATE."
270 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
271 (timezone-parse-date date)))
272 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
274 (aref (timezone-parse-date date) 3))))
275 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
276 (timezone-parse-date "Jan 1 12:00:00 1970")))
277 (tday (- (timezone-absolute-from-gregorian
278 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
279 (timezone-absolute-from-gregorian
280 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
283 (* (float (nth 0 ttime)) 60 60)
284 (* (float tday) 60 60 24))))
286 (defun gnus-xmas-define ()
287 (setq gnus-mouse-2 [button2])
289 (or (memq 'underline (list-faces))
290 (and (fboundp 'make-face)
291 (funcall (intern "make-face") 'underline)))
292 ;; Must avoid calling set-face-underline-p directly, because it
293 ;; is a defsubst in emacs19, and will make the .elc files non
295 (or (face-differs-from-default-p 'underline)
296 (funcall (intern "set-face-underline-p") 'underline t))
298 (fset 'gnus-make-overlay 'make-extent)
299 (fset 'gnus-overlay-put 'set-extent-property)
300 (fset 'gnus-move-overlay 'gnus-xmas-move-overlay)
301 (fset 'gnus-overlay-end 'extent-end-position)
302 (fset 'gnus-extent-detached-p 'extent-detached-p)
304 (fset 'set-text-properties 'gnus-xmas-set-text-properties)
306 (fset 'nnheader-find-file-noselect 'gnus-xmas-find-file-noselect)
308 (or (boundp 'standard-display-table) (setq standard-display-table nil))
310 (defvar gnus-mouse-face-prop 'highlight)
312 (unless (fboundp 'encode-time)
313 (defun encode-time (sec minute hour day month year &optional zone)
315 (gnus-xmas-seconds-since-epoch
316 (timezone-make-arpa-date
317 year month day (timezone-make-time-string hour minute sec)
319 (list (floor (/ seconds (expt 2 16)))
320 (round (mod seconds (expt 2 16)))))))
322 (defun gnus-byte-code (func)
323 "Return a form that can be `eval'ed based on FUNC."
324 (let ((fval (symbol-function func)))
325 (if (byte-code-function-p fval)
327 (cons 'progn (cdr (cdr fval))))))
329 ;; Fix by "jeff (j.d.) sparkes" <jsparkes@bnr.ca>.
330 (defvar gnus-display-type (device-class)
331 "A symbol indicating the display Emacs is running under.
332 The symbol should be one of `color', `grayscale' or `mono'. If Emacs
333 guesses this display attribute wrongly, either set this variable in
334 your `~/.emacs' or set the resource `Emacs.displayType' in your
335 `~/.Xdefaults'. See also `gnus-background-mode'.
337 This is a meta-variable that will affect what default values other
338 variables get. You would normally not change this variable, but
339 pounce directly on the real variables themselves.")
342 (or (fboundp 'x-color-values)
343 (fset 'x-color-values
345 (color-instance-rgb-components
346 (make-color-instance color)))))
348 (defvar gnus-background-mode
351 (x-get-resource ".backgroundMode" "BackgroundMode" 'string)
353 (params (frame-parameters)))
354 (cond (bg-resource (intern (downcase bg-resource)))
355 ((and (assq 'background-color params)
356 (< (apply '+ (x-color-values
357 (cdr (assq 'background-color params))))
358 (/ (apply '+ (x-color-values "white")) 3)))
361 "A symbol indicating the Emacs background brightness.
362 The symbol should be one of `light' or `dark'.
363 If Emacs guesses this frame attribute wrongly, either set this variable in
364 your `~/.emacs' or set the resource `Emacs.backgroundMode' in your
366 See also `gnus-display-type'.
368 This is a meta-variable that will affect what default values other
369 variables get. You would normally not change this variable, but
370 pounce directly on the real variables themselves.")
375 (defun gnus-xmas-redefine ()
376 "Redefine lots of Gnus functions for XEmacs."
377 (fset 'gnus-summary-make-display-table (lambda () nil))
378 (fset 'gnus-visual-turn-off-edit-menu 'identity)
379 (fset 'gnus-highlight-selected-summary
380 'gnus-xmas-highlight-selected-summary)
381 (fset 'gnus-summary-recenter 'gnus-xmas-summary-recenter)
382 (fset 'gnus-group-remove-excess-properties
383 'gnus-xmas-group-remove-excess-properties)
384 (fset 'gnus-topic-remove-excess-properties
385 'gnus-xmas-topic-remove-excess-properties)
386 (fset 'gnus-extent-start-open 'gnus-xmas-extent-start-open)
387 (fset 'gnus-copy-article-buffer 'gnus-xmas-copy-article-buffer)
388 (fset 'gnus-article-push-button 'gnus-xmas-article-push-button)
389 (fset 'gnus-article-add-button 'gnus-xmas-article-add-button)
390 (fset 'gnus-window-top-edge 'gnus-xmas-window-top-edge)
391 (fset 'set-text-properties 'gnus-xmas-set-text-properties)
392 (fset 'gnus-read-event-char 'gnus-xmas-read-event-char)
393 (fset 'gnus-group-startup-message 'gnus-xmas-group-startup-message)
394 (fset 'gnus-tree-minimize 'gnus-xmas-tree-minimize)
396 (or (fboundp 'appt-select-lowest-window)
397 (fset 'appt-select-lowest-window
398 'gnus-xmas-appt-select-lowest-window))
400 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
401 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
402 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add)
404 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar)
405 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar))
408 ;;; XEmacs logo and toolbar.
410 (defun gnus-xmas-find-glyph-directory ()
411 (or gnus-xmas-glyph-directory ; We have a dir already...
412 (let ((path load-path)
414 ;; We try to find the dir by looking at the load path,
415 ;; stripping away the last component and adding "etc/".
418 (file-name-directory (directory-file-name (car path)))
420 (if (and (file-exists-p dir)
421 (file-directory-p dir)
422 (file-exists-p (concat dir "gnus-group-exit-icon-up.xpm")))
423 (setq gnus-xmas-glyph-directory dir
425 (setq path (cdr path))))
426 gnus-xmas-glyph-directory)))
428 (defun gnus-xmas-group-startup-message (&optional x y)
429 "Insert startup message in current buffer."
430 ;; Insert the message.
431 (gnus-xmas-find-glyph-directory)
433 (let ((file (and gnus-xmas-glyph-directory
435 (file-name-as-directory gnus-xmas-glyph-directory)
437 (if (and (featurep 'xpm)
438 (not (equal (device-type) 'tty))
439 file (file-exists-p file))
441 (set-glyph-property gnus-xmas-logo 'image file)
442 (set-glyph-image gnus-xmas-logo file 'global 'x)
445 (set-extent-begin-glyph (make-extent (point) (point)) gnus-xmas-logo)
446 (goto-char (point-min))
448 (insert (make-string (/ (max (- (window-width) (or x 35)) 0) 2)
451 (goto-char (point-min))
452 (let* ((pheight (+ 20 (count-lines (point-min) (point-max))))
453 (wheight (window-height))
454 (rest (- wheight pheight)))
455 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))))
460 _ ___ __ ___ __ _ ___
480 (gnus-indent-rigidly (point-min) (point-max)
481 (/ (max (- (window-width) (or x 46)) 0) 2))
482 (goto-char (point-min))
484 (let* ((pheight (count-lines (point-min) (point-max)))
485 (wheight (window-height))
486 (rest (- wheight pheight)))
487 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))))
489 (goto-char (point-min))
490 (and (search-forward "Praxis" nil t)
491 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
492 (goto-char (point-min))
493 (let* ((mode-string (gnus-group-set-mode-line)))
494 (setq mode-line-buffer-identification
495 (list (concat gnus-version (substring (car mode-string) 4))))
496 (set-buffer-modified-p t))))
501 (defvar gnus-use-toolbar 'default-toolbar
502 "*If nil, do not use a toolbar.
503 If it is non-nil, it must be a toolbar. The five legal values are
504 `default-toolbar', `top-toolbar', `bottom-toolbar',
505 `right-toolbar', and `left-toolbar'.")
507 (defvar gnus-group-toolbar
508 '([gnus-group-exit-icon gnus-group-exit t "Exit Gnus"]
509 [gnus-group-kill-group-icon gnus-group-kill-group t "Kill group"]
510 [gnus-group-get-new-news-icon gnus-group-get-new-news t "Get new news"]
511 [gnus-group-get-new-news-this-group-icon
512 gnus-group-get-new-news-this-group t "Get new news in this group"]
513 [gnus-group-catchup-current-icon
514 gnus-group-catchup-current t "Catchup group"]
515 [gnus-group-describe-group-icon
516 gnus-group-describe-group t "Describe group"])
517 "The group buffer toolbar.")
519 (defvar gnus-summary-toolbar
520 '([gnus-summary-post-news-icon
521 gnus-summary-post-news t "Post an article"]
522 [gnus-summary-save-article-file-icon
523 gnus-summary-save-article-file t "Save article in file"]
524 [gnus-summary-save-article-icon
525 gnus-summary-save-article t "Save article"]
526 [gnus-summary-reply-icon
527 gnus-summary-reply t "Mail a reply"]
528 [gnus-summary-reply-with-original-icon
529 gnus-summary-reply-with-original t "Mail a reply and yank the original"]
530 [gnus-summary-followup-icon
531 gnus-summary-followup t "Post a followup"]
532 [gnus-summary-followup-with-original-icon
533 gnus-summary-followup-with-original t
534 "Post a followup and yank the original"]
535 [gnus-uu-decode-uu-icon
536 gnus-uu-decode-uu t "Decode uuencoded articles"]
537 [gnus-uu-post-news-icon
538 gnus-uu-post-news t "Post an uuencoded article"]
539 [gnus-summary-caesar-message-icon
540 gnus-summary-caesar-message t "Rot 13"]
541 [gnus-summary-cancel-article-icon
542 gnus-summary-cancel-article t "Cancel article"])
543 "The summary buffer toolbar.")
545 (defun gnus-xmas-setup-toolbar (bar &optional force)
546 (let ((dir (gnus-xmas-find-glyph-directory))
547 icon up down disabled name)
551 (boundp (aref (car bar) 0)))
554 (setq icon (aref (car bar) 0)
555 name (symbol-name icon)
557 (setq up (concat dir name "-up.xpm"))
558 (setq down (concat dir name "-down.xpm"))
559 (setq disabled (concat dir name "-disabled.xpm"))
560 (if (not (file-exists-p up))
562 (set icon (toolbar-make-button-list
563 up (and (file-exists-p down) down)
564 (and (file-exists-p disabled) disabled)))))
567 (defun gnus-xmas-setup-group-toolbar ()
568 (and gnus-use-toolbar
569 (gnus-xmas-setup-toolbar gnus-group-toolbar)
570 (set-specifier (symbol-value gnus-use-toolbar)
571 (cons (current-buffer) gnus-group-toolbar))))
573 (defun gnus-xmas-setup-summary-toolbar ()
574 (and gnus-use-toolbar
575 (gnus-xmas-setup-toolbar gnus-summary-toolbar)
576 (set-specifier (symbol-value gnus-use-toolbar)
577 (cons (current-buffer) gnus-summary-toolbar))))
579 ;; Written by Erik Naggum <erik@naggum.no>.
580 ;; Saved by Steve Baur <steve@miranova.com>.
581 (defun insert-file-contents-literally (filename &optional visit beg end replace)
582 "Like `insert-file-contents', q.v., but only reads in the file.
583 A buffer may be modified in several ways after reading into the buffer due
584 to advanced Emacs features, such as file-name-handlers, format decoding,
585 find-file-hooks, etc.
586 This function ensures that none of these modifications will take place."
587 (let ( ; (file-name-handler-alist nil)
589 (after-insert-file-functions nil)
590 (find-buffer-file-type-function
591 (if (fboundp 'find-buffer-file-type)
592 (symbol-function 'find-buffer-file-type)
596 (fset 'find-buffer-file-type (lambda (filename) t))
597 (insert-file-contents filename visit beg end replace))
598 (if find-buffer-file-type-function
599 (fset 'find-buffer-file-type find-buffer-file-type-function)
600 (fmakunbound 'find-buffer-file-type)))))
602 (defun gnus-xmas-find-file-noselect (filename &optional nowarn rawfile)
603 "Read file FILENAME into a buffer and return the buffer.
604 If a buffer exists visiting FILENAME, return that one, but
605 verify that the file has not changed since visited or saved.
606 The buffer is not selected, just returned to the caller."
608 (abbreviate-file-name
609 (expand-file-name filename)))
610 (if (file-directory-p filename)
611 (if find-file-run-dired
612 (dired-noselect filename)
613 (error "%s is a directory." filename))
614 (let* ((buf (get-file-buffer filename))
615 (truename (abbreviate-file-name (file-truename filename)))
616 (number (nthcdr 10 (file-attributes truename)))
617 ;; Find any buffer for a file which has same truename.
618 (other (and (not buf)
619 (if (fboundp 'find-buffer-visiting)
620 (find-buffer-visiting filename)
621 (get-file-buffer filename))))
623 ;; Let user know if there is a buffer with the same truename.
627 (string-equal filename (buffer-file-name other))
628 (message "%s and %s are the same file"
629 filename (buffer-file-name other)))
630 ;; Optionally also find that buffer.
631 (if (or (and (boundp 'find-file-existing-other-name)
632 find-file-existing-other-name)
633 find-file-visit-truename)
637 (verify-visited-file-modtime buf)
638 (cond ((not (file-exists-p filename))
639 (error "File %s no longer exists!" filename))
641 (if (string= (file-name-nondirectory filename)
644 (if (buffer-modified-p buf)
645 "File %s changed on disk. Discard your edits? "
646 "File %s changed on disk. Reread from disk? ")
647 (file-name-nondirectory filename))
649 (if (buffer-modified-p buf)
650 "File %s changed on disk. Discard your edits in %s? "
651 "File %s changed on disk. Reread from disk into %s? ")
652 (file-name-nondirectory filename)
656 (revert-buffer t t)))))
658 ;;; The truename stuff makes this obsolete.
659 ;;; (let* ((link-name (car (file-attributes filename)))
660 ;;; (linked-buf (and (stringp link-name)
661 ;;; (get-file-buffer link-name))))
662 ;;; (if (bufferp linked-buf)
663 ;;; (message "Symbolic link to file in buffer %s"
664 ;;; (buffer-name linked-buf))))
665 (setq buf (create-file-buffer filename))
666 ;; (set-buffer-major-mode buf)
671 (insert-file-contents-literally filename t)
673 ;; Unconditionally set error
676 (insert-file-contents filename t)
678 ;; Run find-file-not-found-hooks until one returns non-nil.
679 (or t ; (run-hook-with-args-until-success 'find-file-not-found-hooks)
680 ;; If they fail too, set error.
682 ;; Find the file's truename, and maybe use that as visited name.
683 (setq buffer-file-truename truename)
684 (setq buffer-file-number number)
685 ;; On VMS, we may want to remember which directory in a search list
686 ;; the file was found in.
687 (and (eq system-type 'vax-vms)
689 (if (string-match ":" (file-name-directory filename))
690 (setq logical (substring (file-name-directory filename)
691 0 (match-beginning 0))))
692 (not (member logical find-file-not-true-dirname-list)))
693 (setq buffer-file-name buffer-file-truename))
694 (if find-file-visit-truename
695 (setq buffer-file-name
697 (expand-file-name buffer-file-truename))))
698 ;; Set buffer's default directory to that of the file.
699 (setq default-directory (file-name-directory filename))
700 ;; Turn off backup files for certain file names. Since
701 ;; this is a permanent local, the major mode won't eliminate it.
702 (and (not (funcall backup-enable-predicate buffer-file-name))
704 (make-local-variable 'backup-inhibited)
705 (setq backup-inhibited t)))
708 (after-find-file error (not nowarn)))))
712 ;;; gnus-xmas.el ends here