From: Miles Bader Date: Thu, 3 Aug 2006 11:45:23 +0000 (+0000) Subject: Merge from emacs--devo--0 X-Git-Tag: emacs-pretest-23.0.90~8295^2~777 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e2b97060142842813b657144787cef3e6e743967;p=emacs.git Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 357-381) - Merge from gnus--rel--5.10 - Update from CVS - Merge from erc--emacs--21 * gnus--rel--5.10 (patch 116-122) - Update from CVS - Merge from emacs--devo--0 Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-98 --- e2b97060142842813b657144787cef3e6e743967 diff --cc lisp/ChangeLog index d57587f2621,28c8ac15e40..dabcdb2f911 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@@ -1,3 -1,398 +1,398 @@@ + 2006-08-03 Stefan Monnier + + * font-lock.el (font-lock-beg, font-lock-end) + (font-lock-extend-region-functions): New vars. + (font-lock-extend-region-multiline) + (font-lock-extend-region-wholelines): New functions. + (font-lock-default-fontify-region): Use them. + (font-lock-extend-jit-lock-region-after-change): Only round up + if font-lock-default-fontify-region will do it as well. + + * font-lock.el (font-lock-extend-after-change-region-function): + Rename from font-lock-extend-region-function. + (font-lock-extend-region): Remove by inlining at call sites. + (font-lock-after-change-function): Don't needlessly round up to a whole + number of lines. + (font-lock-extend-jit-lock-region-after-change): Be more careful about + the boundary conditions and the interactions between the various ways + to extend the region. + + 2006-08-02 Stefan Monnier + + * jit-lock.el (jit-lock-fontify-now): Preserve the buffer's + modification status when forcing the second redisplay. + + 2006-08-03 Kim F. Storm + + * edmacro.el (edmacro-fix-menu-commands): Ignore switch-frame. + + 2006-08-02 Stefan Monnier + + * pcvs-util.el (cvs-get-buffer-create): Obey `noreuse' even if `name' + doesn't look like a file name. + + * complete.el (PC-expand-many-files): Avoid signalling an error when + the current directory doesn't exist. Reported by Micha,Ak(Bl Cadilhac. + + 2006-08-02 Andreas Schwab + + * bindings.el (mode-line-format): Simplify reference to vc-mode. + + 2006-08-02 Nick Roberts + + * bindings.el (map): Make mode-line-buffer-identification-keymap + before defining propertized-buffer-identification. + + 2006-08-01 Richard Stallman + + * bindings.el (mode-line-format): Adjust spacing around vc-mode. + + 2006-08-02 Nick Roberts + + * progmodes/gdb-ui.el (gdb-find-source-frame): Make nil the + default value. + (gdb-find-source-frame): New function. + (menu): Add to menu bar. + + 2006-08-01 Stefan Monnier + + * font-core.el (font-lock-extend-region-function) + (font-lock-extend-region): Move to font-lock.el. + + * font-lock.el (font-lock-extend-region-function) + (font-lock-extend-region): Move from font-core.el. Simplify. + + * jit-lock.el (jit-lock-fontify-now): Cause a second redisplay + if needed. + (jit-lock-start, jit-lock-end): New dynamic scoped vars. + (jit-lock-after-change-extend-region-functions): New hook. + (jit-lock-after-change): Use it instead of hard-coding font-lock code. + + * font-lock.el (font-lock-extend-jit-lock-region-after-change): New fun. + (font-lock-turn-on-thing-lock): Use it. + + * longlines.el (longlines-show-region): Make it work on read-only + buffers as well. + + 2006-08-01 Nick Roberts + + * progmodes/gdb-ui.el (gdb-set-hollow): Check for gud-last-last-frame. + + 2006-07-31 Richard Stallman + + * progmodes/vhdl-mode.el (vhdl-speedbar-display-directory) + (vhdl-speedbar-display-projects): Update old obsolete + speedbar variable names. + + 2006-07-31 Nick Roberts + + * progmodes/gdb-ui.el (gdb-find-source-frame): New option. + (gdb-stopped): Use it. + + * t-mouse.el (t-mouse-mode): Use set-process-query-on-exit-flag. + + 2006-07-29 Chong Yidong + + * loadhist.el (unload-feature): Handle new `(t . SYMBOL)' format + for load-history elements. + + 2006-07-29 Eli Zaretskii + + * files.el (convert-standard-filename): For Cygwin, replace + characters not allowed in Windows file names. + (make-auto-save-file-name): Add Cygwin to the list of systems + where the auto-save file name needs to be run through + convert-standard-filename. + + 2006-07-29 Lennart Borgman + + * window.el (bw-get-tree): Don't integerp subtree if it's nil. + + 2006-07-28 Richard Stallman + + * bindings.el (mode-line-frame-identification) + (propertized-buffer-identification): Centralize the code + to initialize the variable. + + * progmodes/grep.el (grep-default-command): Catch errors from + wildcard-to-regexp. + + 2006-07-29 Kim F. Storm + + * progmodes/grep.el (grep-tag-default): New function. + (grep-default-command, grep-read-regexp): Use it. + (grep-read-files): Use car of grep-files-history or grep-files-aliases + as default if nothing else applies. + + 2006-07-28 Bill Atkins (tiny change) + + * wdired.el (wdired-change-to-wdired-mode, wdired-change-to-dired-mode): + Throw error if buffer is not in Dired and Wdired mode, respectively. + + 2006-07-28 Chong Yidong + + * cus-edit.el (custom-no-edit): Revert 2006-07-27 change, so that + self-insert-command keys don't activate buttons. + (custom-mode-map): Just don't bind "\C-m" to `custom-no-edit'. + + 2006-07-29 Nick Roberts + + * progmodes/gdb-ui.el (gdb-info-breakpoints-custom): Use different + faces for enable character. + + 2006-07-28 Nick Roberts + + * Makefile.in (recompile): Update comment to reflect change + on 2004-04-21. + + 2006-07-27 Richard Stallman + + * cus-edit.el (customize-package-emacs-version-alist): Doc fix. + (customize-package-emacs-version): Change msg when pkg has no entry. + (custom-no-edit): On a button, do like widget-button-press. + + 2006-07-27 Dan Nicolaescu + + * term/xterm.el (terminal-init-xterm): Fix bindings for C-tab, + S-tab and C-S-tab. + + 2006-07-28 Nick Roberts + + * progmodes/which-func.el (which-function): Fix documentation/ + comment typo. + + 2006-07-26 Richard Stallman + + * textmodes/ispell.el (ispell-word): If we replace the word, + move point to the end. Insert before deleting. + + 2006-07-26 Chong Yidong + + * subr.el (sit-for): Use new SECONDS arg of read-event instead of + a timer. + + 2006-07-26 Mathias Dahl + - * tumme.el (tumme-backward-image): Add prefix argument. Add error ++ * tumme.el (tumme-backward-image): Add prefix argument. Add error + when at first image. - (tumme-forward-image): Add prefix argument. Add error when at last ++ (tumme-forward-image): Add prefix argument. Add error when at last + image. + + 2006-07-25 Stefan Monnier + + * tabify.el (tabify-regexp): Use more specific regexps. + (tabify): Avoid modifying the buffer unnecessarily. + + 2006-07-25 Mathias Dahl + + * tumme.el (tumme-track-original-file): Add `buffer-live-p' check. + (tumme-format-properties-string): Handle empty `buf'. + (tumme-get-comment): Change variable names inside `let'. + Add missing `let' variable that cause font-lock problems. + (tumme-write-comments): Change variable names inside `let'. + Add missing `let' variable that cause font-lock problems. + (tumme-forward-image): Rename from `tumme-forward-char'. + (tumme-backward-image): Rename from `tumme-backward-char'. + + 2006-07-25 Masatake YAMATO + + * progmodes/ld-script.el (ld-script-keywords) + (ld-script-font-lock-keywords, ld-script-builtins): Update keywords + and add comments. + + 2006-07-25 Nick Roberts + + * progmodes/gdb-ui.el (gdb-set-gud-minor-mode-existing-buffers) + (gdb-resync, gdb-prompt, gdb-starting, gdb-exited, gdb-stopped) + (gdb-set-gud-minor-mode-existing-buffers-1): Use different faces + for status indicator. + + 2006-07-24 Richard Stallman + + * xml.el (xml-parse-file): Clean up, and use with-temp-buffer. + + * subr.el (dolist, dotimes): Use interned symbols for locals. + (--dotimes-limit--, --dolist-tail--): New defvars. + (looking-back): Doc fix. + + * replace.el (replace-match-string-symbols): Handle dotted lists. + + 2006-07-24 mathias + + * tumme.el (tumme-write-tags): Add. + (tumme-write-comments): Add. + (tumme-tag-files): Change to use `tumme-write-tags'. + (tumme-tag-thumbnail): Change to use `tumme-write-tags'. + (tumme-dired-comment-files): Change to use `tumme-write-comments'. + (tumme-save-information-from-widgets): Change to use + `tumme-write-comments' and `tumme-write-tags'. + (tumme-comment-thumbnail): Change to use `tumme-write-comments'. + (tumme-write-tag): Remove. + (tumme-write-comment): Remove. + (tumme-display-previous-thumbnail-original): Remove empty line. + (tumme-widget-list): Add punctuation. + + 2006-07-24 mathias + + * tumme.el (tumme-line-up): Add an extra check for end of buffer. + + 2006-07-24 Daiki Ueno + + * pgg-def.el (pgg-truncate-key-identifier): Truncate the key ID to 8 - letters from the end. Thanks to "David Smith" - and andreas@altroot.de (Andreas V,Av(Bgele). ++ letters from the end. Thanks to "David Smith" and ++ andreas@altroot.de (Andreas V,Av(Bgele) + + 2006-07-23 Thien-Thi Nguyen + + * mouse.el (mouse-on-link-p): Doc fix. + + 2006-07-23 Nick Roberts + + * emacs-lisp/find-func.el (find-function-search-for-symbol): + Handle "C-h f `". + + 2006-07-22 Dan Nicolaescu + + * ibuffer.el (ibuffer-formats): Use left alignment for the mode + column. + + 2006-07-22 Matt Hodges + + * textmodes/table.el: Add move-beginning-of-line and + move-end-of-line to Point Motion Only Group. + + 2006-07-22 Eric Hanchrow + + * progmodes/delphi.el (delphi-fill-comment): Use save-restriction. + + 2006-07-22 Micha,Ak(Bl Cadilhac + + * startup.el (user-mail-address): Initialize from the `EMAIL' + environment variable first. Document this. + (command-line): Ditto. + + 2006-07-22 Nick Roberts + + * help-mode.el (help-function-def, help-variable-def) + (help-face-def): Print a message in the minibuffer. + + 2006-07-21 Dan Nicolaescu + + * term/xterm.el (terminal-init-xterm): Fix key bindings - syntax. Bind S-return, C-M-., C-TAB, S-TAB and C-S-TAB. ++ syntax. Bind S-return, C-M-., C-TAB, S-TAB and C-S-TAB. + + 2006-07-21 Eli Zaretskii + + * dos-w32.el (find-buffer-file-type-coding-system): Support calls + where `(nth 1 command)' is a cons cell. Doc fix. + + * textmodes/po.el (po-find-charset): Doc fix. + + 2006-07-21 Ken Manheimer + + * allout.el (allout-unprotected, allout-e-o-prefix-p) + (allout-beginning-of-current-line, allout-end-of-current-line) + (allout-next-visible-heading, allout-open-topic) + (allout-kill-topic, allout-yank-processing, allout-resolve-xref) + (allout-flag-current-subtree, allout-show-to-offshoot) + (allout-hide-current-entry, allout-show-current-branches) + (allout-hide-region-body, allout-old-expose-topic) + (allout-listify-exposed, allout-latex-verbatim-quote-curr-line) + (allout-mark-topic, allout-adjust-file-variable): Enclose scopes + containing `beginning-of-line' and `end-of-line' with + `inhibit-field-text-motion' t. + + 2006-07-21 Eli Zaretskii + + * frame.el (focus-follows-mouse): Document that it doesn't have + any effect on MS-Windows. + + 2006-07-20 Stefan Monnier + + * progmodes/sh-script.el (sh-quoted-subshell): Further fix last change. + + 2006-07-20 Jay Belanger + + * calc.el (calc-previous-alg-entry): Remove variable. + - * calc-aent.el (calc-alg-entry-history, calc-quick-calc-history): ++ * calc-aent.el (calc-alg-entry-history, calc-quick-calc-history): + New variables. + (calc-alg-entry): Use `calc-alg-entry-history'. + (calc-do-quick-calc): Use `calc-quick-calc-history'. + Remove reference to `calc-previous-alg-entry'. + (calcAlg-edit, calcAlg-enter): Remove reference to + `calc-previous-alg-entry'. + (calcAlg-previous): Use `previous-history-element' instead of + `calc-previous-alg-entry'. + (calc-do-alg-entry): Use history when calling `read-from-minibuffer'. + Change keybinding for `calcAlg-plus-minus', add keybindings for + `previous-history-element' and `next-history-element'. + + * calc-rewr.el (calc-match): Remove reference to + `calc-previous-alg-entry'. + + * calc-sel.el (calc-selection-history): New variable. + (calc-enter-selection, calc-sel-mult-both-sides) + (calc-sel-add-both-sides): Use `calc-selection-history'. + + * calc-map.el (calc-get-operator-history): New variable. + (calc-get-operator): Use `calc-get-operator-history'. + + * calcalg3.el (calc-curve-fit-history): New variable. + (calc-curve-fit): Use `calc-curve-fit-history'. + + 2006-07-20 Kenichi Handa + + * international/mule-cmds.el (select-safe-coding-system): Fix the + way of deciding eol-type of the coding system. + + 2006-07-20 Alan Mackenzie + + * progmodes/cc-langs.el (c-emacs-variable-inits): New variable. + (c-lang-setvar): New macro. + (c-make-init-lang-vars-fun): Use the initialization forms in + c-emacs-variable-inits in addition to those in c-lang-variable-inits. + (comment-start, comment-end, comment-start-skip): Change these from + c-lang-defvar's to c-lang-setvar's. + + * progmodes/cc-mode.el (c-make-emacs-variables-local): New macro, + which calls make-local-variable on the elements of + c-emacs-variable-inits. + (c-init-language-vars-for): Call this new macro. + + 2006-07-19 Stefan Monnier + + * progmodes/compile.el (compilation-error-regexp-alist-alist) : + Try to rule out false positives due to time stamps. + (compilation-mode-font-lock-keywords): Remove rules made redundant + because of the above change. Add `segmentation fault' to the known and + highlighted compilation termination messages. + + 2006-07-19 Kim F. Storm + + * progmodes/grep.el (grep-find-ignored-directories): + Add .svn and _darcs to list. + + 2006-07-19 Mathias Dahl + + * dired.el (dired-mode-map): Add key binding `C-te' for + `tumme-dired-edit-comment-and-tags'. + + * tumme.el (tumme-display-thumbnail-original-image): Make sure + image display buffer is displayed before call to + `tumme-display-image. + (tumme-dired-display-image): Make sure image display buffer is + displayed before call to `tumme-display-image. + (tumme-mouse-display-image): Make sure image display buffer is + displayed before call to `tumme-display-image. + (tumme-widget-list): Add. + (tumme-dired-edit-comment-and-tags): Add. + (tumme-save-information-from-widgets): Add. + + 2006-07-19 Stefan Monnier + + * progmodes/sh-script.el (sh-quoted-subshell): Fix last change. + 2006-07-18 Stefan Monnier * progmodes/sh-script.el (sh-font-lock-keywords-1): diff --cc lisp/Makefile.in index ef9bf3cd180,f6caedcccda..d13dfe4c51e --- a/lisp/Makefile.in +++ b/lisp/Makefile.in @@@ -206,12 -204,11 +206,11 @@@ backup-compiled-files compile-after-backup: backup-compiled-files compile-always - # Recompile all Lisp files which are newer than their .elc files. - # Note that this doesn't create .elc files. It only recompiles if an - # .elc is present. + # Recompile all Lisp files which are newer than their .elc files and compile + # new ones. recompile: doit mh-autoloads $(lisp)/progmodes/cc-mode.elc - $(EMACS) $(EMACSOPT) --eval "(batch-byte-recompile-directory 0)" $(lisp) + LC_ALL=C $(EMACS) $(EMACSOPT) --eval "(batch-byte-recompile-directory 0)" $(lisp) # CC Mode uses a compile time macro system which causes a compile time # dependency in cc-mode.elc on the macros in cc-langs.el and the diff --cc lisp/international/mule-cmds.el index 3e312f3cafd,9adc4746b91..2965b95e3b3 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@@ -902,14 -922,17 +902,15 @@@ It is highly recommended to fix it befo ;; If the most preferred coding system has the property mime-charset, ;; append it to the defaults. - (let ((tail coding-category-list) - preferred base) - (while (and tail (not (setq preferred (symbol-value (car tail))))) - (setq tail (cdr tail))) + (let ((preferred (coding-system-priority-list t)) + base) (and (coding-system-p preferred) (setq base (coding-system-base preferred)) - (coding-system-get preferred 'mime-charset) + (coding-system-get preferred :mime-charset) (not (rassq base default-coding-system)) - (push (cons preferred base) - default-coding-system)))) + (setq default-coding-system + (append default-coding-system + (list (cons preferred base))))))) (if select-safe-coding-system-accept-default-p (setq accept-default-p select-safe-coding-system-accept-default-p)) diff --cc lispref/modes.texi index 52d6c3735e6,8b24db35621..38227633c6b --- a/lispref/modes.texi +++ b/lispref/modes.texi @@@ -3056,6 -3055,10 +3055,10 @@@ property on the construct when it is ad Use @code{font-lock-fontify-region-function} hook to extend the scan so that the scanned text never starts or ends in the middle of a multiline construct. + @item + Add a function to @code{font-lock-extend-region-functions} that does -the @emph{identification} and extends the scan so that the scanned ++the \emph{identification} and extends the scan so that the scanned + text never starts or ends in the middle of a multiline construct. @end itemize There are three ways to do rehighlighting of multiline constructs: diff --cc src/coding.c index cb6df79fca0,1af7b4c0d52..9ba96981c7f --- a/src/coding.c +++ b/src/coding.c @@@ -8308,693 -7450,135 +8308,696 @@@ The first argument OPERATION specifies For process I/O, `call-process', `call-process-region', or `start-process'. For network I/O, `open-network-stream'. -The remaining arguments should be the same arguments that were passed -to the primitive. Depending on which primitive, one of those arguments -is selected as the TARGET. For example, if OPERATION does file I/O, -whichever argument specifies the file name is TARGET. +The remaining arguments should be the same arguments that were passed +to the primitive. Depending on which primitive, one of those arguments +is selected as the TARGET. For example, if OPERATION does file I/O, +whichever argument specifies the file name is TARGET. + +TARGET has a meaning which depends on OPERATION: + For file I/O, TARGET is a file name (except for the special case below). + For process I/O, TARGET is a process name. + For network I/O, TARGET is a service name or a port number + +This function looks up what specified for TARGET in, +`file-coding-system-alist', `process-coding-system-alist', +or `network-coding-system-alist' depending on OPERATION. +They may specify a coding system, a cons of coding systems, +or a function symbol to call. +In the last case, we call the function with one argument, +which is a list of all the arguments given to this function. + +If OPERATION is `insert-file-contents', the argument corresponding to +TARGET may be a cons (FILENAME . BUFFER). In that case, FILENAME is a +file name to look up, and BUFFER is a buffer that contains the file's +contents (not yet decoded). If `file-coding-system-alist' specifies a +function to call for FILENAME, that function should examine the +contents of BUFFER instead of reading the file. + +usage: (find-operation-coding-system OPERATION ARGUMENTS ...) */) + (nargs, args) + int nargs; + Lisp_Object *args; +{ + Lisp_Object operation, target_idx, target, val; + register Lisp_Object chain; + + if (nargs < 2) + error ("Too few arguments"); + operation = args[0]; + if (!SYMBOLP (operation) + || !INTEGERP (target_idx = Fget (operation, Qtarget_idx))) + error ("Invalid first arguement"); + if (nargs < 1 + XINT (target_idx)) + error ("Too few arguments for operation: %s", + SDATA (SYMBOL_NAME (operation))); + target = args[XINT (target_idx) + 1]; + if (!(STRINGP (target) + || (EQ (operation, Qinsert_file_contents) && CONSP (target) + && STRINGP (XCAR (target)) && BUFFERP (XCDR (target))) + || (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) + error ("Invalid %dth argument", XINT (target_idx) + 1); + if (CONSP (target)) + target = XCAR (target); + + chain = ((EQ (operation, Qinsert_file_contents) + || EQ (operation, Qwrite_region)) + ? Vfile_coding_system_alist + : (EQ (operation, Qopen_network_stream) + ? Vnetwork_coding_system_alist + : Vprocess_coding_system_alist)); + if (NILP (chain)) + return Qnil; + + for (; CONSP (chain); chain = XCDR (chain)) + { + Lisp_Object elt; + + elt = XCAR (chain); + if (CONSP (elt) + && ((STRINGP (target) + && STRINGP (XCAR (elt)) + && fast_string_match (XCAR (elt), target) >= 0) + || (INTEGERP (target) && EQ (target, XCAR (elt))))) + { + val = XCDR (elt); + /* Here, if VAL is both a valid coding system and a valid + function symbol, we return VAL as a coding system. */ + if (CONSP (val)) + return val; + if (! SYMBOLP (val)) + return Qnil; + if (! NILP (Fcoding_system_p (val))) + return Fcons (val, val); + if (! NILP (Ffboundp (val))) + { - val = safe_call1 (val, Flist (nargs, args)); ++ /* We use call1 rather than safe_call1 ++ so as to get bug reports about functions called here ++ which don't handle the current interface. */ ++ val = call1 (val, Flist (nargs, args)); + if (CONSP (val)) + return val; + if (SYMBOLP (val) && ! NILP (Fcoding_system_p (val))) + return Fcons (val, val); + } + return Qnil; + } + } + return Qnil; +} + +DEFUN ("set-coding-system-priority", Fset_coding_system_priority, + Sset_coding_system_priority, 0, MANY, 0, + doc: /* Assign higher priority to the coding systems given as arguments. +If multiple coding systems belongs to the same category, +all but the first one are ignored. + +usage: (set-coding-system-priority ...) */) + (nargs, args) + int nargs; + Lisp_Object *args; +{ + int i, j; + int changed[coding_category_max]; + enum coding_category priorities[coding_category_max]; + + bzero (changed, sizeof changed); + + for (i = j = 0; i < nargs; i++) + { + enum coding_category category; + Lisp_Object spec, attrs; + + CHECK_CODING_SYSTEM_GET_SPEC (args[i], spec); + attrs = AREF (spec, 0); + category = XINT (CODING_ATTR_CATEGORY (attrs)); + if (changed[category]) + /* Ignore this coding system because a coding system of the + same category already had a higher priority. */ + continue; + changed[category] = 1; + priorities[j++] = category; + if (coding_categories[category].id >= 0 + && ! EQ (args[i], CODING_ID_NAME (coding_categories[category].id))) + setup_coding_system (args[i], &coding_categories[category]); + Fset (AREF (Vcoding_category_table, category), args[i]); + } + + /* Now we have decided top J priorities. Reflect the order of the + original priorities to the remaining priorities. */ + + for (i = j, j = 0; i < coding_category_max; i++, j++) + { + while (j < coding_category_max + && changed[coding_priorities[j]]) + j++; + if (j == coding_category_max) + abort (); + priorities[i] = coding_priorities[j]; + } + + bcopy (priorities, coding_priorities, sizeof priorities); + + /* Update `coding-category-list'. */ + Vcoding_category_list = Qnil; + for (i = coding_category_max - 1; i >= 0; i--) + Vcoding_category_list + = Fcons (AREF (Vcoding_category_table, priorities[i]), + Vcoding_category_list); + + return Qnil; +} + +DEFUN ("coding-system-priority-list", Fcoding_system_priority_list, + Scoding_system_priority_list, 0, 1, 0, + doc: /* Return a list of coding systems ordered by their priorities. +HIGHESTP non-nil means just return the highest priority one. */) + (highestp) + Lisp_Object highestp; +{ + int i; + Lisp_Object val; + + for (i = 0, val = Qnil; i < coding_category_max; i++) + { + enum coding_category category = coding_priorities[i]; + int id = coding_categories[category].id; + Lisp_Object attrs; + + if (id < 0) + continue; + attrs = CODING_ID_ATTRS (id); + if (! NILP (highestp)) + return CODING_ATTR_BASE_NAME (attrs); + val = Fcons (CODING_ATTR_BASE_NAME (attrs), val); + } + return Fnreverse (val); +} + +static char *suffixes[] = { "-unix", "-dos", "-mac" }; + +static Lisp_Object +make_subsidiaries (base) + Lisp_Object base; +{ + Lisp_Object subsidiaries; + int base_name_len = SBYTES (SYMBOL_NAME (base)); + char *buf = (char *) alloca (base_name_len + 6); + int i; + + bcopy (SDATA (SYMBOL_NAME (base)), buf, base_name_len); + subsidiaries = Fmake_vector (make_number (3), Qnil); + for (i = 0; i < 3; i++) + { + bcopy (suffixes[i], buf + base_name_len, strlen (suffixes[i]) + 1); + ASET (subsidiaries, i, intern (buf)); + } + return subsidiaries; +} + + +DEFUN ("define-coding-system-internal", Fdefine_coding_system_internal, + Sdefine_coding_system_internal, coding_arg_max, MANY, 0, + doc: /* For internal use only. +usage: (define-coding-system-internal ...) */) + (nargs, args) + int nargs; + Lisp_Object *args; +{ + Lisp_Object name; + Lisp_Object spec_vec; /* [ ATTRS ALIASE EOL_TYPE ] */ + Lisp_Object attrs; /* Vector of attributes. */ + Lisp_Object eol_type; + Lisp_Object aliases; + Lisp_Object coding_type, charset_list, safe_charsets; + enum coding_category category; + Lisp_Object tail, val; + int max_charset_id = 0; + int i; + + if (nargs < coding_arg_max) + goto short_args; + + attrs = Fmake_vector (make_number (coding_attr_last_index), Qnil); + + name = args[coding_arg_name]; + CHECK_SYMBOL (name); + CODING_ATTR_BASE_NAME (attrs) = name; + + val = args[coding_arg_mnemonic]; + if (! STRINGP (val)) + CHECK_CHARACTER (val); + CODING_ATTR_MNEMONIC (attrs) = val; + + coding_type = args[coding_arg_coding_type]; + CHECK_SYMBOL (coding_type); + CODING_ATTR_TYPE (attrs) = coding_type; + + charset_list = args[coding_arg_charset_list]; + if (SYMBOLP (charset_list)) + { + if (EQ (charset_list, Qiso_2022)) + { + if (! EQ (coding_type, Qiso_2022)) + error ("Invalid charset-list"); + charset_list = Viso_2022_charset_list; + } + else if (EQ (charset_list, Qemacs_mule)) + { + if (! EQ (coding_type, Qemacs_mule)) + error ("Invalid charset-list"); + charset_list = Vemacs_mule_charset_list; + } + for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) + if (max_charset_id < XFASTINT (XCAR (tail))) + max_charset_id = XFASTINT (XCAR (tail)); + } + else + { + charset_list = Fcopy_sequence (charset_list); + for (tail = charset_list; !NILP (tail); tail = Fcdr (tail)) + { + struct charset *charset; + + val = Fcar (tail); + CHECK_CHARSET_GET_CHARSET (val, charset); + if (EQ (coding_type, Qiso_2022) + ? CHARSET_ISO_FINAL (charset) < 0 + : EQ (coding_type, Qemacs_mule) + ? CHARSET_EMACS_MULE_ID (charset) < 0 + : 0) + error ("Can't handle charset `%s'", + SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); + + XSETCAR (tail, make_number (charset->id)); + if (max_charset_id < charset->id) + max_charset_id = charset->id; + } + } + CODING_ATTR_CHARSET_LIST (attrs) = charset_list; + + safe_charsets = Fmake_string (make_number (max_charset_id + 1), + make_number (255)); + for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) + SSET (safe_charsets, XFASTINT (XCAR (tail)), 0); + CODING_ATTR_SAFE_CHARSETS (attrs) = safe_charsets; + + CODING_ATTR_ASCII_COMPAT (attrs) = args[coding_arg_ascii_compatible_p]; + + val = args[coding_arg_decode_translation_table]; + if (! CHAR_TABLE_P (val) && ! CONSP (val)) + CHECK_SYMBOL (val); + CODING_ATTR_DECODE_TBL (attrs) = val; + + val = args[coding_arg_encode_translation_table]; + if (! CHAR_TABLE_P (val) && ! CONSP (val)) + CHECK_SYMBOL (val); + CODING_ATTR_ENCODE_TBL (attrs) = val; + + val = args[coding_arg_post_read_conversion]; + CHECK_SYMBOL (val); + CODING_ATTR_POST_READ (attrs) = val; + + val = args[coding_arg_pre_write_conversion]; + CHECK_SYMBOL (val); + CODING_ATTR_PRE_WRITE (attrs) = val; + + val = args[coding_arg_default_char]; + if (NILP (val)) + CODING_ATTR_DEFAULT_CHAR (attrs) = make_number (' '); + else + { + CHECK_CHARACTER (val); + CODING_ATTR_DEFAULT_CHAR (attrs) = val; + } + + val = args[coding_arg_for_unibyte]; + CODING_ATTR_FOR_UNIBYTE (attrs) = NILP (val) ? Qnil : Qt; + + val = args[coding_arg_plist]; + CHECK_LIST (val); + CODING_ATTR_PLIST (attrs) = val; + + if (EQ (coding_type, Qcharset)) + { + /* Generate a lisp vector of 256 elements. Each element is nil, + integer, or a list of charset IDs. + + If Nth element is nil, the byte code N is invalid in this + coding system. + + If Nth element is a number NUM, N is the first byte of a + charset whose ID is NUM. + + If Nth element is a list of charset IDs, N is the first byte + of one of them. The list is sorted by dimensions of the + charsets. A charset of smaller dimension comes firtst. */ + val = Fmake_vector (make_number (256), Qnil); + + for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) + { + struct charset *charset = CHARSET_FROM_ID (XFASTINT (XCAR (tail))); + int dim = CHARSET_DIMENSION (charset); + int idx = (dim - 1) * 4; + + if (CHARSET_ASCII_COMPATIBLE_P (charset)) + CODING_ATTR_ASCII_COMPAT (attrs) = Qt; + + for (i = charset->code_space[idx]; + i <= charset->code_space[idx + 1]; i++) + { + Lisp_Object tmp, tmp2; + int dim2; + + tmp = AREF (val, i); + if (NILP (tmp)) + tmp = XCAR (tail); + else if (NUMBERP (tmp)) + { + dim2 = CHARSET_DIMENSION (CHARSET_FROM_ID (XFASTINT (tmp))); + if (dim < dim2) + tmp = Fcons (XCAR (tail), Fcons (tmp, Qnil)); + else + tmp = Fcons (tmp, Fcons (XCAR (tail), Qnil)); + } + else + { + for (tmp2 = tmp; CONSP (tmp2); tmp2 = XCDR (tmp2)) + { + dim2 = CHARSET_DIMENSION (CHARSET_FROM_ID (XFASTINT (XCAR (tmp2)))); + if (dim < dim2) + break; + } + if (NILP (tmp2)) + tmp = nconc2 (tmp, Fcons (XCAR (tail), Qnil)); + else + { + XSETCDR (tmp2, Fcons (XCAR (tmp2), XCDR (tmp2))); + XSETCAR (tmp2, XCAR (tail)); + } + } + ASET (val, i, tmp); + } + } + ASET (attrs, coding_attr_charset_valids, val); + category = coding_category_charset; + } + else if (EQ (coding_type, Qccl)) + { + Lisp_Object valids; + + if (nargs < coding_arg_ccl_max) + goto short_args; -TARGET has a meaning which depends on OPERATION: - For file I/O, TARGET is a file name (except for the special case below). - For process I/O, TARGET is a process name. - For network I/O, TARGET is a service name or a port number + val = args[coding_arg_ccl_decoder]; + CHECK_CCL_PROGRAM (val); + if (VECTORP (val)) + val = Fcopy_sequence (val); + ASET (attrs, coding_attr_ccl_decoder, val); -This function looks up what specified for TARGET in, -`file-coding-system-alist', `process-coding-system-alist', -or `network-coding-system-alist' depending on OPERATION. -They may specify a coding system, a cons of coding systems, -or a function symbol to call. -In the last case, we call the function with one argument, -which is a list of all the arguments given to this function. + val = args[coding_arg_ccl_encoder]; + CHECK_CCL_PROGRAM (val); + if (VECTORP (val)) + val = Fcopy_sequence (val); + ASET (attrs, coding_attr_ccl_encoder, val); -If OPERATION is `insert-file-contents', the argument corresponding to -TARGET may be a cons (FILENAME . BUFFER). In that case, FILENAME is a -file name to look up, and BUFFER is a buffer that contains the file's -contents (not yet decoded). If `file-coding-system-alist' specifies a -function to call for FILENAME, that function should examine the -contents of BUFFER instead of reading the file. + val = args[coding_arg_ccl_valids]; + valids = Fmake_string (make_number (256), make_number (0)); + for (tail = val; !NILP (tail); tail = Fcdr (tail)) + { + int from, to; -usage: (find-operation-coding-system OPERATION ARGUMENTS ...) */) - (nargs, args) - int nargs; - Lisp_Object *args; -{ - Lisp_Object operation, target_idx, target, val; - register Lisp_Object chain; + val = Fcar (tail); + if (INTEGERP (val)) + { + from = to = XINT (val); + if (from < 0 || from > 255) + args_out_of_range_3 (val, make_number (0), make_number (255)); + } + else + { + CHECK_CONS (val); + CHECK_NATNUM_CAR (val); + CHECK_NATNUM_CDR (val); + from = XINT (XCAR (val)); + if (from > 255) + args_out_of_range_3 (XCAR (val), + make_number (0), make_number (255)); + to = XINT (XCDR (val)); + if (to < from || to > 255) + args_out_of_range_3 (XCDR (val), + XCAR (val), make_number (255)); + } + for (i = from; i <= to; i++) + SSET (valids, i, 1); + } + ASET (attrs, coding_attr_ccl_valids, valids); - if (nargs < 2) - error ("Too few arguments"); - operation = args[0]; - if (!SYMBOLP (operation) - || !INTEGERP (target_idx = Fget (operation, Qtarget_idx))) - error ("Invalid first argument"); - if (nargs < 1 + XINT (target_idx)) - error ("Too few arguments for operation: %s", - SDATA (SYMBOL_NAME (operation))); - /* For write-region, if the 6th argument (i.e. VISIT, the 5th - argument to write-region) is string, it must be treated as a - target file name. */ - if (EQ (operation, Qwrite_region) - && nargs > 5 - && STRINGP (args[5])) - target_idx = make_number (4); - target = args[XINT (target_idx) + 1]; - if (!(STRINGP (target) - || (EQ (operation, Qinsert_file_contents) && CONSP (target) - && STRINGP (XCAR (target)) && BUFFERP (XCDR (target))) - || (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) - error ("Invalid argument %d", XINT (target_idx) + 1); - if (CONSP (target)) - target = XCAR (target); + category = coding_category_ccl; + } + else if (EQ (coding_type, Qutf_16)) + { + Lisp_Object bom, endian; - chain = ((EQ (operation, Qinsert_file_contents) - || EQ (operation, Qwrite_region)) - ? Vfile_coding_system_alist - : (EQ (operation, Qopen_network_stream) - ? Vnetwork_coding_system_alist - : Vprocess_coding_system_alist)); - if (NILP (chain)) - return Qnil; + CODING_ATTR_ASCII_COMPAT (attrs) = Qnil; - for (; CONSP (chain); chain = XCDR (chain)) - { - Lisp_Object elt; - elt = XCAR (chain); + if (nargs < coding_arg_utf16_max) + goto short_args; - if (CONSP (elt) - && ((STRINGP (target) - && STRINGP (XCAR (elt)) - && fast_string_match (XCAR (elt), target) >= 0) - || (INTEGERP (target) && EQ (target, XCAR (elt))))) + bom = args[coding_arg_utf16_bom]; + if (! NILP (bom) && ! EQ (bom, Qt)) { - val = XCDR (elt); - /* Here, if VAL is both a valid coding system and a valid - function symbol, we return VAL as a coding system. */ - if (CONSP (val)) - return val; - if (! SYMBOLP (val)) - return Qnil; - if (! NILP (Fcoding_system_p (val))) - return Fcons (val, val); - if (! NILP (Ffboundp (val))) + CHECK_CONS (bom); + val = XCAR (bom); + CHECK_CODING_SYSTEM (val); + val = XCDR (bom); + CHECK_CODING_SYSTEM (val); + } + ASET (attrs, coding_attr_utf_16_bom, bom); + + endian = args[coding_arg_utf16_endian]; + CHECK_SYMBOL (endian); + if (NILP (endian)) + endian = Qbig; + else if (! EQ (endian, Qbig) && ! EQ (endian, Qlittle)) + error ("Invalid endian: %s", SDATA (SYMBOL_NAME (endian))); + ASET (attrs, coding_attr_utf_16_endian, endian); + + category = (CONSP (bom) + ? coding_category_utf_16_auto + : NILP (bom) + ? (EQ (endian, Qbig) + ? coding_category_utf_16_be_nosig + : coding_category_utf_16_le_nosig) + : (EQ (endian, Qbig) + ? coding_category_utf_16_be + : coding_category_utf_16_le)); + } + else if (EQ (coding_type, Qiso_2022)) + { + Lisp_Object initial, reg_usage, request, flags; + int i; + + if (nargs < coding_arg_iso2022_max) + goto short_args; + + initial = Fcopy_sequence (args[coding_arg_iso2022_initial]); + CHECK_VECTOR (initial); + for (i = 0; i < 4; i++) + { + val = Faref (initial, make_number (i)); + if (! NILP (val)) { - /* We use call1 rather than safe_call1 - so as to get bug reports about functions called here - which don't handle the current interface. */ - val = call1 (val, Flist (nargs, args)); - if (CONSP (val)) - return val; - if (SYMBOLP (val) && ! NILP (Fcoding_system_p (val))) - return Fcons (val, val); + struct charset *charset; + + CHECK_CHARSET_GET_CHARSET (val, charset); + ASET (initial, i, make_number (CHARSET_ID (charset))); + if (i == 0 && CHARSET_ASCII_COMPATIBLE_P (charset)) + CODING_ATTR_ASCII_COMPAT (attrs) = Qt; } - return Qnil; + else + ASET (initial, i, make_number (-1)); } - } - return Qnil; -} -DEFUN ("update-coding-systems-internal", Fupdate_coding_systems_internal, - Supdate_coding_systems_internal, 0, 0, 0, - doc: /* Update internal database for ISO2022 and CCL based coding systems. -When values of any coding categories are changed, you must -call this function. */) - () -{ - int i; + reg_usage = args[coding_arg_iso2022_reg_usage]; + CHECK_CONS (reg_usage); + CHECK_NUMBER_CAR (reg_usage); + CHECK_NUMBER_CDR (reg_usage); + + request = Fcopy_sequence (args[coding_arg_iso2022_request]); + for (tail = request; ! NILP (tail); tail = Fcdr (tail)) + { + int id; + Lisp_Object tmp; + + val = Fcar (tail); + CHECK_CONS (val); + tmp = XCAR (val); + CHECK_CHARSET_GET_ID (tmp, id); + CHECK_NATNUM_CDR (val); + if (XINT (XCDR (val)) >= 4) + error ("Invalid graphic register number: %d", XINT (XCDR (val))); + XSETCAR (val, make_number (id)); + } - for (i = CODING_CATEGORY_IDX_EMACS_MULE; i < CODING_CATEGORY_IDX_MAX; i++) + flags = args[coding_arg_iso2022_flags]; + CHECK_NATNUM (flags); + i = XINT (flags); + if (EQ (args[coding_arg_charset_list], Qiso_2022)) + flags = make_number (i | CODING_ISO_FLAG_FULL_SUPPORT); + + ASET (attrs, coding_attr_iso_initial, initial); + ASET (attrs, coding_attr_iso_usage, reg_usage); + ASET (attrs, coding_attr_iso_request, request); + ASET (attrs, coding_attr_iso_flags, flags); + setup_iso_safe_charsets (attrs); + + if (i & CODING_ISO_FLAG_SEVEN_BITS) + category = ((i & (CODING_ISO_FLAG_LOCKING_SHIFT + | CODING_ISO_FLAG_SINGLE_SHIFT)) + ? coding_category_iso_7_else + : EQ (args[coding_arg_charset_list], Qiso_2022) + ? coding_category_iso_7 + : coding_category_iso_7_tight); + else + { + int id = XINT (AREF (initial, 1)); + + category = (((i & CODING_ISO_FLAG_LOCKING_SHIFT) + || EQ (args[coding_arg_charset_list], Qiso_2022) + || id < 0) + ? coding_category_iso_8_else + : (CHARSET_DIMENSION (CHARSET_FROM_ID (id)) == 1) + ? coding_category_iso_8_1 + : coding_category_iso_8_2); + } + if (category != coding_category_iso_8_1 + && category != coding_category_iso_8_2) + CODING_ATTR_ASCII_COMPAT (attrs) = Qnil; + } + else if (EQ (coding_type, Qemacs_mule)) { - Lisp_Object val; + if (EQ (args[coding_arg_charset_list], Qemacs_mule)) + ASET (attrs, coding_attr_emacs_mule_full, Qt); + CODING_ATTR_ASCII_COMPAT (attrs) = Qt; + category = coding_category_emacs_mule; + } + else if (EQ (coding_type, Qshift_jis)) + { + + struct charset *charset; - val = SYMBOL_VALUE (XVECTOR (Vcoding_category_table)->contents[i]); - if (!NILP (val)) + if (XINT (Flength (charset_list)) != 3 + && XINT (Flength (charset_list)) != 4) + error ("There should be three or four charsets"); + + charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); + if (CHARSET_DIMENSION (charset) != 1) + error ("Dimension of charset %s is not one", + SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); + if (CHARSET_ASCII_COMPATIBLE_P (charset)) + CODING_ATTR_ASCII_COMPAT (attrs) = Qt; + + charset_list = XCDR (charset_list); + charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); + if (CHARSET_DIMENSION (charset) != 1) + error ("Dimension of charset %s is not one", + SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); + + charset_list = XCDR (charset_list); + charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); + if (CHARSET_DIMENSION (charset) != 2) + error ("Dimension of charset %s is not two", + SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); + + charset_list = XCDR (charset_list); + if (! NILP (charset_list)) { - if (! coding_system_table[i]) - coding_system_table[i] = ((struct coding_system *) - xmalloc (sizeof (struct coding_system))); - setup_coding_system (val, coding_system_table[i]); + charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); + if (CHARSET_DIMENSION (charset) != 2) + error ("Dimension of charset %s is not two", + SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); } - else if (coding_system_table[i]) + + category = coding_category_sjis; + Vsjis_coding_system = name; + } + else if (EQ (coding_type, Qbig5)) + { + struct charset *charset; + + if (XINT (Flength (charset_list)) != 2) + error ("There should be just two charsets"); + + charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); + if (CHARSET_DIMENSION (charset) != 1) + error ("Dimension of charset %s is not one", + SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); + if (CHARSET_ASCII_COMPATIBLE_P (charset)) + CODING_ATTR_ASCII_COMPAT (attrs) = Qt; + + charset_list = XCDR (charset_list); + charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); + if (CHARSET_DIMENSION (charset) != 2) + error ("Dimension of charset %s is not two", + SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); + + category = coding_category_big5; + Vbig5_coding_system = name; + } + else if (EQ (coding_type, Qraw_text)) + { + category = coding_category_raw_text; + CODING_ATTR_ASCII_COMPAT (attrs) = Qt; + } + else if (EQ (coding_type, Qutf_8)) + { + category = coding_category_utf_8; + CODING_ATTR_ASCII_COMPAT (attrs) = Qt; + } + else if (EQ (coding_type, Qundecided)) + category = coding_category_undecided; + else + error ("Invalid coding system type: %s", + SDATA (SYMBOL_NAME (coding_type))); + + CODING_ATTR_CATEGORY (attrs) = make_number (category); + CODING_ATTR_PLIST (attrs) + = Fcons (QCcategory, Fcons (AREF (Vcoding_category_table, category), + CODING_ATTR_PLIST (attrs))); + CODING_ATTR_PLIST (attrs) + = Fcons (QCascii_compatible_p, + Fcons (CODING_ATTR_ASCII_COMPAT (attrs), + CODING_ATTR_PLIST (attrs))); + + eol_type = args[coding_arg_eol_type]; + if (! NILP (eol_type) + && ! EQ (eol_type, Qunix) + && ! EQ (eol_type, Qdos) + && ! EQ (eol_type, Qmac)) + error ("Invalid eol-type"); + + aliases = Fcons (name, Qnil); + + if (NILP (eol_type)) + { + eol_type = make_subsidiaries (name); + for (i = 0; i < 3; i++) { - xfree (coding_system_table[i]); - coding_system_table[i] = NULL; + Lisp_Object this_spec, this_name, this_aliases, this_eol_type; + + this_name = AREF (eol_type, i); + this_aliases = Fcons (this_name, Qnil); + this_eol_type = (i == 0 ? Qunix : i == 1 ? Qdos : Qmac); + this_spec = Fmake_vector (make_number (3), attrs); + ASET (this_spec, 1, this_aliases); + ASET (this_spec, 2, this_eol_type); + Fputhash (this_name, this_spec, Vcoding_system_hash_table); + Vcoding_system_list = Fcons (this_name, Vcoding_system_list); + val = Fassoc (Fsymbol_name (this_name), Vcoding_system_alist); + if (NILP (val)) + Vcoding_system_alist + = Fcons (Fcons (Fsymbol_name (this_name), Qnil), + Vcoding_system_alist); } }