Commit 6c122f87 authored by David Byers's avatar David Byers
Browse files

Fix bug 584.

Detailed changes:
> 	Fix bug 587:
> 	* lyskom-rest.el (lyskom-format-x-kom/user-area): New function.
>
> 	* view-text.el (lyskom-print-text): Special patch for user area
> 	(which has no subject line).
>
> 	* flags.el (lyskom-get-holerith): New function that does what
> 	lyskom-read-options-eval-get-holerith does, but does it without
> 	side effects in lyskom-options-text.
>
parent 4e9ea7ef
2003-06-01 David Byers <byers@lysator.liu.se>
Fix bug 587:
* lyskom-rest.el (lyskom-format-x-kom/user-area): New function.
* view-text.el (lyskom-print-text): Special patch for user area
(which has no subject line).
* flags.el (lyskom-get-holerith): New function that does what
lyskom-read-options-eval-get-holerith does, but does it without
side effects in lyskom-options-text.
Fix bug 1046:
* option-edit.el (lyskom-customize-mode): New major mode.
(kom-customize): Use it.
......
......@@ -370,6 +370,37 @@ Returns a list of variables that were ignored."
(decode-coding-string name coding)
(error name))))))
(defun lyskom-get-holerith (string &optional no-coding)
"Get the first holerith string in STRING.
If optional NO-CODING is set, assume the string has internal coding."
(let ((coding (if no-coding 'raw-text lyskom-server-coding-system)))
;; Strip initial whitespace
(when (string-match "^\\(\\s-\\|[\n\r]\\)+" string)
(setq string (substring string (match-end 0))))
;; Read the explicit coding, if any
(when (string-match "^[0-9]+C" string)
(let ((len (string-to-int string)))
(setq coding (intern
(substring string
(match-end 0)
(+ (match-end 0) len))))
(setq string (substring string (+ (match-end 0) len)))))
;; Read the string
(let ((len (string-to-int string))
(start (progn (string-match "[0-9]+H" string)
(match-end 0))))
(let ((name (substring string start (+ start len))))
(setq string (substring string (+ start len)))
(condition-case nil
(cons (decode-coding-string name coding) string)
(error (cons name string)))))))
(defun lyskom-maybe-set-var-from-string (var string)
"This is a wrapper around lyskom-set-var-from-string that does nothing
if the variable is in kom-dont-read-saved-variables.
......
......@@ -2187,6 +2187,66 @@ in lyskom-messages."
(lyskom-button-transform-text (buffer-string) text-stat)
(buffer-substring (point-min) (1- (point-max))))))))
(defun lyskom-get-holerith-list (text &optional no-coding)
"Assume that TEXT is a list of holerith strings. Return those strings."
(let (result tmp)
(while (string-match "\\S-" text)
(setq tmp (lyskom-get-holerith text no-coding))
(setq result (cons (car tmp) result)
text (cdr tmp)))
result))
(defun lyskom-get-holerith-assoc (text &optional no-coding)
"Assume that TEXT is a list of holerith strings. Return those strings."
(let (result tmp key value)
(while (string-match "\\S-" text)
(setq tmp (lyskom-get-holerith text no-coding))
(setq key (car tmp) text (cdr tmp))
(setq tmp (lyskom-get-holerith text no-coding))
(setq value (car tmp) text (cdr tmp))
(setq result (cons (cons key value) result)))
(nreverse result)))
(defun lyskom-split-user-area (text)
"Return the user area split into components."
(let ((tmp (lyskom-get-holerith text t)))
(nreverse (mapcar2 'cons
(lyskom-get-holerith-list (car tmp) t)
(lyskom-get-holerith-list (cdr tmp) t)))))
(defun lyskom-format-x-kom/user-area-data (data)
(let* ((values (lyskom-get-holerith-assoc data t))
(maxlen (apply 'max (mapcar (lambda (el) (length (car el))) values)))
(fs (format "%%-%ds%%s" (+ maxlen 2))))
(mapconcat (lambda (el) (format fs
(concat (car el) ": ")
(cdr el))) values "\n")))
(defun lyskom-format-x-kom/user-area (text text-stat)
; (condition-case nil
(let ((tmpbuf (lyskom-generate-new-buffer "lyskom-user-area"))
(result "")
(user-area (lyskom-split-user-area text)))
(while user-area
(let ((key (car (car user-area)))
(data (cdr (car user-area))))
(setq user-area (cdr user-area))
(setq result
(concat result
key "\n" (make-string (length key) ?=) "\n\n"
(cond ((equal key "common")
(lyskom-format-x-kom/user-area-data data))
((equal key "elisp")
(lyskom-format-x-kom/user-area-data data))
(t data))
(if user-area "\n\n\n" "")))))
result)
; (error (concat "Unable to parse user area\n\n" text)))
)
;;; ============================================================
......
......@@ -805,7 +805,9 @@ blocking-do."
Print an error message if TEXT-STAT or TEXT is nil.
Mark the text as read if (and only if) MARK-AS-READ is non-nil.
Args: TEXT-STAT TEXT MARK-AS-READ TEXT-NO FLAT-REVIEW."
(let ((lyskom-current-function 'lyskom-print-text))
(let* ((lyskom-current-function 'lyskom-print-text)
(cti (lyskom-get-aux-item (text-stat->aux-items text-stat) 1))
(content-type (and cti (aux-item->data (car cti)))))
(cond
((or (null text)
(null text-stat))
......@@ -821,7 +823,8 @@ Args: TEXT-STAT TEXT MARK-AS-READ TEXT-NO FLAT-REVIEW."
body)
(cond
((string-match "\n" str)
((and (string-match "\n" str)
(not (equal "x-kom/user-area" content-type)))
(setq lyskom-current-subject (substring str 0 (match-beginning 0)))
(setq body (substring str (match-end 0)))
(lyskom-insert-string 'head-Subject)
......
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