Commit 1e2659f6 authored by David Byers's avatar David Byers
Browse files

Fixed some compatibility issues

parent f4786f82
2002-08-06 David Byers <david.byers@swipnet.se> 2002-08-06 David Byers <david.byers@swipnet.se>
String "Olsta" in frame title was truncated in Emacs 21:
* lyskom-rest.el (lyskom-make-lyskom-unread-title-format): Use
lyskom-recode-string-for-title.
* utilities.el (lyskom-recode-string-for-title): New function.
Clear out some old junk:
* compatibility.el (lyskom-compatibility-definition-ct): Unused.
Removed.
* lyskom-rest.el (lyskom-call-hook): Unused. Removed.
* lyskom-buttons.el (lyskom-button-send-mail): Unused. Removed.
* utilities.el (skip-first-zeros): Unused. Removed.
(reverse-assoc): Unused. Removed.
(lyskom-string-to-rgb): Unused. Removed.
Fix compatibility problem with Emacs 20:
* utilities.el (lyskom-union): Rebuilt to preserve A and append
the relevant bits of B.
(lyskom-join-lists): Removed. This function used mapc, which is in
cl.el, and is functionally very similar to lyskom-union. Rewrote
lyskom-union to the specifications of this function.
(lyskom-get-ancestors-of-text): Use (new) lyskom-union instead of
lyskom-join-lists.
Fix bug 695: Fix bug 695:
* startup.el (kom-start-anew): Insert language-set-to before the * startup.el (kom-start-anew): Insert language-set-to before the
prompt, not immediately. This ensures that it is printed after any prompt, not immediately. This ensures that it is printed after any
......
...@@ -235,6 +235,7 @@ otherwise return nil" ...@@ -235,6 +235,7 @@ otherwise return nil"
(cache-add session info 'lyskom-static-session-info-cache)) (cache-add session info 'lyskom-static-session-info-cache))
;; NOTUSED: cache-del-static-session-info
(defun cache-del-static-session-info (session) (defun cache-del-static-session-info (session)
"Delete a text from the cache. Args: SESSION." "Delete a text from the cache. Args: SESSION."
(cache-del session 'lyskom-static-session-info-cache)) (cache-del session 'lyskom-static-session-info-cache))
......
...@@ -86,26 +86,6 @@ of the lyskom-provide-* functions instead." ...@@ -86,26 +86,6 @@ of the lyskom-provide-* functions instead."
(cons (quote (, (car (cdr definition)))) (cons (quote (, (car (cdr definition))))
lyskom-compatibility-definitions)))))))) lyskom-compatibility-definitions))))))))
(defmacro lyskom-compatibility-definition-ct (predicate definition)
"If PREDICATE is nil, evaluate DEFINITION at compile and run time.
Definition should be a function definition of some kind, with syntax
similar to defun or defmacro.
To simply define a function if it is not already defined, used one
of the lyskom-provide-* functions instead."
(` (progn ;(eval-when-compile
; (if (not (, predicate))
; (message "Compatibility %S for %S"
; (quote (, (car definition)))
; (quote (, (car (cdr definition)))))))
(eval-when-compile
(if (not (, predicate))
(progn
(, definition)
(setq lyskom-compatibility-definitions
(cons (quote (, (car (cdr definition))))
lyskom-compatibility-definitions))))))))
;;; ============================================================ ;;; ============================================================
;;; lyskom-provide ;;; lyskom-provide
......
...@@ -1157,6 +1157,7 @@ WINDOW plus any optional arguments given in ARG-LIST." ...@@ -1157,6 +1157,7 @@ WINDOW plus any optional arguments given in ARG-LIST."
(defvar Info-current-node) (defvar Info-current-node)
(defvar Info-current-file) (defvar Info-current-file)
;; NOTUSED: kom-yank-info-nodename
(defun kom-yank-info-nodename () (defun kom-yank-info-nodename ()
"Put the current Info-node on the kill-ring." "Put the current Info-node on the kill-ring."
(interactive) (interactive)
...@@ -1165,6 +1166,8 @@ WINDOW plus any optional arguments given in ARG-LIST." ...@@ -1165,6 +1166,8 @@ WINDOW plus any optional arguments given in ARG-LIST."
(file-name-nondirectory Info-current-file) (file-name-nondirectory Info-current-file)
Info-current-node))) Info-current-node)))
;; NOTUSED: kom-insert-last-info-nodename
(defun kom-insert-last-info-nodename () (defun kom-insert-last-info-nodename ()
"Insert a reference to the most recently visited info node." "Insert a reference to the most recently visited info node."
(interactive) (interactive)
......
...@@ -1145,12 +1145,6 @@ depending on the value of `kom-lynx-terminal'." ...@@ -1145,12 +1145,6 @@ depending on the value of `kom-lynx-terminal'."
(t (lyskom-error "Bad Lynx terminal: %s" kom-lynx-terminal)) (t (lyskom-error "Bad Lynx terminal: %s" kom-lynx-terminal))
)) ))
;;;
;;; email buttons
;;;
(defun lyskom-button-send-mail (to)
(mail nil to))
;;; ;;;
;;; aux-item buttons ;;; aux-item buttons
......
...@@ -3507,19 +3507,6 @@ lyskom-get-string to retrieve regexps for answer and string for repeated query." ...@@ -3507,19 +3507,6 @@ lyskom-get-string to retrieve regexps for answer and string for repeated query."
(error "Not implemented")) (error "Not implemented"))
(defun lyskom-call-hook (hook-name &rest args)
"Calls a hook with parameters.
If HOOK-NAME is bound, it is either a function name or a list of functions
to apply to the ARGS."
(if (and (boundp hook-name) (eval hook-name))
(if (listp (eval hook-name))
(mapcar '(lambda (fn)
(apply fn args))
(eval hook-name))
(apply (eval hook-name) args))))
;;; Priority filtering ;;; Priority filtering
(defun lyskom-visible-membership (membership) (defun lyskom-visible-membership (membership)
...@@ -3937,11 +3924,11 @@ One parameter - the prompt string." ...@@ -3937,11 +3924,11 @@ One parameter - the prompt string."
`(kom-show-unread-in-frame-title `(kom-show-unread-in-frame-title
(lyskom-session-has-unreads (lyskom-session-has-unreads
(" (" ((lyskom-session-has-unreads (" (" ((lyskom-session-has-unreads
,(lyskom-maybe-recode-string (lyskom-get-string 'frame-title-unread) ,(lyskom-recode-string-for-title (lyskom-get-string 'frame-title-unread)
'iso-8859-1 t)) 'iso-8859-1))
(lyskom-session-has-unread-letters ,(lyskom-maybe-recode-string (lyskom-session-has-unread-letters ,(lyskom-recode-string-for-title
(lyskom-get-string 'frame-title-letters) (lyskom-get-string 'frame-title-letters)
'iso-8859-1 t))) 'iso-8859-1)))
")")))) ")"))))
(defvar icon-title-format) (defvar icon-title-format)
......
...@@ -54,11 +54,6 @@ ...@@ -54,11 +54,6 @@
"Turn VECTOR into a list" "Turn VECTOR into a list"
(append vector nil)) (append vector nil))
(defun reverse-assoc (key cache)
"Same as assoc, but searches on last element in a list"
(reverse (assoc key (mapcar (function reverse) cache))))
(defun nfirst (n list) (defun nfirst (n list)
"Return a list of the N first elements of LIST." "Return a list of the N first elements of LIST."
(let ((result nil)) (let ((result nil))
...@@ -122,12 +117,6 @@ If BEFORE is not in the list, then insert EL at the end of the list." ...@@ -122,12 +117,6 @@ If BEFORE is not in the list, then insert EL at the end of the list."
(if (> n 0) (setcdr (nthcdr (- (1- m) n) x) nil)) (if (> n 0) (setcdr (nthcdr (- (1- m) n) x) nil))
x)))) x))))
(defun skip-first-zeros (list)
(while (and list (zerop (car list)))
(setq list (cdr list)))
list)
(defun filter-list (test list) (defun filter-list (test list)
(let ((result nil)) (let ((result nil))
(lyskom-traverse el list (lyskom-traverse el list
...@@ -323,6 +312,14 @@ only encode when multibyte strings are not supported." ...@@ -323,6 +312,14 @@ only encode when multibyte strings are not supported."
'raw-text)) 'raw-text))
s)) s))
(defun lyskom-recode-string-for-title (s coding)
"Encode S with CODING for use in frame titles.
Attempts to encode the string only in Emacs versions that do not require
MULE coding for frame titles"
(if (> emacs-major-version 20)
s
(lyskom-maybe-recode-string s coding t)))
(defun lyskom-maybe-frob-completion-table (table &optional copy) (defun lyskom-maybe-frob-completion-table (table &optional copy)
"Recode the cars of alist TABLE to default coding system unless multibyte "Recode the cars of alist TABLE to default coding system unless multibyte
characters are enabled. This function is destructive unless optional copy characters are enabled. This function is destructive unless optional copy
...@@ -607,9 +604,10 @@ non-negative integer and 0 means the given text-no." ...@@ -607,9 +604,10 @@ non-negative integer and 0 means the given text-no."
(result '())) (result '()))
(while ancestors (while ancestors
(setq result (setq result
(lyskom-join-lists (lyskom-union
(lyskom-get-ancestors-of-text (car ancestors) level)
result result
(lyskom-get-ancestors-of-text (car ancestors) level))) ))
(setq ancestors (cdr ancestors))) (setq ancestors (cdr ancestors)))
result))) result)))
...@@ -821,12 +819,13 @@ The order of the list a is kept." ...@@ -821,12 +819,13 @@ The order of the list a is kept."
(defun lyskom-union (a b) (defun lyskom-union (a b)
"Returns a list containing the union of list A and list B. "Returns a list containing the union of list A and list B.
The list may contain list A or list B as its tail. This means that Specifically, concatenate all elements of B that are not in A
destructive operations on the result may affect either operand." to the end of A. This operation is destructive and modifies the
list pointed to by A."
(let ((result nil)) (let ((result nil))
(lyskom-traverse x a (lyskom-traverse x b
(unless (memq x b) (setq result (cons x result)))) (unless (memq x a) (setq result (cons x result))))
(nconc (nreverse result) b))) (nconc a (nreverse result))))
(defun lyskom-delete-duplicates (list &optional key) (defun lyskom-delete-duplicates (list &optional key)
"Removes all but one instance of each element in LIST. "Removes all but one instance of each element in LIST.
...@@ -843,13 +842,6 @@ comparison. Comparison is done with eq." ...@@ -843,13 +842,6 @@ comparison. Comparison is done with eq."
(setq result (cons el result)))) (setq result (cons el result))))
(nreverse (mapcar 'cdr result)))) (nreverse (mapcar 'cdr result))))
(defun lyskom-join-lists (list1 list2)
"Like append, but only elements of list2 that are not present in list1 are
added to the result. The comparison is done with eq."
(let ((in-both (lyskom-intersection list1 list2)))
(mapc (lambda (o) (setq list2 (delq o list2))) in-both)
(append list1 list2)))
(defun lyskom-plusp (int) (defun lyskom-plusp (int)
"Returns t for integers greater than 0, nil otherwise." "Returns t for integers greater than 0, nil otherwise."
(and (integerp int) (> int 0))) (and (integerp int) (> int 0)))
...@@ -1718,10 +1710,6 @@ should be." ...@@ -1718,10 +1710,6 @@ should be."
(lyskom-hls-to-rgb hls)))))) (lyskom-hls-to-rgb hls))))))
(defun lyskom-string-to-rgb (color)
"Convert the name of a color to RGB values."
(mapcar (lambda (x) (/ x 65535.0)) (lyskom-color-values color)))
(defun lyskom-rgb-to-hls (rgb) (defun lyskom-rgb-to-hls (rgb)
"Convert a point in RGB color space to a point in HLS color space. "Convert a point in RGB color space to a point in HLS color space.
......
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