Add 2012 to FSF copyright years for Emacs files
[bpt/emacs.git] / lisp / international / mule-util.el
index 899bedf..7b152a4 100644 (file)
@@ -1,9 +1,8 @@
-;;; mule-util.el --- utility functions for mulitilingual environment (mule)
+;;; mule-util.el --- utility functions for multilingual environment (mule)
 
-;; Copyright (C) 1997, 1998, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2000-2012  Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008
+;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
 ;;   Registration Number H14PRO021
 ;; Copyright (C) 2003
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -25,9 +24,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -235,8 +232,8 @@ can be a string, a vector, or a list."
 (defun set-nested-alist (keyseq entry alist &optional len branches)
   "Set ENTRY for KEYSEQ in a nested alist ALIST.
 Optional 4th arg LEN non-nil means the first LEN elements in KEYSEQ
is considered.
-Optional argument BRANCHES if non-nil is branches for a keyseq
are considered.
+Optional 5th argument BRANCHES if non-nil is branches for a keyseq
 longer than KEYSEQ.
 See the documentation of `nested-alist-p' for more detail."
   (or (nested-alist-p alist)
@@ -250,10 +247,9 @@ See the documentation of `nested-alist-p' for more detail."
          (error "Keyseq %s is too long for this nested alist" keyseq))
       (setq key-elt (if islist (nth i keyseq) (aref keyseq i)))
       (setq slot (assoc key-elt (cdr alist)))
-      (if (null slot)
-         (progn
-           (setq slot (cons key-elt (list t)))
-           (setcdr alist (cons slot (cdr alist)))))
+      (unless slot
+       (setq slot (cons key-elt (list t)))
+       (setcdr alist (cons slot (cdr alist))))
       (setq alist (cdr slot))
       (setq i (1+ i)))
     (setcar alist entry)
@@ -263,14 +259,14 @@ See the documentation of `nested-alist-p' for more detail."
 ;;;###autoload
 (defun lookup-nested-alist (keyseq alist &optional len start nil-for-too-long)
   "Look up key sequence KEYSEQ in nested alist ALIST.  Return the definition.
-Optional 1st argument LEN specifies the length of KEYSEQ.
-Optional 2nd argument START specifies index of the starting key.
+Optional 3rd argument LEN specifies the length of KEYSEQ.
+Optional 4th argument START specifies index of the starting key.
 The returned value is normally a nested alist of which
 car part is the entry for KEYSEQ.
 If ALIST is not deep enough for KEYSEQ, return number which is
  how many key elements at the front of KEYSEQ it takes
  to reach a leaf in ALIST.
-Optional 3rd argument NIL-FOR-TOO-LONG non-nil means return nil
+Optional 5th argument NIL-FOR-TOO-LONG non-nil means return nil
  even if ALIST is not deep enough."
   (or (nested-alist-p alist)
       (error "Invalid argument %s" alist))
@@ -317,16 +313,16 @@ Optional 3rd argument NIL-FOR-TOO-LONG non-nil means return nil
 ;;;###autoload
 (defmacro with-coding-priority (coding-systems &rest body)
   "Execute BODY like `progn' with CODING-SYSTEMS at the front of priority list.
-CODING-SYSTEMS is a list of coding systems.  See
-`set-coding-priority'.  This affects the implicit sorting of lists of
-coding sysems returned by operations such as `find-coding-systems-region'."
+CODING-SYSTEMS is a list of coding systems.  See `set-coding-system-priority'.
+This affects the implicit sorting of lists of coding systems returned by
+operations such as `find-coding-systems-region'."
   (let ((current (make-symbol "current")))
   `(let ((,current (coding-system-priority-list)))
      (apply #'set-coding-system-priority ,coding-systems)
      (unwind-protect
         (progn ,@body)
        (apply #'set-coding-system-priority ,current)))))
-(put 'with-coding-priority 'lisp-indent-function 1)
+;;;###autoload(put 'with-coding-priority 'lisp-indent-function 1)
 (put 'with-coding-priority 'edebug-form-spec t)
 
 ;;;###autoload
@@ -337,7 +333,7 @@ coding systems ordered by priority."
   `(with-coding-priority (mapcar #'cdr ,priority-list)
      (detect-coding-region ,from ,to)))
 (make-obsolete 'detect-coding-with-priority
-              "Use with-coding-priority and detect-coding-region" "23.1")
+              "use `with-coding-priority' and `detect-coding-region'." "23.1")
 
 ;;;###autoload
 (defun detect-coding-with-language-environment (from to lang-env)
@@ -349,13 +345,15 @@ language environment LANG-ENV."
        (with-coding-priority coding-priority
           (detect-coding-region from to)))))
 
+(declare-function internal-char-font "fontset.c" (position &optional ch))
+
 ;;;###autoload
 (defun char-displayable-p (char)
   "Return non-nil if we should be able to display CHAR.
 On a multi-font display, the test is only whether there is an
-appropriate font from the selected frame's fontset to display CHAR's
-charset in general.  Since fonts may be specified on a per-character
-basis, this may not be accurate."
+appropriate font from the selected frame's fontset to display
+CHAR's charset in general.  Since fonts may be specified on a
+per-character basis, this may not be accurate."
   (cond ((< char 128)
         ;; ASCII characters are always displayable.
         t)
@@ -371,34 +369,34 @@ basis, this may not be accurate."
         ;; On a terminal, a character is displayable if the coding
         ;; system for the terminal can encode it.
         (let ((coding (terminal-coding-system)))
-          (if coding
-              (let ((cs-list (coding-system-get coding :charset-list)))
-                (cond
-                 ((listp cs-list)
-                  (catch 'tag
-                    (mapc #'(lambda (charset) 
-                              (if (encode-char char charset)
-                                  (throw 'tag charset)))
-                          cs-list)
-                    nil))
-                 ((eq cs-list 'iso-2022)
-                  (catch 'tag2
-                    (mapc #'(lambda (charset)
-                              (if (and (plist-get (charset-plist charset)
-                                                  :iso-final-char)
-                                       (encode-char char charset))
-                                  (throw 'tag2 charset)))
-                          charset-list)
-                    nil))
-                 ((eq cs-list 'emacs-mule)
-                  (catch 'tag3
-                    (mapc #'(lambda (charset)
-                              (if (and (plist-get (charset-plist charset) 
-                                                  :emacs-mule-id)
-                                       (encode-char char charset))
-                                  (throw 'tag3 charset)))
-                          charset-list)
-                    nil)))))))))
+          (when coding
+            (let ((cs-list (coding-system-get coding :charset-list)))
+              (cond
+                ((listp cs-list)
+                 (catch 'tag
+                   (mapc #'(lambda (charset)
+                             (if (encode-char char charset)
+                                 (throw 'tag charset)))
+                         cs-list)
+                   nil))
+                ((eq cs-list 'iso-2022)
+                 (catch 'tag2
+                   (mapc #'(lambda (charset)
+                             (if (and (plist-get (charset-plist charset)
+                                                 :iso-final-char)
+                                      (encode-char char charset))
+                                 (throw 'tag2 charset)))
+                         charset-list)
+                   nil))
+                ((eq cs-list 'emacs-mule)
+                 (catch 'tag3
+                   (mapc #'(lambda (charset)
+                             (if (and (plist-get (charset-plist charset)
+                                                 :emacs-mule-id)
+                                      (encode-char char charset))
+                                 (throw 'tag3 charset)))
+                         charset-list)
+                   nil)))))))))
 \f
 (provide 'mule-util)
 
@@ -406,5 +404,4 @@ basis, this may not be accurate."
 ;; coding: iso-2022-7bit
 ;; End:
 
-;; arch-tag: 5bdb52b6-a3a5-4529-b7a0-37d01b0e570b
 ;;; mule-util.el ends here