Commit 4fadea6a authored by David Byers's avatar David Byers
Browse files

Cleaned up compatibility code. Handle async-text-aux-changed.

Detailed changes that consist only of name changes have been
excluded from this message (see the ChangeLog for details).

Detailed changes:
> 2003-08-16  David Byers  <byers@lysator.liu.se>
>
> 	Handle async-text-aux-changed:
> 	* async.el (lyskom-parse-async): Handle async-text-aux-changed.
>
> 	* aux-items.el (lyskom-aux-item-modify-list): New function.
>
> 	* komtypes.el (text-stat): Make aux-items field read-write.
>
> 	Major cleanup of compatibility code:
> 	* compatibility.el: Cleaned up compatibility code a lot. We no
> 	longer provide fake versions of MULE-related functions or any
> 	other function that other code might take to mean there's some
> 	major feature in Emacs. The only definitions we make in the
> 	standard namespace are "safe" functions. Removed functions that
> 	are not used. Simplified some of the macros. Moved code here from
> 	utilities.el.
> 	(lyskom-gnu-keysym,lyskom-xemacs-keysym): Removed swedish chars
> 	from the lists since we don't use lyskom-keys for that any more.
>
> 	* compatibility.el (coding-system-type): New compatibility def.
> 	(coding-system-property): New compatibility def.
> 	(split-string): Provide compatibility definition for split-string.
>
> 	* lyskom-rest.el (lyskom-unity-text): Use compatibility functions
> 	for MULE stuff.
>
> 	* macros.el (lyskom-end-of-compilation): Don't remove
> 	compatibility definitions from the list of warnings for unresolved
> 	functions since this serves no purpose and hides actual errors.
>
> 	* mship-edit.el (lp--maybe-update-unreads): Use
> 	lyskom-next-property-bounds, not next-text-property-bounds.
>
> 	* lyskom-rest.el (lyskom-do-special-inserts): Use
> 	lyskom-next-property-bounds, not next-text-property-bounds.
>
> 	* mime.el (lyskom-mime-string-charset): Use :mime-charset next to
> 	mime-charset (Gnus does this ans says it is the Emacs 22 way).
parent a947e09f
2003-08-16 David Byers <byers@lysator.liu.se>
Handle async-text-aux-changed:
* async.el (lyskom-parse-async): Handle async-text-aux-changed.
* aux-items.el (lyskom-aux-item-modify-list): New function.
* komtypes.el (text-stat): Make aux-items field read-write.
Major cleanup of compatibility code:
* compatibility.el: Cleaned up compatibility code a lot. We no
longer provide fake versions of MULE-related functions or any
other function that other code might take to mean there's some
major feature in Emacs. The only definitions we make in the
standard namespace are "safe" functions. Removed functions that
are not used. Simplified some of the macros. Moved code here from
utilities.el.
(lyskom-gnu-keysym,lyskom-xemacs-keysym): Removed swedish chars
from the lists since we don't use lyskom-keys for that any more.
* commands2.el (kom-diff-texts): split-string to
lyskom-split-string.
* compatibility.el (coding-system-type): New compatibility def.
(coding-system-property): New compatibility def.
(split-string): Provide compatibility definition for split-string.
* lyskom-rest.el (lyskom-unity-text): Use compatibility functions
for MULE stuff.
* macros.el (lyskom-end-of-compilation): Don't remove
compatibility definitions from the list of warnings for unresolved
functions since this serves no purpose and hides actual errors.
* lyskom-rest.el (lyskom-unity-text): coding-system-type to
lyskom-coding-system-type.
* option-edit.el (lyskom-widget-click): event-point to
lyskom-event-point.
* slow.el (kom-slow-click-or-yank): event-closest-point to
lyskom-event-closest-point.
* utilities.el (lyskom-unicase-char): char-to-int to
lyskom-char-to-int.
* lyskom-rest.el (lyskom-fill-message-initial-wrap): char-to-int
to lyskom-char-to-int.
(lyskom-fill-message): Same here.
(lyskom-is-loaded): Same here.
* faces.el (lyskom-setup-faces-for-buffer): frame-property to
lyskom-frame-property.
* review.el (lyskom-get-texts-by-and-to): mapcar2 to
lyskom-mapcar2.
* lyskom-rest.el (lyskom-split-user-area): mapcar2 to
lyskom-mapcar2.
* feature.el (lyskom-list-features): mapcar2 to lyskom-mapcar2.
* slow.el (lyskom-expand-slow-command): char-before to
lyskom-char-before.
* option-edit.el (lyskom-widget-click): event-point to
lyskom-event-point.
* lyskom-buttons.el (kom-button-click): event-point to
lyskom-event-point. event-glyph to lyskom-event-glyph.
(kom-popup-menu): Same here.
* mship-edit.el (lp--entry-set-background): find-face to
lyskom-find-face.
(lp--entry-set-foreground): Same here.
* lyskom-rest.el (lyskom-face-default-p): find-face to
lyskom-find-face.
* aux-items.el (lyskom-maybe-add-face-to-string): find-face to
lyskom-find-face.
* mship-edit.el (lp--format-entry): lyskom-face-background-name to
lyskom-face-background. lyskom-face-foreground-name to
lyskom-face-foreground.
(lp--redraw-entry-mark): Same here.
* lyskom-rest.el (lyskom-verified-read-enter): minibuffer-message
to lyskom-minibuffer-message.
* command.el (lyskom-command-complete-word): minibuffer-message to
lyskom-minibuffer-message.
* utilities.el (lyskom-maybe-recode-string): multibyte-string-p to
lyskom-multibyte-string-p.
(lyskom-string=): multibyte-string-p to
lyskom-multibyte-string-p.
* compatibility.el (lyskom-string-width): multibyte-string-p to
lyskom-multibyte-string-p.
* buffers.el (lyskom-recode-buffer-name): multibyte-string-p to
lyskom-multibyte-string-p.
* compatibility.el (lyskom-string-width): string-make-unibyte to
lyskom-string-make-unibyte. string-make-multibyte to
lyskom-string-make-multibyte.
* lyskom-rest.el (lyskom-filter): string-as-unibyte to
lyskom-string-as-unibyte.
(lyskom-prot-a-format-string): Same here.
(lyskom-prot-a-format-raw-string): Same here.
* mime.el (lyskom-mime-string-charset): find-charset-string to
lyskom-find-charset-string.
* utilities.el (lyskom-truncate-string-to-width): char-width to
lyskom-char-width.
* view-text.el (lyskom-format-text-footer): string-width to
lyskom-string-width.
* completing-read.el (lyskom-read-session-resolve-ambiguity):
string-width to lyskom-string-width.
* utilities.el (lyskom-check-configuration): coding-system-get to
lyskom-coding-system-get.
* mime.el (lyskom-mime-string-charset):
find-coding-systems-for-charsets to
lyskom-find-coding-systems-for-charsets
(lyskom-mime-string-charset): coding-system-get to
lyskom-coding-system-get.
* parse.el (lyskom-parse-coded-string): check-coding-system to
lyskom-check-coding-system.
* mime.el (lyskom-mime-charset-coding-system): check-coding-system
to lyskom-check-coding-system.
* lyskom-rest.el (lyskom-prot-a-format-string): string-bytes to
lyskom-string-bytes.
(lyskom-prot-a-format-raw-string): string-bytes to
lyskom-string-bytes.
* flags.el (lyskom-save-options): string-bytes to
lyskom-string-bytes.
* utilities.el (lyskom-compute-char-classes): decode-coding-string
to lyskom-decode-coding-string.
(lyskom-string=): decode-coding-string to
lyskom-decode-coding-string.
* parse.el (lyskom-parse-coded-string): decode-coding-string to
lyskom-decode-coding-string.
* mime.el (lyskom-mime-decode-string): decode-coding-string to
lyskom-decode-coding-string.
* parse.el (lyskom-parse-string): decode-coding-string to
lyskom-decode-coding-string.
* flags.el (lyskom-read-options-eval-get-holerith):
decode-coding-string to lyskom-decode-coding-string.
(lyskom-get-holerith): decode-coding-string to
lyskom-decode-coding-string.
* compatibility.el (lyskom-buggy-decode-coding-string):
decode-coding-string to lyskom-decode-coding-string.
* buffers.el (lyskom-recode-buffer-name): decode-coding-string to
lyskom-decode-coding-string.
* aux-items.el (lyskom-aux-item-decode-data): decode-coding-string
to lyskom-decode-coding-string.
* compatibility.el (lyskom-buggy-encode-coding-string):
encoded-coding-string to lyskom-encode-coding-string.
* utilities.el (lyskom-maybe-recode-string): encode-coding-string
to lyskom-encode-coding-string.
(lyskom-unicase): encode-coding-string to
lyskom-encode-coding-string.
* mime.el (lyskom-mime-encode-string): encode-coding-string to
lyskom-encode-coding-string.
* lyskom-rest.el (lyskom-prot-a-format-string):
encode-coding-string to lyskom-encode-coding-string.
* language.el (lyskom-get-menu-string): encode-coding-string to
lyskom-encode-coding-string.
* keyboard-menu.el (lyskom-keyboard-menu-keys-for-string):
encode-coding-string to lyskom-encode-coding-string.
* flags.el (lyskom-save-options): encode-coding-string to
lyskom-encode-coding-string.
* buffers.el (lyskom-recode-buffer-name): encode-coding-string to
lyskom-encode-coding-string.
* aux-items.el (lyskom-aux-item-encode-data): encode-coding-string
to lyskom-encode-coding-string.
* startup.el (lyskom): set-process-coding-system to
lyskom-set-process-coding-system.
* parse.el (lyskom-init-parse): set-buffer-multibyte to
lyskom-set-buffer-multibyte.
* mship-edit.el (lp--maybe-update-unreads): Use
lyskom-next-property-bounds, not next-text-property-bounds.
* lyskom-rest.el (lyskom-do-special-inserts): Use
lyskom-next-property-bounds, not next-text-property-bounds.
* view-mode.el (lyskom-view-base-mode): set-keymap-parent to
lyskom-set-keymap-parent.
* language.el (lyskom-set-language-keymaps): set-keymap-parent to
lyskom-set-keymap-parent.
* completing-read.el (lyskom-minibuffer-local-must-match-map):
set-keymap-parent to lyskom-set-keymap-parent.
* command.el (lyskom-command-minibuffer-local-must-match-map):
set-keymap-parent to lyskom-set-keymap-parent.
* commands2.el (lyskom-help-get-keylist): map-keymap to
lyskom-map-keymap. Removed other branches since map-keymap is
always defined now.
* mship-edit.el (lp--calculate-distance): signum to lyskom-signum.
* commands1.el (lyskom-window-width): frame-width to
lyskom-frame-width.
* lyskom-rest.el (lyskom-format-aux-help): int-to-char to
lyskom-int-to-char.
* commands2.el (lyskom-help): characterp to lyskom-characterp
* keyboard-menu.el (lyskom-read-from-menu): characterp to
lyskom-characterp.
* lyskom-rest.el (lyskom-format-aux-help): characterp to
lyskom-characterp.
* regexp.el (lyskom-re-convert-finalize-result): characterp to
lyskom-characterp.
(lyskom-re-convert-finalize-result): Same here.
* mime.el (lyskom-mime-string-charset): Use :mime-charset next to
mime-charset (Gnus does this ans says it is the Emacs 22 way).
2003-08-15 David Byers <byers@lysator.liu.se>
* view-text.el (lyskom-get-text-belongs-to): New function.
......
......@@ -306,6 +306,20 @@ this function shall be with current-buffer the BUFFER."
(set-conf-stat->msg-of-day (cache-get-conf-stat conf-no)
new-motd)))))
((eq msg-no 22) ; async-text-aux-changes
(let* ((text-no (lyskom-parse-num))
(deleted-aux (lyskom-parse-aux-item-list))
(added-aux (lyskom-parse-aux-item-list))
(text-stat nil))
(lyskom-save-excursion
(set-buffer buffer)
(setq text-stat (cache-get-text-stat text-no))
(when text-stat
(set-text-stat->aux-items text-stat
(lyskom-aux-item-modify-list
(text-stat->aux-items text-stat)
deleted-aux
added-aux))))))
(t
(lyskom-skip-tokens tokens)))))
......
......@@ -135,6 +135,15 @@ return non-nil if the item is to be included in the list."
(aux-item->data item)
item))
(defun lyskom-aux-item-modify-list (item-list deleted added)
"Return a copy of ITEM-LIST with items in DELETED removed and items
in ADDED added."
(let ((new-nos (nconc (mapcar 'aux-item->aux-no deleted)
(mapcar 'aux-item->aux-no added))))
(nconc (filter-list (lambda (el) (not (memq (aux-item->aux-no el) new-nos)))
item-list)
added)))
;;; ======================================================================
......@@ -347,10 +356,10 @@ return non-nil if the item is to be included in the list."
(defun lyskom-aux-item-decode-data (item)
(set-aux-item->data
item
(decode-coding-string (aux-item->data item) lyskom-server-coding-system)))
(lyskom-decode-coding-string (aux-item->data item) lyskom-server-coding-system)))
(defun lyskom-aux-item-encode-data (item)
(encode-coding-string (aux-item->data item) lyskom-server-coding-system)
(lyskom-encode-coding-string (aux-item->data item) lyskom-server-coding-system)
)
......@@ -578,7 +587,7 @@ return non-nil if the item is to be included in the list."
(if (null item)
string
(setq item (car item))
(unless (find-face 'kom-xface)
(unless (lyskom-find-face 'kom-xface)
(make-face 'kom-xface))
(let* ((h (concat "X-Face: " (aux-item->data item)))
(g (intern h lyskom-xface-cache))
......
......@@ -351,18 +351,20 @@ categories")
(add-hook 'kill-emacs-query-functions 'lyskom-quit-query)
(defun lyskom-recode-buffer-name (name)
(cond ((and (multibyte-string-p name) (not enable-multibyte-characters))
(encode-coding-string name
(or (and lyskom-language
(lyskom-language-coding
lyskom-language))
'raw-text)))
((and (not (multibyte-string-p name)) enable-multibyte-characters)
(decode-coding-string name
(cond ((and (lyskom-multibyte-string-p name)
(not enable-multibyte-characters))
(lyskom-encode-coding-string name
(or (and lyskom-language
(lyskom-language-coding
lyskom-language))
'raw-text)))
((and (not (lyskom-multibyte-string-p name))
enable-multibyte-characters)
(lyskom-decode-coding-string name
(or (and lyskom-language
(lyskom-language-coding
lyskom-language))
'raw-text)))
(t name)))
(defun lyskom-generate-new-buffer (name)
......
......@@ -207,7 +207,7 @@
(defvar lyskom-command-minibuffer-local-must-match-map
(let ((map (copy-keymap minibuffer-local-must-match-map)))
(lyskom-xemacs-or-gnu
(progn (set-keymap-parent map lyskom-minibuffer-local-completion-map)
(progn (lyskom-set-keymap-parent map lyskom-minibuffer-local-completion-map)
(define-key map " " 'lyskom-command-complete-word))
(define-key map " " 'lyskom-command-complete-word))
map)
......@@ -392,7 +392,7 @@ and back of the string."
(let ((completion (try-completion string
minibuffer-completion-table
minibuffer-completion-predicate)))
(cond ((null completion) (minibuffer-message " [No match]") nil)
(cond ((null completion) (lyskom-minibuffer-message " [No match]") nil)
((eq completion t) nil)
(t (let* ((tmp string))
(when (and (string-equal (lyskom-unicase completion)
......
......@@ -2555,79 +2555,80 @@ administrative privileges enabled."
))
(lyskom-external-function calendar-iso-from-absolute)
(lyskom-external-function calendar-absolute-from-gregorian)
(def-kom-command kom-display-time ()
"Display the current date and time, according to the server. If
(lyskom-with-external-functions (calendar-iso-from-absolute
calendar-absolute-from-gregorian)
(def-kom-command kom-display-time ()
"Display the current date and time, according to the server. If
`kom-show-week-number', include the ISO week number. Display of
today's name is controlled by `kom-show-namedays'."
(interactive)
(let ((time (lyskom-current-server-time))
(lyskom-last-text-format-flags nil)
(weekno nil))
(lyskom-format-insert
(if kom-show-week-number
(condition-case nil
(progn (require 'calendar)
(require 'cal-iso)
(setq weekno
(car (calendar-iso-from-absolute
(calendar-absolute-from-gregorian
(list (time->mon time)
(time->mday time)
(time->year time))))))
'time-is-week)
(error 'time-is))
'time-is)
(lyskom-format-time 'timeformat-day-yyyy-mm-dd-hh-mm-ss time)
;; Kult:
(if (and (= (time->hour time)
(+ (/ (time->sec time) 10)
(* (% (time->sec time) 10) 10)))
(= (/ (time->min time) 10)
(% (time->min time) 10)))
(lyskom-get-string 'palindrome)
"")
weekno)
;; Mera kult
(mapcar (function
(lambda (el)
(let ((when (car el))
(event (cdr el)))
(if (and (or (null (elt when 0))
(= (time->year time) (elt when 0)))
(or (null (elt when 1))
(= (time->mon time) (elt when 1)))
(or (null (elt when 2))
(= (time->mday time) (elt when 2)))
(or (null (elt when 3))
(= (time->hour time) (elt when 3)))
(or (null (elt when 4))
(= (time->min time) (elt when 4)))
(or (null (elt when 5))
(= (time->sec time) (elt when 5))))
(condition-case nil
(progn
(lyskom-insert " ")
(lyskom-format-insert
"%#1t"
(lyskom-format event
(time->year time)
(time->mon time)
(time->mday time)
(time->hour time)
(time->min time)
(time->sec time))))
(error nil))))))
lyskom-times)
(when kom-show-namedays
(let ((tmp (lyskom-nameday time)))
(when tmp
(lyskom-insert "\n")
(lyskom-insert tmp)))))
(lyskom-insert "\n"))
(interactive)
(let ((time (lyskom-current-server-time))
(lyskom-last-text-format-flags nil)
(weekno nil))
(lyskom-format-insert
(if kom-show-week-number
(condition-case nil
(progn (require 'calendar)
(require 'cal-iso)
(setq weekno
(car (calendar-iso-from-absolute
(calendar-absolute-from-gregorian
(list (time->mon time)
(time->mday time)
(time->year time))))))
'time-is-week)
(error 'time-is))
'time-is)
(lyskom-format-time 'timeformat-day-yyyy-mm-dd-hh-mm-ss time)
;; Kult:
(if (and (= (time->hour time)
(+ (/ (time->sec time) 10)
(* (% (time->sec time) 10) 10)))
(= (/ (time->min time) 10)
(% (time->min time) 10)))
(lyskom-get-string 'palindrome)
"")
weekno)
;; Mera kult
(mapcar (function
(lambda (el)
(let ((when (car el))
(event (cdr el)))
(if (and (or (null (elt when 0))
(= (time->year time) (elt when 0)))
(or (null (elt when 1))
(= (time->mon time) (elt when 1)))
(or (null (elt when 2))
(= (time->mday time) (elt when 2)))
(or (null (elt when 3))
(= (time->hour time) (elt when 3)))
(or (null (elt when 4))
(= (time->min time) (elt when 4)))
(or (null (elt when 5))
(= (time->sec time) (elt when 5))))
(condition-case nil
(progn
(lyskom-insert " ")
(lyskom-format-insert
"%#1t"
(lyskom-format event
(time->year time)
(time->mon time)
(time->mday time)
(time->hour time)
(time->min time)
(time->sec time))))
(error nil))))))
lyskom-times)
(when kom-show-namedays
(let ((tmp (lyskom-nameday time)))
(when tmp
(lyskom-insert "\n")
(lyskom-insert tmp)))))
(lyskom-insert "\n"))
)
......@@ -3254,7 +3255,7 @@ prefix argument \(C-u -), list all sessions."
(let ((win (get-buffer-window (current-buffer))))
(cond
(win (window-width win))
(t (frame-width)))))
(t (lyskom-frame-width)))))
(defun lyskom-return-username (who-info)
......
......@@ -751,22 +751,25 @@ send. If DONTSHOW is non-nil, don't display the sent message."
(t (setq lyskom-message-string (substring lyskom-message-string
0 size)))))))
(lyskom-external-function resize-minibuffer-setup)
(defun lyskom-send-message-turn-off-resize-on-exit ()
(resize-minibuffer-mode -1)
(remove-hook 'kom-send-message-exit-hook
'lyskom-send-message-turn-off-resize-on-exit))
(defun lyskom-send-message-turn-off-resize-on-exit ()
(resize-minibuffer-mode -1)
(remove-hook 'kom-send-message-exit-hook
'lyskom-send-message-turn-off-resize-on-exit))
;; USER-HOOK: lyskom-send-message-resize-minibuffer
(defvar resize-minibuffer-mode)
;; USER-HOOK: lyskom-send-message-resize-minibuffer
(defvar resize-minibuffer-mode)
(defun lyskom-send-message-resize-minibuffer ()
"Temporarily turn on resizing of minibuffer"
(unless resize-minibuffer-mode
(resize-minibuffer-mode 1)
(resize-minibuffer-setup)
(add-hook 'kom-send-message-exit-hook
'kom-send-message-turn-off-resize-on-exit)))
(lyskom-with-external-functions (resize-minibuffer-setup)
(defun lyskom-send-message-resize-minibuffer ()
"Temporarily turn on resizing of minibuffer"
(unless resize-minibuffer-mode
(resize-minibuffer-mode 1)
(resize-minibuffer-setup)
(add-hook 'kom-send-message-exit-hook
'kom-send-message-turn-off-resize-on-exit)))
)
;; USER-HOOK: lyskom-send-message-auto-fill
......@@ -1432,7 +1435,7 @@ YYYY-MM-DD."
(key-description (car arg)))
(cond ((symbolp (car arg))
(format "%s" (car arg)))
((characterp (car arg))
((lyskom-characterp (car arg))
(format "%c" (car arg)))
(t (format "%S" (car arg)))))
(or (lyskom-command-name (cdr arg))
......@@ -1453,27 +1456,13 @@ YYYY-MM-DD."
(defun lyskom-help-get-keylist (keymap)
(cond
((fboundp 'map-keymap)
(and keymap
(let (list)
(map-keymap
(function
(lambda (event function)
(setq list (cons (cons event function) list))))
keymap t)
(nreverse list))))
((vectorp keymap)
(let ((lis nil)
(r 0))
(while (< r (length keymap))
(if (aref keymap r)
(setq lis (cons (cons r (aref keymap r))
lis)))
(++ r))
(nreverse lis)))
(t
(cdr keymap))))
(and keymap
(let (list)
(lyskom-map-keymap
(lambda (event function)
(setq list (cons (cons event function) list)))
keymap t)
(nreverse list))))
;;; ================================================================
......@@ -2240,27 +2229,28 @@ global effect, including changes to key binding."
;;; ============================================================
;;; Berkna
(lyskom-external-function calc-eval)
(def-kom-command kom-calculate (&optional exprx)
"Calculate a mathematical expression.
(lyskom-with-external-functions (calc-eval)
(def-kom-command kom-calculate (&optional exprx)
"Calculate a mathematical expression.
This function requires the `calc' package to be installed, and is
really only a simple interface to the basic functionality of calc."