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>
Fix bug 1654:
* edit-text.el (lyskom-edit-send): Use accessors to access parsed
headers.
Fix bug 1660:
* edit-text.el (lyskom-create-text-handler): Added callback and
callback-data parameters. Juggling buffers to get these right is
......
......@@ -104,14 +104,14 @@ See `kom-toggle-auto-reply' and `kom-ansaphone-record-messages'."
(lyskom-format-insert (lyskom-get-string 'ansaphone-no-messages))
(progn
(lyskom-format-insert (lyskom-get-string 'ansaphone-message-list-start))
(mapcar (function
(lambda (msg)
(lyskom-show-personal-message
(blocking-do 'get-conf-stat (elt msg 0))
(blocking-do 'get-conf-stat (elt msg 1))
(elt msg 2)
(elt msg 3)
'nobeep)))
(mapc (function
(lambda (msg)
(lyskom-show-personal-message
(blocking-do 'get-conf-stat (elt msg 0))
(blocking-do 'get-conf-stat (elt msg 1))
(elt msg 2)
(elt msg 3)
'nobeep)))
(reverse lyskom-ansaphone-messages))
(lyskom-format-insert (lyskom-get-string 'ansaphone-message-list-end)))))
......
......@@ -40,11 +40,11 @@
"List of aux item definitions.")
(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
(cons (, number)
(cons (cons 'name (quote (, name)))
(quote (, data))))))))
(cons ,number
(cons (cons 'name (quote ,name))
(quote ,data))))))
(defun lyskom-aux-item-definition->name (def)
(cdr (assq 'name def)))
......
......@@ -290,7 +290,7 @@ CACHE is the name of the variable that points to the cache."
(defun clear-all-caches ()
(mapcar (function (lambda (cache) (set cache nil)))
(mapc (function (lambda (cache) (set cache nil)))
lyskom-caches)
(setq lyskom-caches nil))
......
......@@ -1151,7 +1151,7 @@ The default subject is SUBJECT. TYPE is either 'comment or 'footnote."
'kom-tell-write-comment
'kom-tell-write-footnote))
(let (data)
(mapcar
(mapc
(lambda (misc-info)
(cond
((eq 'RECPT (misc-info->type misc-info))
......@@ -2513,7 +2513,7 @@ today's name is controlled by `kom-show-namedays'."
"")
weekno)
;; Mera kult
(mapcar (function
(mapc (function
(lambda (el)
(let ((when (car el))
(event (cdr el)))
......
......@@ -2014,26 +2014,22 @@ global effect, including changes to key binding."
(defun lyskom-available-language-list ()
"Return an alist suitable for completing read of available language names."
(let ((tmp
(mapcar
(function
(lambda (el)
(cons (car el) (eval (cdr el)))))
(get 'lyskom-language-codes 'lyskom-language-var)))
(mapcar (lambda (el)
(cons (car el) (eval (cdr el))))
(get 'lyskom-language-codes 'lyskom-language-var)))
(codes (mapcar 'car lyskom-languages))
(result nil))
(mapcar
(function
(lambda (code)
(mapcar
(function
(lambda (codelist)
(when (assq code codelist)
(setq result
(cons (cons (cdr (assq code codelist))
code)
result)))))
tmp)))
codes)
(mapc (lambda (code)
(mapcar
(function
(lambda (codelist)
(when (assq code codelist)
(setq result
(cons (cons (cdr (assq code codelist))
code)
result)))))
tmp))
codes)
result))
......@@ -2426,7 +2422,7 @@ See `kom-keep-alive' for more information."
(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))
......
......@@ -1028,7 +1028,7 @@ the LysKOM rules of string matching."
(lyskom-save-excursion
(set-buffer lyskom-buffer)
(mapcar
(mapc
(function
(lambda (x)
(cond ((>= (aref x 0) (aref x 1))
......
......@@ -96,11 +96,15 @@
(defvar lyskom-edit-handler nil
"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
"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
"Status variable for an edit-buffer.")
......@@ -144,11 +148,12 @@ Does lyskom-end-of-command."
(defun lyskom-dispatch-edit-text (proc misc-list subject body
&optional handler &rest data)
"Same as lyskom-edit-text except that it doesn't set lyskom-is-writing."
(let ((buffer (lyskom-get-buffer-create 'write-texts
(concat
(buffer-name (process-buffer proc))
"-edit")))
(config (current-window-configuration)))
(let* ((saved-buffer lyskom-buffer)
(buffer (lyskom-get-buffer-create 'write-texts
(concat
(buffer-name (process-buffer proc))
"-edit")))
(config (current-window-configuration)))
(lyskom-display-buffer buffer)
(text-mode)
......@@ -157,9 +162,11 @@ Does lyskom-end-of-command."
(lyskom-edit-mode)
(make-local-variable 'lyskom-edit-handler)
(make-local-variable 'lyskom-edit-handler-data)
(make-local-variable 'lyskom-edit-handler-buffer)
(make-local-variable 'lyskom-edit-return-to-configuration)
(setq lyskom-edit-handler handler)
(setq lyskom-edit-handler-data data)
(setq lyskom-edit-handler-buffer saved-buffer)
(setq lyskom-edit-return-to-configuration config)
(buffer-disable-undo)
(lyskom-edit-insert-miscs misc-list subject body)
......@@ -231,20 +238,20 @@ nil -> Ingenting."
(lyskom-get-string 'footnote)
where-put-misc data)))
(setq misc-list (cdr misc-list))))
(mapcar (lambda (item)
(let ((data (lyskom-aux-item-call
item '(edit-insert print)
item lyskom-pers-no)))
(when data
(lyskom-princ
(lyskom-format "%#1@%[%#3s%] %#2s\n"
(lyskom-default-button 'aux-edit-menu
(cons edit-buffer
(copy-marker where-put-misc)))
data
(lyskom-get-string 'aux-item-prefix))
where-put-misc))))
aux-list)
(mapc (lambda (item)
(let ((data (lyskom-aux-item-call
item '(edit-insert print)
item lyskom-pers-no)))
(when data
(lyskom-princ
(lyskom-format "%#1@%[%#3s%] %#2s\n"
(lyskom-default-button 'aux-edit-menu
(cons edit-buffer
(copy-marker where-put-misc)))
data
(lyskom-get-string 'aux-item-prefix))
where-put-misc))))
aux-list)
(unless kom-edit-hide-add-button
(lyskom-princ (lyskom-format "%[%#1@%#2s%]\n"
(lyskom-default-button 'add-recipient-or-xref
......@@ -476,6 +483,7 @@ This runs `kom-send-text-hook' and (for backwards compatibility)
(let ((buffer (current-buffer))
(handler lyskom-edit-handler)
(handler-data lyskom-edit-handler-data)
(handler-buffer lyskom-edit-handler-buffer)
(headers nil)
(misc-list nil)
(subject nil)
......@@ -637,7 +645,8 @@ This runs `kom-send-text-hook' and (for backwards compatibility)
buffer
is-anonymous
handler
handler-data))))
handler-data
handler-buffer))))
(lyskom-undisplay-buffer)
(goto-char (point-max))))
;;
......@@ -839,12 +848,12 @@ Cannot be called from a callback."
(set-buffer lyskom-buffer)
(set-collector->value collector nil)
(mapcar (lambda (text-stat)
(cache-del-text-stat text-stat)
(initiate-get-text-stat 'sending
'collector-push
text-stat
collector))
(mapc (lambda (text-stat)
(cache-del-text-stat text-stat)
(initiate-get-text-stat 'sending
'collector-push
text-stat
collector))
comm-to-list)
(lyskom-wait-queue 'sending)
......@@ -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
callback callback-data)
callback callback-data
callback-buffer)
"Handle an attempt to write a text."
(lyskom-tell-internat 'kom-tell-silence)
(message "")
......@@ -1723,30 +1733,27 @@ Point must be located on the line where the subject is."
;; Save the text
(when kom-created-texts-are-saved
(when (buffer-live-p edit-buffer)
(initiate-get-conf-stat 'background
'lyskom-edit-fcc-text
lyskom-pers-no
(save-excursion (set-buffer edit-buffer)
(buffer-string))
text-no
is-anonymous)))
(when (and kom-created-texts-are-saved (buffer-live-p edit-buffer))
(initiate-get-conf-stat 'background
'lyskom-edit-fcc-text
lyskom-pers-no
(save-excursion (set-buffer edit-buffer)
(buffer-string))
text-no
is-anonymous))
;; Immediately mark the text as read if kom-created-texts-are-read is set
;; and we are not sending the text anonymously.
(cond
((and kom-created-texts-are-read
(not is-anonymous))
((and kom-created-texts-are-read (not is-anonymous))
(lyskom-is-read text-no)
(initiate-get-text-stat 'background 'lyskom-mark-as-read
text-no)
(lyskom-run 'background 'set 'lyskom-dont-change-prompt nil)
(lyskom-run 'background 'lyskom-set-mode-line))
(t ; Probably not necessary
(setq lyskom-dont-change-prompt nil)))
(t (setq lyskom-dont-change-prompt nil)))
(save-excursion
(set-buffer edit-buffer) ;Need local variables.
(lyskom-edit-sent-mode 1))
......@@ -1763,13 +1770,14 @@ Point must be located on the line where the subject is."
(set-window-configuration lyskom-edit-return-to-configuration)
(set-buffer (window-buffer (selected-window)))
(goto-char (point-max)))
;; Apply handler.
(lyskom-save-excursion
(set-buffer lyskom-buffer)
(if callback (apply callback text-no callback-data)))
(when (and callback (buffer-live-p callback-buffer))
(lyskom-save-excursion
(set-buffer callback-buffer)
(if callback (apply callback text-no callback-data))))
;; Kill the edit-buffer.
(lyskom-save-excursion
......
......@@ -245,13 +245,13 @@ invalid-value until a filter action has been selected.")
(defmacro lyskom-filter-is-member (testfn arg list selector)
(` (let (found
(objlist (, list)))
(while (and objlist (not found))
(and ((, testfn) (, arg) ((, selector) (car objlist)))
(setq found t))
(setq objlist (cdr objlist)))
found)))
`(let (found
(objlist ,list))
(while (and objlist (not found))
(and (,testfn ,arg (,selector (car objlist)))
(setq found t))
(setq objlist (cdr objlist)))
found))
(defun lyskom-create-compile-filter-function (pattern)
......@@ -262,8 +262,8 @@ invalid-value until a filter action has been selected.")
(defun lyskom-create-filter-function (pattern)
(` (lambda (filter author recipient-list subject text-stat text)
(, (cons 'and (lyskom-create-filter-function-body pattern))))))
`(lambda (filter author recipient-list subject text-stat text)
,(cons 'and (lyskom-create-filter-function-body pattern))))
(defun lyskom-create-filter-function-body (pattern)
(let (inverse)
......@@ -301,57 +301,54 @@ invalid-value until a filter action has been selected.")
(cond
((eq key 'author)
(lyskom-filter-check-args 'stringp args)
(` (and author (string-match (, (regexp-quote args))
(conf-stat->name author)))))
`(and author (string-match ,(regexp-quote args)
(conf-stat->name author))))
((eq key 'author-re)
(lyskom-filter-check-args 'regexpp args)
(` (and author (string-match (, args)
(conf-stat->name author)))))
`(and author (string-match ,args
(conf-stat->name author))))
((eq key 'author-no)
(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)
(lyskom-filter-check-args 'stringp args)
(` (lyskom-filter-is-member
`(lyskom-filter-is-member
string-match
(, (regexp-quote args))
,(regexp-quote args)
recipient-list
conf-stat->name)))
conf-stat->name))
((eq key 'recipient-re)
(lyskom-filter-check-args 'regexpp args)
(` (lyskom-filter-is-member
`(lyskom-filter-is-member
string-match
(, args)
,args
recipient-list
conf-stat->name)))
conf-stat->name))
((eq key 'recipient-no)
(lyskom-filter-check-args 'integerp args)
(` (lyskom-filter-is-member
`(lyskom-filter-is-member
=
(, args)
,args
recipient-list
conf-stat->conf-no)))
conf-stat->conf-no))
((eq key 'subject)
(lyskom-filter-check-args 'stringp args)
(` (string-match (, (regexp-quote args))
subject)))
`(string-match ,(regexp-quote args)
subject))
((eq key 'subject-re)
(lyskom-filter-check-args 'regexpp args)
(` (string-match (, args)
subject)))
`(string-match ,args subject))
((eq key 'text)
(lyskom-filter-check-args 'stringp args)
(` (string-match (, (regexp-quote args))
text)))
`(string-match ,(regexp-quote args) text))
((eq key 'text-re)
(lyskom-filter-check-args 'regexpp args)
(` (string-match (, args)
text)))
`(string-match ,args text))
(t (lyskom-error
(lyskom-get-string 'filter-error-unknown-key)
key
......
......@@ -380,8 +380,8 @@ If optional PORTABLE-ONLY is non-nil, skip variables marked non-portable."
;was stored.
(++ r))
(mapcar 'lyskom-recompile-filter kom-permanent-filter-list)
(mapcar 'lyskom-recompile-filter kom-session-filter-list)
(mapc 'lyskom-recompile-filter kom-permanent-filter-list)
(mapc 'lyskom-recompile-filter kom-session-filter-list)
(setq lyskom-filter-list (append kom-permanent-filter-list
kom-session-filter-list))
......
......@@ -304,9 +304,10 @@ Returns the selected string."
(while (not done)
;; Move up one line
(condition-case nil
(previous-line 1)
(beginning-of-buffer (setq done t)))
(let ((current-prefix-arg nil))
(condition-case nil
(call-interactively 'previous-line)
(beginning-of-buffer (setq done t))))
;; Scan the items on this line until we find the one
;; just before point or just after point or around
......@@ -336,9 +337,10 @@ Returns the selected string."
(while (not done)
;; Move up one line
(condition-case nil
(next-line 1)
(end-of-buffer (setq done t)))
(let ((current-prefix-arg nil))
(condition-case nil
(call-interactively 'next-line)
(end-of-buffer (setq done t))))
;; Scan the items on this line until we find the one
;; just before point or just after point or around
......
......@@ -133,7 +133,7 @@ Automatically created with def-komtype" type)
;; Create accessors and mutators
(let ((field-index 0))
(mapcar
(mapc
(lambda (arg)
(unless (eq arg '&optional)
(let ((field (or (car-safe arg) arg)))
......@@ -346,11 +346,17 @@ Automatically created with def-komtype" type)
(text-stat->aux-items text-stat) 1))
(content-type (and (car item)
(lyskom-mime-decode-content-type
(aux-item->data (car item))))))
(if (lyskom-mime-content-type-get content-type 'charset)
(lyskom-mime-decode-string str (lyskom-mime-content-type-get content-type 'charset))
str))))
(aux-item->data (car item)))))
(charset (lyskom-mime-content-type-get content-type 'charset)))
(condition-case nil
(cond (charset (lyskom-mime-decode-string str charset))
((and (setq charset (detect-coding-string str t))
(not (memq charset '(raw-text undecided))))
(lyskom-mime-decode-string str charset))
((setq charset lyskom-server-coding-system)
(lyskom-mime-decode-string str charset))
(t (lyskom-mime-decode-string str 'iso-8859-1)))
(error str)))))
;;; ================================================================
......
......@@ -146,7 +146,7 @@ parameters to this function."
(setq lyskom-language-categories
(cons (cons category scope) lyskom-language-categories)))
(let ((record (get category 'lyskom-language-symbols)))
(mapcar (lambda (pair)
(mapc (lambda (pair)
(let* ((symbol (car pair))
(string (cdr pair))
(llist (get symbol category))
......
......@@ -200,20 +200,16 @@ If there is no active area, then do something else."
text)
':active t)))
entries))))
(t (append (list 'keymap title)
(delq nil
(mapcar
(lambda (entry)
(and (funcall filter (cdr entry) arg)
(let ((tmp (copy-tree entry)))
(setcar tmp
(lyskom-menu-encode
(lyskom-get-string (car tmp))
'item))
(cons `(,(cdr entry) ,buf ,arg ,text)
tmp))))
entries)))))))
(t (list title
(cons title
(delq nil
(mapcar (lambda (entry)
(when (funcall filter (cdr entry) arg)
(cons
(lyskom-menu-encode (lyskom-get-string (car entry))
'item)
`(,(cdr entry) ,buf ,arg ,text))))
entries))))))))
(