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:
......
......@@ -104,7 +104,7 @@ 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
(mapc (function
(lambda (msg)
(lyskom-show-personal-message
(blocking-do 'get-conf-stat (elt msg 0))
......
......@@ -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,16 +2014,12 @@ 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)))))
(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)
(mapc (lambda (code)
(mapcar
(function
(lambda (codelist)
......@@ -2032,7 +2028,7 @@ global effect, including changes to key binding."
(cons (cons (cdr (assq code codelist))
code)
result)))))
tmp)))
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,7 +148,8 @@ 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
(let* ((saved-buffer lyskom-buffer)
(buffer (lyskom-get-buffer-create 'write-texts
(concat
(buffer-name (process-buffer proc))
"-edit")))
......@@ -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,7 +238,7 @@ nil -> Ingenting."
(lyskom-get-string 'footnote)
where-put-misc data)))
(setq misc-list (cdr misc-list))))
(mapcar (lambda (item)
(mapc (lambda (item)
(let ((data (lyskom-aux-item-call
item '(edit-insert print)
item lyskom-pers-no)))
......@@ -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,7 +848,7 @@ Cannot be called from a callback."
(set-buffer lyskom-buffer)
(set-collector->value collector nil)
(mapcar (lambda (text-stat)
(mapc (lambda (text-stat)
(cache-del-text-stat text-stat)
(initiate-get-text-stat 'sending
'collector-push
......@@ -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,29 +1733,26 @@ 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)
(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)))
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.
......@@ -1766,9 +1773,10 @@ Point must be located on the line where the subject is."
;; Apply handler.
(when (and callback (buffer-live-p callback-buffer))
(lyskom-save-excursion
(set-buffer lyskom-buffer)
(if callback (apply callback text-no callback-data)))
(set-buffer callback-buffer)
(if callback (apply callback text-no callback-data))))
;; Kill the edit-buffer.
......
......@@ -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)))
`(let (found
(objlist ,list))
(while (and objlist (not found))
(and ((, testfn) (, arg) ((, selector) (car objlist)))
(and (,testfn ,arg (,selector (car objlist)))
(setq found t))
(setq objlist (cdr objlist)))
found)))
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
(let ((current-prefix-arg nil))
(condition-case nil
(previous-line 1)
(beginning-of-buffer (setq done t)))
(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
(let ((current-prefix-arg nil))
(condition-case nil
(next-line 1)
(end-of-buffer (setq done t)))
(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)
(t (list title
(cons 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)))))))
(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))))))))
(defun lyskom-button-menu (pos event)
......
......@@ -1468,7 +1468,7 @@ Args: FORMAT-STRING &rest ARGS"
(lyskom-nbutlast lyskom-overlay-pool
(- (length lyskom-overlay-pool)
kom-max-overlays)))
(mapcar
(mapc
(lambda (o) (lyskom-xemacs-or-gnu (delete-extent o)
(delete-overlay o))) old))
(setq lyskom-overlay-pool (cons val lyskom-overlay-pool)))
......@@ -3223,7 +3223,7 @@ See `kom-save-text-body' for an alternative to this command."
(lyskom-format-insert-before-prompt 'saving-many-on-file
(length list-of-texts)
name))
(mapcar (lambda (n)
(mapc (lambda (n)
(blocking-do-multiple ((text-stat (get-text-stat n))
(text (get-text n)))
(lyskom-save-text text-stat text name)))
......@@ -4676,7 +4676,7 @@ One parameter - the prompt string."
(setq lyskom-line-start-chars
(let ((tmp (make-vector 256 nil)))
(mapcar
(mapc
(function
(lambda (x)
(aset tmp (lyskom-char-to-int x) t)))
......
......@@ -251,8 +251,8 @@ All the forms in BIND-LIST are evaluated before any symbols are bound."
lyskom-expected-unresolved-functions-temp))))
,@body
(eval-when-compile
(and (boundp 'byte-compile-unresolved-functions)
(mapcar (lambda (fn) (and fn (setq byte-compile-unresolved-functions
(when (boundp 'byte-compile-unresolved-functions)
(mapc (lambda (fn) (and fn (setq byte-compile-unresolved-functions
(delq (assq fn byte-compile-unresolved-functions)
byte-compile-unresolved-functions))))
(car lyskom-expected-unresolved-functions-temp)))
......@@ -269,12 +269,12 @@ All the forms in BIND-LIST are evaluated before any symbols are bound."
(symbolp (car-safe (car-safe
byte-compile-unresolved-functions))))
(progn
(mapcar (function (lambda (x)
(mapc (lambda (x)
(setq byte-compile-unresolved-functions
(delq
(assq x
byte-compile-unresolved-functions)
byte-compile-unresolved-functions))))
byte-compile-unresolved-functions)))
lyskom-expected-unresolved-functions)
))
......@@ -292,10 +292,9 @@ All the forms in BIND-LIST are evaluated before any symbols are bound."
(defmacro lyskom-use-local-map (keymap)
"Use keymap KEYMAP as local map in this buffer. KEYMAP is made local in
the current buffer, and its value is copied from the LysKOM buffer."
(` (progn (make-local-variable (quote (, keymap)))
(setq (, keymap)
(lyskom-default-value (quote (, keymap))))
(use-local-map (, keymap)))))
` (progn (make-local-variable (quote ,keymap))
(setq ,keymap (lyskom-default-value (quote ,keymap)))
(use-local-map ,keymap)))
(defmacro lyskom-try-define-key (map seq fn)
`(condition-case nil
......@@ -328,9 +327,9 @@ the current buffer, and its value is copied from the LysKOM buffer."
;;;
(defmacro lyskom-ignore-errors (&rest forms)
(` (condition-case nil
(progn (,@ forms))
(error nil))))
` (condition-case nil
(progn ,@forms)
(error nil)))
(put 'ignore-errors 'edebug-form-spec
'(sexp form body))
......@@ -367,8 +366,8 @@ the current buffer, and its value is copied from the LysKOM buffer."
;;;
(defmacro lyskom-setq-default (name value)
(` (lyskom-set-default (quote (, name))
(, value))))
` (lyskom-set-default (quote ,name)
,value))
(defmacro lyskom-ref-no ()
`(prog1 lyskom-ref-no
......
......@@ -319,7 +319,7 @@
"The menus used in LysKOM.")
(defvar lyskom-popup-menu-template
(` (menu lyskom ((,@ lyskom-menu-template))))
`(menu lyskom (,@lyskom-menu-template))
"Popup-menu in the backgrouond of the LysKOM window")
......@@ -640,7 +640,7 @@ WHAT is one of title, item or keys"