Commit 415cfb96 authored by David Byers's avatar David Byers

Compatibility with Emacs 23; bug 1658; work on bug 1660

parent ec0ee395
2009-03-08 David Byers <davby@ida.liu.se>
Defensive coding for bug 1660:
* edit-text.el (lyskom-create-text-handler): New parameter
callback-buffer. Use instead of lyskom-buffer when calling
callback.
(lyskom-edit-handler-buffer): New variable.
(lyskom-dispatch-edit-text): Initialize callback buffer to lyskom-buffer.
(lyskom-edit-send): Pass callback buffer to create-text handler.
Fix bug 1658 again:
* review.el (kom-review-rot13): Rewrote to use unwind-protect to
remove the rot13 filter rather than use let to override the hook
variable.
Fixed text viewing in Emacs 23:
* komtypes.el (text->decoded-text-mass): Use detect-coding-string
on texts with no specified charset.
Fix compilation warnings in Emacs 23:
* macros.el (lyskom-end-of-compilation): mapcar->mapc
* commands2.el (lyskom-stop-keep-alive): mapcar->mapc
(lyskom-available-language-list): mapcar->mapc
* review.el (kom-review-more-comments): mapcar->mapc
* edit-text.el (lyskom-edit-insert-miscs): mapcar->mapc
(lyskom-edit-send-check-recipients): mapcar->mapc
* option-edit.el (lyskom-custom-insert): mapcar->mapc
2009-03-04 David Byers <davby@ida.liu.se>
Fix compilation warnings in Emacs 23:
* lyskom-rest.el (lyskom-limited-make-overlay): mapcar->mapc
(kom-save-text): mapcar->mapc
(lyskom-is-loaded): mapcar->mapc
* talkback.el (lyskom-insert-bug-report): mapcar->mapc
* option-edit.el (lyskom-customize-send): mapcar->mapc
(lyskom-customize-mode): mapcar->mapc
(lyskom-widget-kbd-macro-action): mapcar->mapc
* menus.el (lyskom-popup-menu-template): Removed old-style backquotes.
(lyskom-set-menus-xemacs): mapcar->mapc
* view-text.el (lyskom-view-text): mapcar->mapc
* filter.el (lyskom-create-filter-function-body): Removed
old-style backquotes.
* cache.el (clear-all-caches): mapcar->mapc
* startup.el (kom-start-anew): mapcar->mapc
* aux-items.el (def-aux-item): Removed last old-style backquotes
* completing-read.el (lyskom-complete-string-next-char): mapcar->mapc
* komtypes.el (def-komtype): mapcar->mapc
* language.el (lyskom-language-strings-internal): mapcar->mapc
* macros.el: Removed last old-style backquotes.
* vars.el.in (lyskom-setup-local-variables): mapcar->mapc
2008-05-11 <David Byers@GULAG> 2008-05-11 <David Byers@GULAG>
Fix bug 1654: Fix bug 1654:
* edit-text.el (lyskom-edit-send): Use accessors to access parsed * edit-text.el (lyskom-edit-send): Use accessors to access parsed
headers. headers.
Fix bug 1660: Fix bug 1660:
* edit-text.el (lyskom-create-text-handler): Added callback and * edit-text.el (lyskom-create-text-handler): Added callback and
callback-data parameters. Juggling buffers to get these right is callback-data parameters. Juggling buffers to get these right is
......
...@@ -104,14 +104,14 @@ See `kom-toggle-auto-reply' and `kom-ansaphone-record-messages'." ...@@ -104,14 +104,14 @@ See `kom-toggle-auto-reply' and `kom-ansaphone-record-messages'."
(lyskom-format-insert (lyskom-get-string 'ansaphone-no-messages)) (lyskom-format-insert (lyskom-get-string 'ansaphone-no-messages))
(progn (progn
(lyskom-format-insert (lyskom-get-string 'ansaphone-message-list-start)) (lyskom-format-insert (lyskom-get-string 'ansaphone-message-list-start))
(mapcar (function (mapc (function
(lambda (msg) (lambda (msg)
(lyskom-show-personal-message (lyskom-show-personal-message
(blocking-do 'get-conf-stat (elt msg 0)) (blocking-do 'get-conf-stat (elt msg 0))
(blocking-do 'get-conf-stat (elt msg 1)) (blocking-do 'get-conf-stat (elt msg 1))
(elt msg 2) (elt msg 2)
(elt msg 3) (elt msg 3)
'nobeep))) 'nobeep)))
(reverse lyskom-ansaphone-messages)) (reverse lyskom-ansaphone-messages))
(lyskom-format-insert (lyskom-get-string 'ansaphone-message-list-end))))) (lyskom-format-insert (lyskom-get-string 'ansaphone-message-list-end)))))
......
...@@ -40,11 +40,11 @@ ...@@ -40,11 +40,11 @@
"List of aux item definitions.") "List of aux item definitions.")
(defmacro def-aux-item (name number &rest data) (defmacro def-aux-item (name number &rest data)
(` (setq lyskom-aux-item-definitions ` (setq lyskom-aux-item-definitions
(add-to-list 'lyskom-aux-item-definitions (add-to-list 'lyskom-aux-item-definitions
(cons (, number) (cons ,number
(cons (cons 'name (quote (, name))) (cons (cons 'name (quote ,name))
(quote (, data)))))))) (quote ,data))))))
(defun lyskom-aux-item-definition->name (def) (defun lyskom-aux-item-definition->name (def)
(cdr (assq 'name def))) (cdr (assq 'name def)))
......
...@@ -290,7 +290,7 @@ CACHE is the name of the variable that points to the cache." ...@@ -290,7 +290,7 @@ CACHE is the name of the variable that points to the cache."
(defun clear-all-caches () (defun clear-all-caches ()
(mapcar (function (lambda (cache) (set cache nil))) (mapc (function (lambda (cache) (set cache nil)))
lyskom-caches) lyskom-caches)
(setq lyskom-caches nil)) (setq lyskom-caches nil))
......
...@@ -1151,7 +1151,7 @@ The default subject is SUBJECT. TYPE is either 'comment or 'footnote." ...@@ -1151,7 +1151,7 @@ The default subject is SUBJECT. TYPE is either 'comment or 'footnote."
'kom-tell-write-comment 'kom-tell-write-comment
'kom-tell-write-footnote)) 'kom-tell-write-footnote))
(let (data) (let (data)
(mapcar (mapc
(lambda (misc-info) (lambda (misc-info)
(cond (cond
((eq 'RECPT (misc-info->type misc-info)) ((eq 'RECPT (misc-info->type misc-info))
...@@ -2513,7 +2513,7 @@ today's name is controlled by `kom-show-namedays'." ...@@ -2513,7 +2513,7 @@ today's name is controlled by `kom-show-namedays'."
"") "")
weekno) weekno)
;; Mera kult ;; Mera kult
(mapcar (function (mapc (function
(lambda (el) (lambda (el)
(let ((when (car el)) (let ((when (car el))
(event (cdr el))) (event (cdr el)))
......
...@@ -2014,26 +2014,22 @@ global effect, including changes to key binding." ...@@ -2014,26 +2014,22 @@ global effect, including changes to key binding."
(defun lyskom-available-language-list () (defun lyskom-available-language-list ()
"Return an alist suitable for completing read of available language names." "Return an alist suitable for completing read of available language names."
(let ((tmp (let ((tmp
(mapcar (mapcar (lambda (el)
(function (cons (car el) (eval (cdr el))))
(lambda (el) (get 'lyskom-language-codes 'lyskom-language-var)))
(cons (car el) (eval (cdr el)))))
(get 'lyskom-language-codes 'lyskom-language-var)))
(codes (mapcar 'car lyskom-languages)) (codes (mapcar 'car lyskom-languages))
(result nil)) (result nil))
(mapcar (mapc (lambda (code)
(function (mapcar
(lambda (code) (function
(mapcar (lambda (codelist)
(function (when (assq code codelist)
(lambda (codelist) (setq result
(when (assq code codelist) (cons (cons (cdr (assq code codelist))
(setq result code)
(cons (cons (cdr (assq code codelist)) result)))))
code) tmp))
result))))) codes)
tmp)))
codes)
result)) result))
...@@ -2426,7 +2422,7 @@ See `kom-keep-alive' for more information." ...@@ -2426,7 +2422,7 @@ See `kom-keep-alive' for more information."
(defun lyskom-stop-keep-alive () (defun lyskom-stop-keep-alive ()
(mapcar 'disable-timeout lyskom-keep-alive-timers) (mapc 'disable-timeout lyskom-keep-alive-timers)
(setq lyskom-keep-alive-timers nil)) (setq lyskom-keep-alive-timers nil))
......
...@@ -1028,7 +1028,7 @@ the LysKOM rules of string matching." ...@@ -1028,7 +1028,7 @@ the LysKOM rules of string matching."
(lyskom-save-excursion (lyskom-save-excursion
(set-buffer lyskom-buffer) (set-buffer lyskom-buffer)
(mapcar (mapc
(function (function
(lambda (x) (lambda (x)
(cond ((>= (aref x 0) (aref x 1)) (cond ((>= (aref x 0) (aref x 1))
......
...@@ -96,11 +96,15 @@ ...@@ -96,11 +96,15 @@
(defvar lyskom-edit-handler nil (defvar lyskom-edit-handler nil
"Status variable for an edit-buffer. "Status variable for an edit-buffer.
See lyskom-edit-handler-data.") See lyskom-edit-handler-data and lyskom-edit-handler-buffer.")
(defvar lyskom-edit-handler-data nil (defvar lyskom-edit-handler-data nil
"Status variable for an edit-buffer. "Status variable for an edit-buffer.
See lyskom-edit-handler.") See lyskom-edit-handler and lyskom-edit-handler-buffer.")
(defvar lyskom-edit-handler-buffer nil
"Buffer to run the edit-handler in.
See lyskom-edit-handler and lyskom-edit-handler-data.")
(defvar lyskom-edit-return-to-configuration nil (defvar lyskom-edit-return-to-configuration nil
"Status variable for an edit-buffer.") "Status variable for an edit-buffer.")
...@@ -144,11 +148,12 @@ Does lyskom-end-of-command." ...@@ -144,11 +148,12 @@ Does lyskom-end-of-command."
(defun lyskom-dispatch-edit-text (proc misc-list subject body (defun lyskom-dispatch-edit-text (proc misc-list subject body
&optional handler &rest data) &optional handler &rest data)
"Same as lyskom-edit-text except that it doesn't set lyskom-is-writing." "Same as lyskom-edit-text except that it doesn't set lyskom-is-writing."
(let ((buffer (lyskom-get-buffer-create 'write-texts (let* ((saved-buffer lyskom-buffer)
(concat (buffer (lyskom-get-buffer-create 'write-texts
(buffer-name (process-buffer proc)) (concat
"-edit"))) (buffer-name (process-buffer proc))
(config (current-window-configuration))) "-edit")))
(config (current-window-configuration)))
(lyskom-display-buffer buffer) (lyskom-display-buffer buffer)
(text-mode) (text-mode)
...@@ -157,9 +162,11 @@ Does lyskom-end-of-command." ...@@ -157,9 +162,11 @@ Does lyskom-end-of-command."
(lyskom-edit-mode) (lyskom-edit-mode)
(make-local-variable 'lyskom-edit-handler) (make-local-variable 'lyskom-edit-handler)
(make-local-variable 'lyskom-edit-handler-data) (make-local-variable 'lyskom-edit-handler-data)
(make-local-variable 'lyskom-edit-handler-buffer)
(make-local-variable 'lyskom-edit-return-to-configuration) (make-local-variable 'lyskom-edit-return-to-configuration)
(setq lyskom-edit-handler handler) (setq lyskom-edit-handler handler)
(setq lyskom-edit-handler-data data) (setq lyskom-edit-handler-data data)
(setq lyskom-edit-handler-buffer saved-buffer)
(setq lyskom-edit-return-to-configuration config) (setq lyskom-edit-return-to-configuration config)
(buffer-disable-undo) (buffer-disable-undo)
(lyskom-edit-insert-miscs misc-list subject body) (lyskom-edit-insert-miscs misc-list subject body)
...@@ -231,20 +238,20 @@ nil -> Ingenting." ...@@ -231,20 +238,20 @@ nil -> Ingenting."
(lyskom-get-string 'footnote) (lyskom-get-string 'footnote)
where-put-misc data))) where-put-misc data)))
(setq misc-list (cdr misc-list)))) (setq misc-list (cdr misc-list))))
(mapcar (lambda (item) (mapc (lambda (item)
(let ((data (lyskom-aux-item-call (let ((data (lyskom-aux-item-call
item '(edit-insert print) item '(edit-insert print)
item lyskom-pers-no))) item lyskom-pers-no)))
(when data (when data
(lyskom-princ (lyskom-princ
(lyskom-format "%#1@%[%#3s%] %#2s\n" (lyskom-format "%#1@%[%#3s%] %#2s\n"
(lyskom-default-button 'aux-edit-menu (lyskom-default-button 'aux-edit-menu
(cons edit-buffer (cons edit-buffer
(copy-marker where-put-misc))) (copy-marker where-put-misc)))
data data
(lyskom-get-string 'aux-item-prefix)) (lyskom-get-string 'aux-item-prefix))
where-put-misc)))) where-put-misc))))
aux-list) aux-list)
(unless kom-edit-hide-add-button (unless kom-edit-hide-add-button
(lyskom-princ (lyskom-format "%[%#1@%#2s%]\n" (lyskom-princ (lyskom-format "%[%#1@%#2s%]\n"
(lyskom-default-button 'add-recipient-or-xref (lyskom-default-button 'add-recipient-or-xref
...@@ -476,6 +483,7 @@ This runs `kom-send-text-hook' and (for backwards compatibility) ...@@ -476,6 +483,7 @@ This runs `kom-send-text-hook' and (for backwards compatibility)
(let ((buffer (current-buffer)) (let ((buffer (current-buffer))
(handler lyskom-edit-handler) (handler lyskom-edit-handler)
(handler-data lyskom-edit-handler-data) (handler-data lyskom-edit-handler-data)
(handler-buffer lyskom-edit-handler-buffer)
(headers nil) (headers nil)
(misc-list nil) (misc-list nil)
(subject nil) (subject nil)
...@@ -637,7 +645,8 @@ This runs `kom-send-text-hook' and (for backwards compatibility) ...@@ -637,7 +645,8 @@ This runs `kom-send-text-hook' and (for backwards compatibility)
buffer buffer
is-anonymous is-anonymous
handler handler
handler-data)))) handler-data
handler-buffer))))
(lyskom-undisplay-buffer) (lyskom-undisplay-buffer)
(goto-char (point-max)))) (goto-char (point-max))))
;; ;;
...@@ -839,12 +848,12 @@ Cannot be called from a callback." ...@@ -839,12 +848,12 @@ Cannot be called from a callback."
(set-buffer lyskom-buffer) (set-buffer lyskom-buffer)
(set-collector->value collector nil) (set-collector->value collector nil)
(mapcar (lambda (text-stat) (mapc (lambda (text-stat)
(cache-del-text-stat text-stat) (cache-del-text-stat text-stat)
(initiate-get-text-stat 'sending (initiate-get-text-stat 'sending
'collector-push 'collector-push
text-stat text-stat
collector)) collector))
comm-to-list) comm-to-list)
(lyskom-wait-queue 'sending) (lyskom-wait-queue 'sending)
...@@ -1691,7 +1700,8 @@ Point must be located on the line where the subject is." ...@@ -1691,7 +1700,8 @@ Point must be located on the line where the subject is."
(defun lyskom-create-text-handler (text-no edit-buffer is-anonymous (defun lyskom-create-text-handler (text-no edit-buffer is-anonymous
callback callback-data) callback callback-data
callback-buffer)
"Handle an attempt to write a text." "Handle an attempt to write a text."
(lyskom-tell-internat 'kom-tell-silence) (lyskom-tell-internat 'kom-tell-silence)
(message "") (message "")
...@@ -1723,30 +1733,27 @@ Point must be located on the line where the subject is." ...@@ -1723,30 +1733,27 @@ Point must be located on the line where the subject is."
;; Save the text ;; Save the text
(when kom-created-texts-are-saved (when (and kom-created-texts-are-saved (buffer-live-p edit-buffer))
(when (buffer-live-p edit-buffer) (initiate-get-conf-stat 'background
(initiate-get-conf-stat 'background 'lyskom-edit-fcc-text
'lyskom-edit-fcc-text lyskom-pers-no
lyskom-pers-no (save-excursion (set-buffer edit-buffer)
(save-excursion (set-buffer edit-buffer) (buffer-string))
(buffer-string)) text-no
text-no is-anonymous))
is-anonymous)))
;; Immediately mark the text as read if kom-created-texts-are-read is set ;; Immediately mark the text as read if kom-created-texts-are-read is set
;; and we are not sending the text anonymously. ;; and we are not sending the text anonymously.
(cond (cond
((and kom-created-texts-are-read ((and kom-created-texts-are-read (not is-anonymous))
(not is-anonymous))
(lyskom-is-read text-no) (lyskom-is-read text-no)
(initiate-get-text-stat 'background 'lyskom-mark-as-read (initiate-get-text-stat 'background 'lyskom-mark-as-read
text-no) text-no)
(lyskom-run 'background 'set 'lyskom-dont-change-prompt nil) (lyskom-run 'background 'set 'lyskom-dont-change-prompt nil)
(lyskom-run 'background 'lyskom-set-mode-line)) (lyskom-run 'background 'lyskom-set-mode-line))
(t ; Probably not necessary (t (setq lyskom-dont-change-prompt nil)))
(setq lyskom-dont-change-prompt nil)))
(save-excursion (save-excursion
(set-buffer edit-buffer) ;Need local variables. (set-buffer edit-buffer) ;Need local variables.
(lyskom-edit-sent-mode 1)) (lyskom-edit-sent-mode 1))
...@@ -1763,13 +1770,14 @@ Point must be located on the line where the subject is." ...@@ -1763,13 +1770,14 @@ Point must be located on the line where the subject is."
(set-window-configuration lyskom-edit-return-to-configuration) (set-window-configuration lyskom-edit-return-to-configuration)
(set-buffer (window-buffer (selected-window))) (set-buffer (window-buffer (selected-window)))
(goto-char (point-max))) (goto-char (point-max)))
;; Apply handler. ;; Apply handler.
(lyskom-save-excursion (when (and callback (buffer-live-p callback-buffer))
(set-buffer lyskom-buffer) (lyskom-save-excursion
(if callback (apply callback text-no callback-data))) (set-buffer callback-buffer)
(if callback (apply callback text-no callback-data))))
;; Kill the edit-buffer. ;; Kill the edit-buffer.
(lyskom-save-excursion (lyskom-save-excursion
......
...@@ -245,13 +245,13 @@ invalid-value until a filter action has been selected.") ...@@ -245,13 +245,13 @@ invalid-value until a filter action has been selected.")
(defmacro lyskom-filter-is-member (testfn arg list selector) (defmacro lyskom-filter-is-member (testfn arg list selector)
(` (let (found `(let (found
(objlist (, list))) (objlist ,list))
(while (and objlist (not found)) (while (and objlist (not found))
(and ((, testfn) (, arg) ((, selector) (car objlist))) (and (,testfn ,arg (,selector (car objlist)))
(setq found t)) (setq found t))
(setq objlist (cdr objlist))) (setq objlist (cdr objlist)))
found))) found))
(defun lyskom-create-compile-filter-function (pattern) (defun lyskom-create-compile-filter-function (pattern)
...@@ -262,8 +262,8 @@ invalid-value until a filter action has been selected.") ...@@ -262,8 +262,8 @@ invalid-value until a filter action has been selected.")
(defun lyskom-create-filter-function (pattern) (defun lyskom-create-filter-function (pattern)
(` (lambda (filter author recipient-list subject text-stat text) `(lambda (filter author recipient-list subject text-stat text)
(, (cons 'and (lyskom-create-filter-function-body pattern)))))) ,(cons 'and (lyskom-create-filter-function-body pattern))))
(defun lyskom-create-filter-function-body (pattern) (defun lyskom-create-filter-function-body (pattern)
(let (inverse) (let (inverse)
...@@ -301,57 +301,54 @@ invalid-value until a filter action has been selected.") ...@@ -301,57 +301,54 @@ invalid-value until a filter action has been selected.")
(cond (cond
((eq key 'author) ((eq key 'author)
(lyskom-filter-check-args 'stringp args) (lyskom-filter-check-args 'stringp args)
(` (and author (string-match (, (regexp-quote args)) `(and author (string-match ,(regexp-quote args)
(conf-stat->name author))))) (conf-stat->name author))))
((eq key 'author-re) ((eq key 'author-re)
(lyskom-filter-check-args 'regexpp args) (lyskom-filter-check-args 'regexpp args)
(` (and author (string-match (, args) `(and author (string-match ,args
(conf-stat->name author))))) (conf-stat->name author))))
((eq key 'author-no) ((eq key 'author-no)
(lyskom-filter-check-args 'integerp args) (lyskom-filter-check-args 'integerp args)
(` (and author (= (, args) (conf-stat->conf-no author))))) `(and author (= ,args (conf-stat->conf-no author))))
((eq key 'recipient) ((eq key 'recipient)
(lyskom-filter-check-args 'stringp args) (lyskom-filter-check-args 'stringp args)
(` (lyskom-filter-is-member `(lyskom-filter-is-member
string-match string-match
(, (regexp-quote args)) ,(regexp-quote args)
recipient-list recipient-list
conf-stat->name))) conf-stat->name))
((eq key 'recipient-re) ((eq key 'recipient-re)
(lyskom-filter-check-args 'regexpp args) (lyskom-filter-check-args 'regexpp args)
(` (lyskom-filter-is-member `(lyskom-filter-is-member
string-match string-match
(, args) ,args
recipient-list recipient-list
conf-stat->name))) conf-stat->name))
((eq key 'recipient-no) ((eq key 'recipient-no)
(lyskom-filter-check-args 'integerp args) (lyskom-filter-check-args 'integerp args)
(` (lyskom-filter-is-member `(lyskom-filter-is-member
= =
(, args) ,args
recipient-list recipient-list
conf-stat->conf-no))) conf-stat->conf-no))
((eq key 'subject) ((eq key 'subject)
(lyskom-filter-check-args 'stringp args) (lyskom-filter-check-args 'stringp args)
(` (string-match (, (regexp-quote args)) `(string-match ,(regexp-quote args)
subject))) subject))
((eq key 'subject-re) ((eq key 'subject-re)
(lyskom-filter-check-args 'regexpp args) (lyskom-filter-check-args 'regexpp args)
(` (string-match (, args) `(string-match ,args subject))
subject)))
((eq key 'text) ((eq key 'text)
(lyskom-filter-check-args 'stringp args) (lyskom-filter-check-args 'stringp args)
(` (string-match (, (regexp-quote args