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 (defvar gnus-mouse-face-0
'highlight
)
268 (defvar gnus-mouse-face-1
'highlight
)
269 (defvar gnus-mouse-face-2
'highlight
)
270 (defvar gnus-mouse-face-3
'highlight
)
271 (defvar gnus-mouse-face-4
'highlight
)
273 (defun gnus-mouse-face-function (form type
)
274 `(gnus-put-text-property
275 (point) (progn ,@form
(point))
279 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type
)))))))
281 (defvar gnus-face-0
'bold
)
282 (defvar gnus-face-1
'italic
)
283 (defvar gnus-face-2
'bold-italic
)
284 (defvar gnus-face-3
'bold
)
285 (defvar gnus-face-4
'bold
)
287 (defun gnus-face-face-function (form type
)
288 `(gnus-add-text-properties
289 (point) (progn ,@form
(point))
290 '(gnus-face t face
,(symbol-value (intern (format "gnus-face-%d" type
))))))
292 (defun gnus-balloon-face-function (form type
)
293 `(gnus-put-text-property
294 (point) (progn ,@form
(point))
295 ,(if (fboundp 'balloon-help-mode
)
298 ,(intern (format "gnus-balloon-face-%d" type
))))
300 (defun gnus-spec-tab (column)
302 `(insert-char ?
(max (- ,column
(current-column)) 0))
303 (let ((column (abs column
)))
304 `(if (> (current-column) ,column
)
306 (if (= (move-to-column ,column
) ,column
)
307 (delete-region (point) end
)
308 (delete-region (1- (point)) end
)
310 (insert-char ?
(max (- ,column
(current-column)) 0))))))
312 (defun gnus-correct-length (string)
313 "Return the correct width of STRING."
314 (apply #'+ (mapcar #'char-width string
)))
316 (defun gnus-correct-substring (string start
&optional end
)
321 (length (length string
))
322 (string (concat string
"\0")))
323 ;; Find the start position.
324 (while (and (< seek length
)
326 (incf wseek
(char-width (aref string seek
)))
329 ;; Find the end position.
330 (while (and (<= seek length
)
333 (incf wseek
(char-width (aref string seek
)))
336 (substring string wstart
(1- wend
))))
338 (defun gnus-string-width-function ()
340 (gnus-use-correct-string-widths
341 'gnus-correct-length
)
342 ((fboundp 'string-width
)
347 (defun gnus-substring-function ()
349 (gnus-use-correct-string-widths
350 'gnus-correct-substring
)
351 ((fboundp 'string-width
)
352 'gnus-correct-substring
)
356 (defun gnus-tilde-max-form (el max-width
)
357 "Return a form that limits EL to MAX-WIDTH."
358 (let ((max (abs max-width
))
359 (length-fun (gnus-string-width-function))
360 (substring-fun (gnus-substring-function)))
362 `(if (> (,length-fun
,el
) ,max
)
364 `(,substring-fun
,el
(- (,length-fun
,el
) ,max
))
365 `(if (gnus-lrm-string-p ,el
)
366 (concat (,substring-fun
,el
0 ,max
) ,gnus-lrm-string
)
367 (,substring-fun
,el
0 ,max
)))
369 `(let ((val (eval ,el
)))
370 (if (> (,length-fun val
) ,max
)
372 `(,substring-fun val
(- (,length-fun val
) ,max
))
373 `(if (gnus-lrm-string-p val
)
374 (concat (,substring-fun val
0 ,max
) ,gnus-lrm-string
)
375 (,substring-fun val
0 ,max
)))
378 (defun gnus-tilde-cut-form (el cut-width
)
379 "Return a form that cuts CUT-WIDTH off of EL."
380 (let ((cut (abs cut-width
))
381 (length-fun (gnus-string-width-function))
382 (substring-fun (gnus-substring-function)))
384 `(if (> (,length-fun
,el
) ,cut
)
386 `(,substring-fun
,el
0 (- (,length-fun
,el
) ,cut
))
387 `(,substring-fun
,el
,cut
))
389 `(let ((val (eval ,el
)))
390 (if (> (,length-fun val
) ,cut
)
392 `(,substring-fun val
0 (- (,length-fun val
) ,cut
))
393 `(,substring-fun val
,cut
))
396 (defun gnus-tilde-ignore-form (el ignore-value
)
397 "Return a form that is blank when EL is IGNORE-VALUE."
399 `(if (equal ,el
,ignore-value
)
401 `(let ((val (eval ,el
)))
402 (if (equal val
,ignore-value
)
405 (defun gnus-pad-form (el pad-width
)
406 "Return a form that pads EL to PAD-WIDTH accounting for multi-column
407 characters correctly. This is because `format' may pad to columns or to
408 characters when given a pad value."
409 (let ((pad (abs pad-width
))
410 (side (< 0 pad-width
))
411 (length-fun (gnus-string-width-function)))
413 `(let ((need (- ,pad
(,length-fun
,el
))))
415 (concat ,(when side
'(make-string need ?\
))
417 ,(when (not side
) '(make-string need ?\
)))
419 `(let* ((val (eval ,el
))
420 (need (- ,pad
(,length-fun val
))))
422 (concat ,(when side
'(make-string need ?\
))
424 ,(when (not side
) '(make-string need ?\
)))
427 (defun gnus-parse-format (format spec-alist
&optional insert
)
428 ;; This function parses the FORMAT string with the help of the
429 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
430 ;; string. If the FORMAT string contains the specifiers %( and %)
431 ;; the text between them will have the mouse-face text property.
432 ;; If the FORMAT string contains the specifiers %[ and %], the text between
433 ;; them will have the balloon-help text property.
434 (let ((case-fold-search nil
))
436 "\\`\\(.*\\)%[0-9]?[{(«]\\(.*\\)%[0-9]?[»})]\\(.*\n?\\)\\'\\|%[-0-9]*=\\|%[-0-9]*\\*"
438 (gnus-parse-complex-format format spec-alist
)
439 ;; This is a simple format.
440 (gnus-parse-simple-format format spec-alist insert
))))
442 (defun gnus-parse-complex-format (format spec-alist
)
443 (let ((cursor-spec nil
))
445 (gnus-set-work-buffer)
447 (goto-char (point-min))
448 (while (re-search-forward "\"" nil t
)
449 (replace-match "\\\"" nil t
))
450 (goto-char (point-min))
452 ;; Convert all font specs into font spec lists.
453 (while (re-search-forward "%\\([0-9]+\\)?\\([«»{}()]\\)" nil t
)
454 (let ((number (if (match-beginning 1)
455 (match-string 1) "0"))
456 (delim (aref (match-string 2) 0)))
457 (if (or (= delim ?\
()
460 (replace-match (concat "\"("
461 (cond ((= delim ?\
() "mouse")
462 ((= delim ?\
{) "face")
466 (replace-match "\")\""))))
467 (goto-char (point-max))
469 ;; Convert point position commands.
470 (goto-char (point-min))
471 (let ((case-fold-search nil
))
472 (while (re-search-forward "%\\([-0-9]+\\)?\\*" nil t
)
473 (replace-match "\"(point)\"" t t
)
474 (setq cursor-spec t
)))
475 ;; Convert TAB commands.
476 (goto-char (point-min))
477 (while (re-search-forward "%\\([-0-9]+\\)=" nil t
)
478 (replace-match (format "\"(tab %s)\"" (match-string 1)) t t
))
479 ;; Convert the buffer into the spec.
480 (goto-char (point-min))
481 (let ((form (read (current-buffer))))
483 `(let (gnus-position)
484 ,@(gnus-complex-form-to-spec form spec-alist
)
486 (gnus-put-text-property gnus-position
(1+ gnus-position
)
489 ,@(gnus-complex-form-to-spec form spec-alist
)))))))
491 (defun gnus-complex-form-to-spec (form spec-alist
)
497 (gnus-parse-simple-format sform spec-alist t
))
498 ((eq (car sform
) 'point
)
499 '(setq gnus-position
(point)))
500 ((eq (car sform
) 'tab
)
501 (gnus-spec-tab (cadr sform
)))
503 (funcall (intern (format "gnus-%s-face-function" (car sform
)))
504 (gnus-complex-form-to-spec (cddr sform
) spec-alist
)
509 (defun gnus-xmas-format (fstring &rest args
)
510 "A version of `format' which preserves text properties.
512 Required for XEmacs, where the built in `format' function strips all text
513 properties from both the format string and any inserted strings.
515 Only supports the format sequence %s, and %% for inserting
516 literal % characters. A pad width and an optional - (to right pad)
517 are supported for %s."
518 (let ((re "%%\\|%\\(-\\)?\\([1-9][0-9]*\\)?s")
522 (goto-char (point-min))
523 (while (re-search-forward re nil t
)
524 (goto-char (match-end 0))
526 ((string= (match-string 0) "%%")
530 (error 'wrong-number-of-arguments
#'my-format n fstring
))
531 (let* ((minlen (string-to-number (or (match-string 2) "")))
533 (str (if (stringp arg
) arg
(format "%s" arg
)))
534 (lpad (null (match-string 1)))
535 (padlen (max 0 (- minlen
(length str
)))))
537 (if lpad
(insert-char ?\ padlen
))
539 (unless lpad
(insert-char ?\ padlen
))
540 (setq args
(cdr args
))))))
543 (defun gnus-parse-simple-format (format spec-alist
&optional insert
)
544 ;; This function parses the FORMAT string with the help of the
545 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
548 spec flist fstring elem result dontinsert user-defined
549 type value pad-width spec-beg cut-width ignore-value
550 tilde-form tilde elem-type extended-spec
)
552 (gnus-set-work-buffer)
554 (goto-char (point-min))
555 (while (re-search-forward "%" nil t
)
556 (setq user-defined nil
564 (setq spec-beg
(1- (point)))
566 ;; Parse this spec fully.
569 ((looking-at "\\([-.0-9]+\\)\\(,[-0-9]+\\)?")
570 (setq pad-width
(string-to-number (match-string 1)))
571 (when (match-beginning 2)
572 (setq max-width
(string-to-number (buffer-substring
573 (1+ (match-beginning 2))
575 (goto-char (match-end 0)))
578 (setq tilde
(read (current-buffer))
582 ((memq type
'(pad pad-left
))
583 (setq pad-width value
))
584 ((eq type
'pad-right
)
585 (setq pad-width
(- value
)))
586 ((memq type
'(max-right max
))
587 (setq max-width value
))
589 (setq max-width
(- value
)))
590 ((memq type
'(cut cut-left
))
591 (setq cut-width value
))
592 ((eq type
'cut-right
)
593 (setq cut-width
(- value
)))
596 (if (stringp value
) value
(format "%s" value
))))
598 (setq tilde-form value
))
600 (error "Unknown tilde type: %s" tilde
)))
605 ;; User-defined spec -- find the spec name.
606 ((eq (setq spec
(char-after)) ?u
)
608 (when (and (eq (setq user-defined
(char-after)) ?
&)
609 (looking-at "&\\([^;]+\\);"))
610 (setq user-defined
(match-string 1))
611 (goto-char (match-end 1))))
613 ((and (eq spec ?
&) (looking-at "&\\([^;]+\\);"))
614 (setq extended-spec
(intern (match-string 1)))
615 (goto-char (match-end 1))))
617 (delete-region spec-beg
(point))
619 ;; Now we have all the relevant data on this spec, so
620 ;; we start doing stuff.
623 ;; "%%" just results in a "%".
628 (setq elem
(list tilde-form ?s
)))
629 ;; Treat user defined format specifiers specially.
633 (list (intern (format
634 (if (stringp user-defined
)
635 "gnus-user-format-function-%s"
636 "gnus-user-format-function-%c")
640 ;; Find the specification from `spec-alist'.
641 ((setq elem
(cdr (assq (or extended-spec spec
) spec-alist
))))
642 ;; We used to use "%l" for displaying the grouplens score.
644 (setq elem
'("" ?s
)))
646 (setq elem
'("*" ?s
))))
647 (setq elem-type
(cadr elem
))
648 ;; Insert the new format elements.
650 (not (and (featurep 'xemacs
)
651 gnus-use-correct-string-widths
)))
652 (insert (number-to-string pad-width
)))
653 ;; Create the form to be evaled.
654 (if (or max-width cut-width ignore-value
655 (and (featurep 'xemacs
)
656 gnus-use-correct-string-widths
))
659 (let ((el (car elem
)))
660 (cond ((= (cadr elem
) ?c
)
661 (setq el
(list 'char-to-string el
)))
663 (setq el
(list 'int-to-string el
))))
665 (setq el
(gnus-tilde-ignore-form el ignore-value
)))
667 (setq el
(gnus-tilde-cut-form el cut-width
)))
669 (setq el
(gnus-tilde-max-form el max-width
)))
671 (setq el
(gnus-pad-form el pad-width
)))
674 (push (car elem
) flist
))))
675 (setq fstring
(buffer-substring-no-properties (point-min) (point-max))))
677 ;; Do some postprocessing to increase efficiency.
682 ((string= fstring
"")
684 ;; Not a format string.
685 ((not (string-match "%" fstring
))
687 ;; A format string with just a single string spec.
688 ((string= fstring
"%s")
690 ;; A single character.
691 ((string= fstring
"%c")
694 ((string= fstring
"%d")
697 `(insert (int-to-string ,(car flist
)))
698 (list `(int-to-string ,(car flist
)))))
699 ;; Just lots of chars and strings.
700 ((string-match "\\`\\(%[cs]\\)+\\'" fstring
)
702 ;; A single string spec at the beginning of the spec.
703 ((string-match "\\`%[sc][^%]+\\'" fstring
)
704 (list (car flist
) (substring fstring
2)))
705 ;; A single string spec in the middle of the spec.
706 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring
)
707 (list (match-string 1 fstring
) (car flist
) (match-string 2 fstring
)))
708 ;; A single string spec in the end of the spec.
709 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring
)
710 (list (match-string 1 fstring
) (car flist
)))
711 ;; Only string (and %) specs (XEmacs only!)
712 ((and (featurep 'xemacs
)
713 gnus-make-format-preserve-properties
715 "\\`\\([^%]*\\(%%\\|%-?\\([1-9][0-9]*\\)?s\\)\\)*[^%]*\\'"
717 (list (cons 'gnus-xmas-format
(cons fstring
(nreverse flist
)))))
718 ;; A more complex spec.
720 (list (cons 'format
(cons fstring
(nreverse flist
)))))))
726 (cons 'insert result
)))
727 (cond ((stringp result
)
730 (cons 'concat result
))
733 (defun gnus-eval-format (format &optional alist props
)
734 "Eval the format variable FORMAT, using ALIST.
735 If PROPS, insert the result."
736 (let ((form (gnus-parse-format format alist props
)))
738 (gnus-add-text-properties (point) (progn (eval form
) (point)) props
)
741 (defun gnus-compile ()
742 "Byte-compile the user-defined format specs."
745 (let ((entries gnus-format-specs
)
746 (byte-compile-warnings '(unresolved callargs redefine
))
749 (gnus-message 7 "Compiling format specs...")
752 (setq entry
(pop entries
))
753 (if (memq (car entry
) '(gnus-version version
))
754 (setq gnus-format-specs
(delq entry gnus-format-specs
))
755 (let ((form (caddr entry
)))
756 (when (and (listp form
)
757 ;; Under GNU Emacs, it's (byte-code ...)
758 (not (eq 'byte-code
(car form
)))
759 ;; Under XEmacs, it's (funcall #<compiled-function ...>)
760 (not (and (eq 'funcall
(car form
))
761 (byte-code-function-p (cadr form
)))))
762 (defalias 'gnus-tmp-func
`(lambda () ,form
))
763 (byte-compile 'gnus-tmp-func
)
764 (setcar (cddr entry
) (gnus-byte-code 'gnus-tmp-func
))))))
766 (push (cons 'version emacs-version
) gnus-format-specs
)
767 ;; Mark the .newsrc.eld file as "dirty".
769 (gnus-message 7 "Compiling user specs...done"))))
771 (defun gnus-set-format (type &optional insertable
)
772 (set (intern (format "gnus-%s-line-format-spec" type
))
774 (symbol-value (intern (format "gnus-%s-line-format" type
)))
775 (symbol-value (intern (format "gnus-%s-line-format-alist" type
)))
781 ;; coding: iso-8859-1
784 ;;; gnus-spec.el ends here