1 ;;; gnus-spec.el --- format spec functions for Gnus
3 ;; Copyright (C) 1996-2011 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;; For Emacs <22.2 and XEmacs.
29 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
30 (eval-when-compile (require 'cl))
31 (defvar gnus-newsrc-file-version)
35 (defcustom gnus-use-correct-string-widths (featurep 'xemacs)
36 "*If non-nil, use correct functions for dealing with wide characters."
41 (defcustom gnus-make-format-preserve-properties (featurep 'xemacs)
42 "*If non-nil, use a replacement `format' function which preserves
43 text properties. This is only needed on XEmacs, as Emacs does this anyway."
48 ;;; Internal variables.
50 (defvar gnus-summary-mark-positions nil)
51 (defvar gnus-group-mark-positions nil)
52 (defvar gnus-group-indentation "")
54 ;; Format specs. The chunks below are the machine-generated forms
55 ;; that are to be evaled as the result of the default format strings.
56 ;; We write them in here to get them byte-compiled. That way the
57 ;; default actions will be quite fast, while still retaining the full
58 ;; flexibility of the user-defined format specs.
60 ;; First we have lots of dummy defvars to let the compiler know these
61 ;; are really dynamic variables.
63 (defvar gnus-tmp-unread)
64 (defvar gnus-tmp-replied)
65 (defvar gnus-tmp-score-char)
66 (defvar gnus-tmp-indentation)
67 (defvar gnus-tmp-opening-bracket)
68 (defvar gnus-tmp-lines)
69 (defvar gnus-tmp-name)
70 (defvar gnus-tmp-closing-bracket)
71 (defvar gnus-tmp-subject-or-nil)
72 (defvar gnus-tmp-subject)
73 (defvar gnus-tmp-marked)
74 (defvar gnus-tmp-marked-mark)
75 (defvar gnus-tmp-subscribed)
76 (defvar gnus-tmp-process-marked)
77 (defvar gnus-tmp-number-of-unread)
78 (defvar gnus-tmp-group-name)
79 (defvar gnus-tmp-group)
80 (defvar gnus-tmp-article-number)
81 (defvar gnus-tmp-unread-and-unselected)
82 (defvar gnus-tmp-news-method)
83 (defvar gnus-tmp-news-server)
84 (defvar gnus-tmp-article-number)
85 (defvar gnus-mouse-face)
86 (defvar gnus-mouse-face-prop)
87 (defvar gnus-tmp-header)
88 (defvar gnus-tmp-from)
90 (declare-function gnus-summary-from-or-to-or-newsgroups "gnus-sum"
91 (header gnus-tmp-from))
93 (defmacro gnus-lrm-string-p (string)
94 (if (fboundp 'string-mark-left-to-rigth)
95 `(eq (aref ,string (1- (length ,string))) 8206)
98 (defvar gnus-lrm-string (if (ignore-errors (string 8206))
99 (propertize (string 8206) 'invisible t)
102 (defun gnus-summary-line-format-spec ()
103 (insert gnus-tmp-unread gnus-tmp-replied
104 gnus-tmp-score-char gnus-tmp-indentation)
105 (gnus-put-text-property
109 (format "%c%4s: %-23s%c" gnus-tmp-opening-bracket gnus-tmp-lines
112 (gnus-summary-from-or-to-or-newsgroups
113 gnus-tmp-header gnus-tmp-from))))
114 (if (> (length val) 23)
115 (if (gnus-lrm-string-p val)
116 (concat (substring val 0 23) gnus-lrm-string)
117 (substring val 0 23))
119 gnus-tmp-closing-bracket))
121 gnus-mouse-face-prop gnus-mouse-face)
122 (insert " " gnus-tmp-subject-or-nil "\n"))
124 (defvar gnus-summary-line-format-spec
125 (gnus-byte-code 'gnus-summary-line-format-spec))
127 (defun gnus-summary-dummy-line-format-spec ()
129 (gnus-put-text-property
134 gnus-mouse-face-prop gnus-mouse-face)
135 (insert " " gnus-tmp-subject "\n"))
137 (defvar gnus-summary-dummy-line-format-spec
138 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
140 (defun gnus-group-line-format-spec ()
141 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
142 gnus-tmp-process-marked
143 gnus-group-indentation
144 (format "%5s: " gnus-tmp-number-of-unread))
145 (gnus-put-text-property
148 (insert gnus-tmp-group "\n")
150 gnus-mouse-face-prop gnus-mouse-face))
151 (defvar gnus-group-line-format-spec
152 (gnus-byte-code 'gnus-group-line-format-spec))
154 (defvar gnus-format-specs
155 `((version . ,emacs-version)
156 (gnus-version . ,(gnus-continuum-version))
157 (group "%M\%S\%p\%P\%5y: %(%g%)\n" ,gnus-group-line-format-spec)
158 (summary-dummy "* %(: :%) %S\n"
159 ,gnus-summary-dummy-line-format-spec)
160 (summary "%U%R%z%I%(%[%4L: %-23,23f%]%) %s\n"
161 ,gnus-summary-line-format-spec))
162 "Alist of format specs.")
164 (defvar gnus-default-format-specs gnus-format-specs)
166 (defvar gnus-article-mode-line-format-spec nil)
167 (defvar gnus-summary-mode-line-format-spec nil)
168 (defvar gnus-group-mode-line-format-spec nil)
170 ;;; Phew. All that gruft is over with, fortunately.
173 (defun gnus-update-format (var)
174 "Update the format specification near point."
179 ;; Find the end of the current word.
180 (re-search-forward "[ \t\n]" nil t)
182 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
184 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
185 (match-string 1 var))))
186 (entry (assq type gnus-format-specs))
189 (setq gnus-format-specs (delq entry gnus-format-specs)))
191 (intern (format "%s-spec" var))
192 (gnus-parse-format (setq value (symbol-value (intern var)))
193 (symbol-value (intern (format "%s-alist" var)))
194 (not (string-match "mode" var))))
195 (setq spec (symbol-value (intern (format "%s-spec" var))))
196 (push (list type value spec) gnus-format-specs)
198 (pop-to-buffer "*Gnus Format*")
200 (lisp-interaction-mode)
201 (insert (gnus-pp-to-string spec))))
203 (defun gnus-update-format-specifications (&optional force &rest types)
204 "Update all (necessary) format specifications.
205 Return a list of updated types."
206 ;; Make the indentation array.
207 ;; See whether all the stored info needs to be flushed.
209 (not gnus-newsrc-file-version)
210 (not (equal (gnus-continuum-version)
211 (gnus-continuum-version gnus-newsrc-file-version)))
212 (not (equal emacs-version
213 (cdr (assq 'version gnus-format-specs)))))
214 (setq gnus-format-specs nil))
215 ;; Flush the group format spec cache if there's the grouplens stuff
216 ;; or it doesn't support decoded group names.
217 (when (memq 'group types)
218 (let* ((spec (assq 'group gnus-format-specs))
219 (sspec (gnus-prin1-to-string (nth 2 spec))))
220 (when (or (string-match " gnus-tmp-grouplens[ )]" sspec)
221 (not (string-match " gnus-tmp-decoded-group[ )]" sspec)))
222 (setq gnus-format-specs (delq spec gnus-format-specs)))))
224 ;; Go through all the formats and see whether they need updating.
225 (let (new-format entry type val updated)
226 (while (setq type (pop types))
227 ;; Jump to the proper buffer to find out the value of the
228 ;; variable, if possible. (It may be buffer-local.)
230 (let ((buffer (intern (format "gnus-%s-buffer" type))))
231 (when (and (boundp buffer)
232 (setq val (symbol-value buffer))
233 (gnus-buffer-exists-p val))
235 (setq new-format (symbol-value
236 (intern (format "gnus-%s-line-format" type)))))
237 (setq entry (cdr (assq type gnus-format-specs)))
239 (equal (car entry) new-format))
240 ;; Use the old format.
241 (set (intern (format "gnus-%s-line-format-spec" type))
243 ;; This is a new format.
245 (if (not (stringp new-format))
246 ;; This is a function call or something.
248 ;; This is a "real" format.
252 (intern (format "gnus-%s-line-format-alist" type)))
253 (not (string-match "mode$" (symbol-name type))))))
254 ;; Enter the new format spec into the list.
257 (setcar (cdr entry) val)
258 (setcar entry new-format))
259 (push (list type new-format val) gnus-format-specs))
260 (set (intern (format "gnus-%s-line-format-spec" type)) val)
261 (push type updated))))
263 (unless (assq 'version gnus-format-specs)
264 (push (cons 'version emacs-version) gnus-format-specs))
267 (defcustom gnus-mouse-face-0 'highlight
268 "The \"%(hello%)\" face."
272 (defcustom gnus-mouse-face-1 'highlight
273 "The \"%1(hello%)\" face."
277 (defcustom gnus-mouse-face-2 'highlight
278 "The \"%2(hello%)\" face."
282 (defcustom gnus-mouse-face-3 'highlight
283 "The \"%3(hello%)\" face."
287 (defcustom gnus-mouse-face-4 'highlight
288 "The \"%4(hello%)\" face."
292 (defun gnus-mouse-face-function (form type)
293 `(gnus-put-text-property
294 (point) (progn ,@form (point))
298 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
300 (defcustom gnus-face-0 'bold
301 "The \"%{hello%}\" face."
305 (defcustom gnus-face-1 'italic
306 "The \"%1{hello%}\" face."
310 (defcustom gnus-face-2 'bold-italic
311 "The \"%2{hello%}\" face."
315 (defcustom gnus-face-3 'bold
316 "The \"%3{hello%}\" face."
320 (defcustom gnus-face-4 'bold
321 "The \"%4{hello%}\" face."
325 (defun gnus-face-face-function (form type)
326 `(gnus-add-text-properties
327 (point) (progn ,@form (point))
328 '(gnus-face t face ,(symbol-value (intern (format "gnus-face-%d" type))))))
330 (defun gnus-balloon-face-function (form type)
331 `(gnus-put-text-property
332 (point) (progn ,@form (point))
333 ,(if (fboundp 'balloon-help-mode)
336 ,(intern (format "gnus-balloon-face-%d" type))))
338 (defun gnus-spec-tab (column)
340 `(insert-char ? (max (- ,column (current-column)) 0))
341 (let ((column (abs column)))
342 `(if (> (current-column) ,column)
344 (if (= (move-to-column ,column) ,column)
345 (delete-region (point) end)
346 (delete-region (1- (point)) end)
348 (insert-char ? (max (- ,column (current-column)) 0))))))
350 (defun gnus-correct-length (string)
351 "Return the correct width of STRING."
352 (apply #'+ (mapcar #'char-width string)))
354 (defun gnus-correct-substring (string start &optional end)
359 (length (length string))
360 (string (concat string "\0")))
361 ;; Find the start position.
362 (while (and (< seek length)
364 (incf wseek (char-width (aref string seek)))
367 ;; Find the end position.
368 (while (and (<= seek length)
371 (incf wseek (char-width (aref string seek)))
374 (substring string wstart (1- wend))))
376 (defun gnus-string-width-function ()
378 (gnus-use-correct-string-widths
379 'gnus-correct-length)
380 ((fboundp 'string-width)
385 (defun gnus-substring-function ()
387 (gnus-use-correct-string-widths
388 'gnus-correct-substring)
389 ((fboundp 'string-width)
390 'gnus-correct-substring)
394 (defun gnus-tilde-max-form (el max-width)
395 "Return a form that limits EL to MAX-WIDTH."
396 (let ((max (abs max-width))
397 (length-fun (gnus-string-width-function))
398 (substring-fun (gnus-substring-function)))
400 `(if (> (,length-fun ,el) ,max)
402 `(,substring-fun ,el (- (,length-fun ,el) ,max))
403 `(if (gnus-lrm-string-p ,el)
404 (concat (,substring-fun ,el 0 ,max) ,gnus-lrm-string)
405 (,substring-fun ,el 0 ,max)))
407 `(let ((val (eval ,el)))
408 (if (> (,length-fun val) ,max)
410 `(,substring-fun val (- (,length-fun val) ,max))
411 `(if (gnus-lrm-string-p val)
412 (concat (,substring-fun val 0 ,max) ,gnus-lrm-string)
413 (,substring-fun val 0 ,max)))
416 (defun gnus-tilde-cut-form (el cut-width)
417 "Return a form that cuts CUT-WIDTH off of EL."
418 (let ((cut (abs cut-width))
419 (length-fun (gnus-string-width-function))
420 (substring-fun (gnus-substring-function)))
422 `(if (> (,length-fun ,el) ,cut)
424 `(,substring-fun ,el 0 (- (,length-fun ,el) ,cut))
425 `(,substring-fun ,el ,cut))
427 `(let ((val (eval ,el)))
428 (if (> (,length-fun val) ,cut)
430 `(,substring-fun val 0 (- (,length-fun val) ,cut))
431 `(,substring-fun val ,cut))
434 (defun gnus-tilde-ignore-form (el ignore-value)
435 "Return a form that is blank when EL is IGNORE-VALUE."
437 `(if (equal ,el ,ignore-value)
439 `(let ((val (eval ,el)))
440 (if (equal val ,ignore-value)
443 (defun gnus-pad-form (el pad-width)
444 "Return a form that pads EL to PAD-WIDTH accounting for multi-column
445 characters correctly. This is because `format' may pad to columns or to
446 characters when given a pad value."
447 (let ((pad (abs pad-width))
448 (side (< 0 pad-width))
449 (length-fun (gnus-string-width-function)))
451 `(let ((need (- ,pad (,length-fun ,el))))
453 (concat ,(when side '(make-string need ?\ ))
455 ,(when (not side) '(make-string need ?\ )))
457 `(let* ((val (eval ,el))
458 (need (- ,pad (,length-fun val))))
460 (concat ,(when side '(make-string need ?\ ))
462 ,(when (not side) '(make-string need ?\ )))
465 (defun gnus-parse-format (format spec-alist &optional insert)
466 ;; This function parses the FORMAT string with the help of the
467 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
468 ;; string. If the FORMAT string contains the specifiers %( and %)
469 ;; the text between them will have the mouse-face text property.
470 ;; If the FORMAT string contains the specifiers %[ and %], the text between
471 ;; them will have the balloon-help text property.
472 (let ((case-fold-search nil))
474 "\\`\\(.*\\)%[0-9]?[{(«]\\(.*\\)%[0-9]?[»})]\\(.*\n?\\)\\'\\|%[-0-9]*=\\|%[-0-9]*\\*"
476 (gnus-parse-complex-format format spec-alist)
477 ;; This is a simple format.
478 (gnus-parse-simple-format format spec-alist insert))))
480 (defun gnus-parse-complex-format (format spec-alist)
481 (let ((cursor-spec nil))
483 (gnus-set-work-buffer)
485 (goto-char (point-min))
486 (while (re-search-forward "\"" nil t)
487 (replace-match "\\\"" nil t))
488 (goto-char (point-min))
490 ;; Convert all font specs into font spec lists.
491 (while (re-search-forward "%\\([0-9]+\\)?\\([«»{}()]\\)" nil t)
492 (let ((number (if (match-beginning 1)
493 (match-string 1) "0"))
494 (delim (aref (match-string 2) 0)))
495 (if (or (= delim ?\()
498 (replace-match (concat "\"("
499 (cond ((= delim ?\() "mouse")
500 ((= delim ?\{) "face")
504 (replace-match "\")\""))))
505 (goto-char (point-max))
507 ;; Convert point position commands.
508 (goto-char (point-min))
509 (let ((case-fold-search nil))
510 (while (re-search-forward "%\\([-0-9]+\\)?\\*" nil t)
511 (replace-match "\"(point)\"" t t)
512 (setq cursor-spec t)))
513 ;; Convert TAB commands.
514 (goto-char (point-min))
515 (while (re-search-forward "%\\([-0-9]+\\)=" nil t)
516 (replace-match (format "\"(tab %s)\"" (match-string 1)) t t))
517 ;; Convert the buffer into the spec.
518 (goto-char (point-min))
519 (let ((form (read (current-buffer))))
521 `(let (gnus-position)
522 ,@(gnus-complex-form-to-spec form spec-alist)
524 (gnus-put-text-property gnus-position (1+ gnus-position)
527 ,@(gnus-complex-form-to-spec form spec-alist)))))))
529 (defun gnus-complex-form-to-spec (form spec-alist)
535 (gnus-parse-simple-format sform spec-alist t))
536 ((eq (car sform) 'point)
537 '(setq gnus-position (point)))
538 ((eq (car sform) 'tab)
539 (gnus-spec-tab (cadr sform)))
541 (funcall (intern (format "gnus-%s-face-function" (car sform)))
542 (gnus-complex-form-to-spec (cddr sform) spec-alist)
547 (defun gnus-xmas-format (fstring &rest args)
548 "A version of `format' which preserves text properties.
550 Required for XEmacs, where the built in `format' function strips all text
551 properties from both the format string and any inserted strings.
553 Only supports the format sequence %s, and %% for inserting
554 literal % characters. A pad width and an optional - (to right pad)
555 are supported for %s."
556 (let ((re "%%\\|%\\(-\\)?\\([1-9][0-9]*\\)?s")
560 (goto-char (point-min))
561 (while (re-search-forward re nil t)
562 (goto-char (match-end 0))
564 ((string= (match-string 0) "%%")
568 (error 'wrong-number-of-arguments #'my-format n fstring))
569 (let* ((minlen (string-to-number (or (match-string 2) "")))
571 (str (if (stringp arg) arg (format "%s" arg)))
572 (lpad (null (match-string 1)))
573 (padlen (max 0 (- minlen (length str)))))
575 (if lpad (insert-char ?\ padlen))
577 (unless lpad (insert-char ?\ padlen))
578 (setq args (cdr args))))))
581 (defun gnus-parse-simple-format (format spec-alist &optional insert)
582 ;; This function parses the FORMAT string with the help of the
583 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
586 spec flist fstring elem result dontinsert user-defined
587 type value pad-width spec-beg cut-width ignore-value
588 tilde-form tilde elem-type extended-spec)
590 (gnus-set-work-buffer)
592 (goto-char (point-min))
593 (while (re-search-forward "%" nil t)
594 (setq user-defined nil
602 (setq spec-beg (1- (point)))
604 ;; Parse this spec fully.
607 ((looking-at "\\([-.0-9]+\\)\\(,[-0-9]+\\)?")
608 (setq pad-width (string-to-number (match-string 1)))
609 (when (match-beginning 2)
610 (setq max-width (string-to-number (buffer-substring
611 (1+ (match-beginning 2))
613 (goto-char (match-end 0)))
616 (setq tilde (read (current-buffer))
620 ((memq type '(pad pad-left))
621 (setq pad-width value))
622 ((eq type 'pad-right)
623 (setq pad-width (- value)))
624 ((memq type '(max-right max))
625 (setq max-width value))
627 (setq max-width (- value)))
628 ((memq type '(cut cut-left))
629 (setq cut-width value))
630 ((eq type 'cut-right)
631 (setq cut-width (- value)))
634 (if (stringp value) value (format "%s" value))))
636 (setq tilde-form value))
638 (error "Unknown tilde type: %s" tilde)))
643 ;; User-defined spec -- find the spec name.
644 ((eq (setq spec (char-after)) ?u)
646 (when (and (eq (setq user-defined (char-after)) ?&)
647 (looking-at "&\\([^;]+\\);"))
648 (setq user-defined (match-string 1))
649 (goto-char (match-end 1))))
651 ((and (eq spec ?&) (looking-at "&\\([^;]+\\);"))
652 (setq extended-spec (intern (match-string 1)))
653 (goto-char (match-end 1))))
655 (delete-region spec-beg (point))
657 ;; Now we have all the relevant data on this spec, so
658 ;; we start doing stuff.
661 ;; "%%" just results in a "%".
666 (setq elem (list tilde-form ?s)))
667 ;; Treat user defined format specifiers specially.
671 (list (intern (format
672 (if (stringp user-defined)
673 "gnus-user-format-function-%s"
674 "gnus-user-format-function-%c")
678 ;; Find the specification from `spec-alist'.
679 ((setq elem (cdr (assq (or extended-spec spec) spec-alist))))
680 ;; We used to use "%l" for displaying the grouplens score.
682 (setq elem '("" ?s)))
684 (setq elem '("*" ?s))))
685 (setq elem-type (cadr elem))
686 ;; Insert the new format elements.
688 (not (and (featurep 'xemacs)
689 gnus-use-correct-string-widths)))
690 (insert (number-to-string pad-width)))
691 ;; Create the form to be evaled.
692 (if (or max-width cut-width ignore-value
693 (and (featurep 'xemacs)
694 gnus-use-correct-string-widths))
697 (let ((el (car elem)))
698 (cond ((= (cadr elem) ?c)
699 (setq el (list 'char-to-string el)))
701 (setq el (list 'int-to-string el))))
703 (setq el (gnus-tilde-ignore-form el ignore-value)))
705 (setq el (gnus-tilde-cut-form el cut-width)))
707 (setq el (gnus-tilde-max-form el max-width)))
709 (setq el (gnus-pad-form el pad-width)))
712 (push (car elem) flist))))
713 (setq fstring (buffer-substring-no-properties (point-min) (point-max))))
715 ;; Do some postprocessing to increase efficiency.
720 ((string= fstring "")
722 ;; Not a format string.
723 ((not (string-match "%" fstring))
725 ;; A format string with just a single string spec.
726 ((string= fstring "%s")
728 ;; A single character.
729 ((string= fstring "%c")
732 ((string= fstring "%d")
735 `(insert (int-to-string ,(car flist)))
736 (list `(int-to-string ,(car flist)))))
737 ;; Just lots of chars and strings.
738 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
740 ;; A single string spec at the beginning of the spec.
741 ((string-match "\\`%[sc][^%]+\\'" fstring)
742 (list (car flist) (substring fstring 2)))
743 ;; A single string spec in the middle of the spec.
744 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
745 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
746 ;; A single string spec in the end of the spec.
747 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
748 (list (match-string 1 fstring) (car flist)))
749 ;; Only string (and %) specs (XEmacs only!)
750 ((and (featurep 'xemacs)
751 gnus-make-format-preserve-properties
753 "\\`\\([^%]*\\(%%\\|%-?\\([1-9][0-9]*\\)?s\\)\\)*[^%]*\\'"
755 (list (cons 'gnus-xmas-format (cons fstring (nreverse flist)))))
756 ;; A more complex spec.
758 (list (cons 'format (cons fstring (nreverse flist)))))))
764 (cons 'insert result)))
765 (cond ((stringp result)
768 (cons 'concat result))
771 (defun gnus-eval-format (format &optional alist props)
772 "Eval the format variable FORMAT, using ALIST.
773 If PROPS, insert the result."
774 (let ((form (gnus-parse-format format alist props)))
776 (gnus-add-text-properties (point) (progn (eval form) (point)) props)
779 (defun gnus-compile ()
780 "Byte-compile the user-defined format specs."
783 (let ((entries gnus-format-specs)
784 (byte-compile-warnings '(unresolved callargs redefine))
787 (gnus-message 7 "Compiling format specs...")
790 (setq entry (pop entries))
791 (if (memq (car entry) '(gnus-version version))
792 (setq gnus-format-specs (delq entry gnus-format-specs))
793 (let ((form (caddr entry)))
794 (when (and (listp form)
795 ;; Under GNU Emacs, it's (byte-code ...)
796 (not (eq 'byte-code (car form)))
797 ;; Under XEmacs, it's (funcall #<compiled-function ...>)
798 (not (and (eq 'funcall (car form))
799 (byte-code-function-p (cadr form)))))
800 (defalias 'gnus-tmp-func `(lambda () ,form))
801 (byte-compile 'gnus-tmp-func)
802 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func))))))
804 (push (cons 'version emacs-version) gnus-format-specs)
805 ;; Mark the .newsrc.eld file as "dirty".
807 (gnus-message 7 "Compiling user specs...done"))))
809 (defun gnus-set-format (type &optional insertable)
810 (set (intern (format "gnus-%s-line-format-spec" type))
812 (symbol-value (intern (format "gnus-%s-line-format" type)))
813 (symbol-value (intern (format "gnus-%s-line-format-alist" type)))
819 ;; coding: iso-8859-1
822 ;;; gnus-spec.el ends here