Commit 7e28a8ad authored by David Byers's avatar David Byers
Browse files

Nu kan man bestämma formatet på inläggsfoten helt själv.

parent 6b83e547
Fri Sep 26 11:18:57 1997 David Byers <davby@ida.liu.se> Fri Sep 26 11:18:57 1997 David Byers <davby@ida.liu.se>
* vars.el.in (kom-footer-format): Ny variabel. * vars.el.in (kom-text-footer-format): Ny variabel.
* view-text.el (lyskom-transform-footer-format): Ny funktion. * view-text.el (lyskom-format-text-footer): Ny funktion.
(lyskom-deferred-insert-footer): Anvnd lyskom-footer-format.
* vars.el.in (kom-text-footer-format): Ny variabel.
* view-text.el (lyskom-deferred-insert-footer): Anvnd
lyskom-format-text-footer.
* lyskom-rest.el (lyskom-fill-message): Bryt inte stycken dr alla * lyskom-rest.el (lyskom-fill-message): Bryt inte stycken dr alla
rader brjar med ett ord och ett kolon. rader brjar med ett ord och ett kolon.
......
...@@ -195,6 +195,44 @@ enabled mode." ...@@ -195,6 +195,44 @@ enabled mode."
server server
inherited) inherited)
(def-kom-var kom-text-footer-format nil
"*If non-nil, this specifies the format of a text footer.
The following format directives are legal:
%n The text number.
%p The number of the author.
%P The name of the author
%- A bunch of dashes
%f Information about the text in parentheses.
Format letters can be prefixed with a number specifying the minimum
field width. The field width can be prefixed with an equals sign which
means that the field is exactly as wide as specified (contents may be
truncated.) A negative field width means left justify the contents.
The field width of %- is special. It specifies the maximum number of
dashes the print. The actual number will be the maximum minus the
length of the author's name, if it is included anywhere in the format
string.
When set, this variable overrides kom-dashed-lines and
kom-show-author-at-end.
The default format is equivalent to the following strings, depending on
the settings of kom-dashed-lines and kom-show-author-at-end.
kom-dashed-lines kom-show-author-at-end Format
t t \"(%n) /%P/%42-%f\"
t nil \"(%n) %42-%f\"
nil t \"(%n) /%P/ %f\"
nil nil \"(%n) %f\"
"
server
inherited)
(def-kom-var kom-show-author-at-end t (def-kom-var kom-show-author-at-end t
"*If non-nil then the author will be shown at the end of each text." "*If non-nil then the author will be shown at the end of each text."
server server
......
...@@ -405,26 +405,106 @@ the user is a member of. Uses blocking-do. Returns t if TEXT-STAT is nil." ...@@ -405,26 +405,106 @@ the user is a member of. Uses blocking-do. Returns t if TEXT-STAT is nil."
"Print date and time. Arg: TIME" "Print date and time. Arg: TIME"
(lyskom-insert (lyskom-return-date-and-time time fmt))) (lyskom-insert (lyskom-return-date-and-time time fmt)))
(defun lyskom-format-text-footer (text author author-name format format-flags)
"Format the footer of a text."
(let* ((result "")
(start 0)
(format-letter nil)
(field-width nil)
(kom-deferred-printing nil)
(have-author (and format (string-match "%=?[0-9]*P" format))))
(if (null format)
(lyskom-format
(cond ((and kom-dashed-lines kom-show-author-at-end)
"(%#1n) /%#2P/%#3s%#4s")
(kom-dashed-lines
"(%#1n) %#3s%#4s")
(kom-show-author-at-end
"(%#1n) /%#2P/")
(t
"(%#1n)"))
text
(or author author-name)
(if kom-show-author-at-end
(if (> (length author-name) 42)
""
(make-string (- 42 (length author-name)) ?-))
"------------------------------------------")
(if format-flags
(lyskom-get-string format-flags)
""))
(while (string-match "%\\(=?-?[0-9]+\\)?\\([-nPpf% ]\\)" format start)
(setq result (concat result (substring format start
(match-beginning 0))))
(setq format-letter (aref format (match-beginning 2)))
(setq field-width (match-string 1 format))
(when (null field-width) (setq field-width ""))
(setq start (match-end 0))
(setq result
(concat
result
(cond
((eq format-letter ?p)
(lyskom-format (format "%%%s#1p" field-width) author))
((eq format-letter ?P)
(lyskom-format (format "%%%s#1P" field-width)
(or author author-name)))
((eq format-letter ?n)
(lyskom-format (format "%%%s#1n" field-width)
(text-stat->text-no text)))
((eq format-letter ?f)
(if format-flags
(lyskom-format (format "%%%s#1s" field-width)
(lyskom-get-string format-flags))
""))
((eq format-letter ?-)
(let ((width
(cond ((null field-width) 42)
((string= "" field-width) 42)
((eq ?= (aref field-width 0))
(string-to-int (substring field-width 1)))
(t (string-to-int field-width)))))
(lyskom-format
(format "%%%s#1s" field-width)
(if have-author
(if (< (length author-name) width)
(make-string (- width (length author-name)) ?-)
"")
(make-string width ?-)))))
((eq format-letter ?%)
"%")
(t (concat "%" field-width (make-string 1 format-letter))))))
)
(setq result (concat result (substring format start)))
(if (string-match "[ \t]+\\'" result)
(substring result 0 (match-beginning 0))
result))))
(defun lyskom-deferred-insert-footer (conf-stat defer-info) (defun lyskom-deferred-insert-footer (conf-stat defer-info)
"Insert the name of a conference at a previously reserved place." "Insert the name of a conference at a previously reserved place."
(let* ((name (cond (conf-stat (conf-stat->name conf-stat)) (let* ((text-stat (elt (defer-info->data defer-info) 0))
(format-flags (elt (defer-info->data defer-info) 1))
(name (cond (conf-stat (conf-stat->name conf-stat))
((= (defer-info->call-par defer-info) 0) ((= (defer-info->call-par defer-info) 0)
(lyskom-get-string 'person-is-anonymous)) (lyskom-get-string 'person-is-anonymous))
(t (lyskom-format 'person-does-not-exist (t (lyskom-format 'person-does-not-exist
(defer-info->call-par defer-info))))) (defer-info->call-par defer-info))))))
(dashes (if (> 42 (length name)) (lyskom-replace-deferred defer-info
(make-string (- 42 (length name)) ?-) (lyskom-format-text-footer text-stat
"")) conf-stat
(text (lyskom-format "/%[%#3@%#1P%]/%#2s%#4s" name
(or conf-stat name) kom-text-footer-format
dashes format-flags))))
(text-properties-at
(defer-info->pos defer-info))
(if (defer-info->data defer-info)
(lyskom-get-string
(defer-info->data defer-info))
""))))
(lyskom-replace-deferred defer-info text)))
(defun lyskom-print-text (text-stat text mark-as-read text-no) (defun lyskom-print-text (text-stat text mark-as-read text-no)
"Print a text. The header must already be printed. "Print a text. The header must already be printed.
...@@ -470,47 +550,37 @@ Args: TEXT-STAT TEXT MARK-AS-READ TEXT-NO." ...@@ -470,47 +550,37 @@ Args: TEXT-STAT TEXT MARK-AS-READ TEXT-NO."
(cache-del-text (text->text-no text))) (cache-del-text (text->text-no text)))
(sit-for 0) (sit-for 0)
(let ((lyskom-current-function-phase 'footer)) (let ((lyskom-current-function-phase 'footer))
(cond (kom-dashed-lines (lyskom-insert "\n")
(lyskom-format-insert "\n(%#1n) " (text->text-no text)) (if kom-deferred-printing
(if (not kom-show-author-at-end) (progn
(progn (lyskom-format-insert "%#1s\n" lyskom-defer-indicator)
(lyskom-format-insert (lyskom-defer-insertion
"-----------------------------------%#1s\n" (lyskom-create-defer-info
(if lyskom-last-text-format-flags 'get-conf-stat
(lyskom-get-string lyskom-last-text-format-flags) (text-stat->author text-stat)
""))) 'lyskom-deferred-insert-footer
(if kom-deferred-printing (set-marker (make-marker)
(progn (- (point-max)
(lyskom-format-insert "%#1s\n" lyskom-defer-indicator) (length lyskom-defer-indicator)
(lyskom-defer-insertion 1))
(lyskom-create-defer-info (length lyskom-defer-indicator)
'get-conf-stat "%#1s"
(text-stat->author text-stat) (list text-stat lyskom-last-text-format-flags))))
'lyskom-deferred-insert-footer (let* ((conf-stat (blocking-do 'get-conf-stat
(set-marker (text-stat->author text-stat)))
(make-marker) (author-name
(- (point-max) (or (conf-stat->name conf-stat)
(length lyskom-defer-indicator) (and (eq (text-stat->author text-stat) 0)
1)) (lyskom-get-string 'person-is-anonymous))
(length lyskom-defer-indicator) (lyskom-format 'person-does-not-exist
"%#1s" (text-stat->author text-stat)))))
lyskom-last-text-format-flags))) (lyskom-insert (lyskom-format-text-footer
(let* ((conf-stat (blocking-do text-stat
'get-conf-stat conf-stat
(text-stat->author text-stat))) author-name
(name (lyskom-format "%#1P" conf-stat))) kom-text-footer-format
(lyskom-format-insert lyskom-last-text-format-flags)))
"/%#1P/%#2s\n" (lyskom-insert "\n")))
conf-stat
(if (> 42 (length name))
(make-string (- 42 (length name)) ?-)
""))))))
(t (lyskom-format-insert
(if kom-show-author-at-end
"\n(%#1n) /%#2P/\n"
"\n(%#1n)\n")
(text->text-no text)
(text-stat->author text-stat)))))
(if mark-as-read (if mark-as-read
(lyskom-mark-as-read text-stat)) (lyskom-mark-as-read text-stat))
(setq lyskom-previous-text lyskom-current-text) (setq lyskom-previous-text lyskom-current-text)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment