• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/international/

Lines Matching +defs:after +defs:find +defs:file +defs:from +defs:revert +defs:buffer

12 ;; This file is part of GNU Emacs.
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
39 (defun load-with-code-conversion (fullname file &optional noerror nomessage)
40 "Execute a file of Lisp code named FILE whose absolute name is FULLNAME.
41 The file contents are decoded before evaluation if necessary.
46 Return t if file exists."
47 (if (null (file-readable-p fullname))
49 (signal 'file-error (list "Cannot open load file" file)))
50 ;; Read file with code conversion, and then eval.
51 (let* ((buffer
55 ;; file is encoded in some complicated character set,
56 ;; read it with real decoding, as a multibyte buffer,
60 ;; We can't use `generate-new-buffer' because files.el
62 (get-buffer-create (generate-new-buffer-name " *load*"))))
67 (message "Loading %s (source)..." file)
68 (message "Loading %s..." file)))
70 (push file preloaded-file-list))
72 (let ((load-file-name fullname)
74 (inhibit-file-name-operation nil))
75 (with-current-buffer buffer
78 (insert-file-contents fullname))
79 ;; If the loaded file was inserted with no-conversion or
80 ;; raw-text coding system, make the buffer unibyte.
81 ;; Otherwise, eval-buffer might try to interpret random
86 (set-buffer-multibyte nil))
87 ;; Make `kill-buffer' quiet.
88 (set-buffer-modified-p nil))
89 ;; Have the original buffer current while we eval.
90 (eval-buffer buffer nil
92 (if purify-flag file fullname)
95 ;; after reading them.
99 (let (kill-buffer-hook kill-buffer-query-functions)
100 (kill-buffer buffer)))
102 (do-after-load-evaluation fullname))
106 (message "Loading %s (source)...done" file)
107 (message "Loading %s...done" file)))
142 charset when rendering. If 0, render from left to right, else
143 render from right to left.
156 LEFT-TO-RIGHT value from the charset. If there's no such a
166 ;; It is better not to use backquote in this file,
401 ;; Code copied from copy-case-table to avoid requiring case-table.el
491 "Extract a value from CODING-SYSTEM's property list for property PROP."
590 made from bases and aliases automatically for various end-of-line
800 The value is a function to call after some text is inserted and
802 `after-insert-functions' are called. The argument of this
804 `after-insert-file-functions', i.e. LENGTH of the text inserted,
809 The value is a function to call after all functions in
810 `write-region-annotate-functions' and `buffer-file-format' are
855 file. Each element of the list is an integer or a cons of integer.
1027 ;; If only safe-charsets is specified, make a char-table from
1147 "Fill in any unspecified aspects of coding system FIRST from SECOND.
1173 (defun set-buffer-file-coding-system (coding-system &optional force nomodify)
1174 "Set the file coding-system of the current buffer to CODING-SYSTEM.
1175 This means that when you save the buffer, it will be converted
1181 do. If FORCE is nil, get the unspecified aspect (or aspects) from the
1182 buffer's previous `buffer-file-coding-system' value (if it is
1185 This marks the buffer modified so that the succeeding \\[save-buffer]
1186 surely saves the buffer with CODING-SYSTEM. From a program, if you
1187 don't want to mark the buffer modified, specify t for NOMODIFY.
1189 just set the variable `buffer-file-coding-system' directly."
1190 (interactive "zCoding system for saving file (default nil): \nP")
1192 (if (and coding-system buffer-file-coding-system (null force))
1194 (merge-coding-systems coding-system buffer-file-coding-system)))
1195 (setq buffer-file-coding-system coding-system)
1197 ;; `set-buffer-major-mode-hook' take care of setting the table.
1201 (set-buffer-modified-p t))
1204 (defun revert-buffer-with-coding-system (coding-system &optional force)
1205 "Visit the current buffer's file again using coding system CODING-SYSTEM.
1210 do. If FORCE is nil, get the unspecified aspect (or aspects) from the
1211 buffer's previous `buffer-file-coding-system' value (if it is
1212 specified there). Otherwise, determine it from the file contents as
1213 usual for visiting a file."
1214 (interactive "zCoding system for visited file (default nil): \nP")
1216 (if (and coding-system buffer-file-coding-system (null force))
1218 (merge-coding-systems coding-system buffer-file-coding-system)))
1220 (revert-buffer)))
1222 (defun set-file-name-coding-system (coding-system)
1223 "Set coding system for decoding and encoding file names to CODING-SYSTEM.
1224 It actually just set the variable `file-name-coding-system' (which
1226 (interactive "zCoding system for file names (default nil): ")
1231 (setq file-name-coding-system coding-system))
1296 If you set this on a terminal which can't distinguish Meta keys from
1300 On non-windowing terminals, this is set from the locale by default.
1316 (defun set-buffer-process-coding-system (decoding encoding)
1317 "Set coding systems for the process associated with the current buffer.
1318 DECODING is the coding system to be used to decode input from the process,
1323 "zCoding-system for output from the process: \nzCoding-system for input to the process: ")
1324 (let ((proc (get-buffer-process (current-buffer))))
1369 ;; ARG from CURRENT-LIST. We assume that CODING-CATEGORY-LIST
1397 characters into (or from) the extended segment.
1440 (in-workbuf (string= (buffer-name) " *code-converting-work*"))
1446 (set-buffer-multibyte t))
1452 (let* ((M (char-after (+ pos 4)))
1453 (L (char-after (+ pos 5)))
1504 (defun ctext-pre-write-conversion (from to)
1507 If FROM is a string, or if the current buffer is not the one set up for us
1508 by encode-coding-string, generate a new temp buffer, insert the
1509 text, and convert it in the temporary buffer. Otherwise, convert in-place."
1511 (let ((workbuf (get-buffer-create " *code-conversion-work*")))
1512 ;; Setup a working buffer if necessary.
1513 (cond ((stringp from)
1514 (set-buffer workbuf)
1515 (erase-buffer)
1516 (set-buffer-multibyte (multibyte-string-p from))
1517 (insert from))
1518 ((not (eq (current-buffer) workbuf))
1519 (let ((buf (current-buffer))
1521 (set-buffer workbuf)
1522 (erase-buffer)
1523 (set-buffer-multibyte multibyte)
1524 (insert-buffer-substring buf from to)))))
1526 ;; Now we can encode the whole buffer.
1536 last-encoding-info (aref encoding-table (char-after last-pos)))
1595 A file whose name matches REGEXP is decoded by CODING-SYSTEM on reading.
1598 in the file (see the function `set-auto-coding')
1599 and the contents of `file-coding-system-alist'."
1612 A file whose first bytes match REGEXP is decoded by CODING-SYSTEM on reading.
1615 in the file (see the function `set-auto-coding')
1616 and the contents of `file-coding-system-alist'."
1622 (defun auto-coding-regexp-alist-lookup (from to)
1623 "Lookup `auto-coding-regexp-alist' for the contents of the current buffer.
1627 (goto-char from)
1639 ;; See the bottom of this file for built-in auto coding functions.
1645 current buffer, but should not modify it in any way. The buffer
1646 will contain undecoded text of parts of the file. Each function
1648 characters (starting from point) it should look at.
1654 If a file has a `coding:' tag, that takes precedence over these
1678 (defun find-auto-coding (filename size)
1679 "Find a coding system for a file FILENAME of which SIZE bytes follow point.
1680 These bytes should include at least the first 1k of the file
1681 and the last 3k of the file, but the middle may be omitted.
1685 contents of the current buffer following point against
1762 ;; line. The suffix is what comes after "local variables:"
1826 "Return coding system for a file FILENAME of which SIZE bytes follow point.
1827 See `find-auto-coding' for how the coding system is found.
1832 (let ((found (find-auto-coding filename size)))
1839 ;; (1) A file is read by a coding system specified explicitly.
1840 ;; after-insert-file-set-coding sets this value to
1842 ;; (2) A buffer is saved.
1843 ;; After writing, basic-save-buffer-1 sets this value to
1845 ;; This variable is used for decoding in revert-buffer.
1846 (defvar buffer-file-coding-system-explicit nil
1847 "The file coding system explicitly specified for the current buffer.
1849 (make-variable-buffer-local 'buffer-file-coding-system-explicit)
1850 (put 'buffer-file-coding-system-explicit 'permanent-local t)
1852 (defun after-insert-file-set-coding (inserted &optional visit)
1853 "Set `buffer-file-coding-system' of current buffer after text is inserted.
1856 inserted, as figured in the situation after. The two numbers can be
1857 different if the buffer has become unibyte.
1858 The optional second arg VISIT non-nil means that we are visiting a file."
1862 (setq buffer-file-coding-system-explicit coding-system-for-read))
1865 (find-new-buffer-file-coding-system last-coding-system-used))
1866 (modified-p (buffer-modified-p)))
1868 ;; Tell set-buffer-file-coding-system not to mark the file
1872 (set-buffer-file-coding-system coding-system t t)
1876 ;; If buffer was unmodified and the size is the
1879 (= (buffer-size) inserted))
1881 ;; edit the buffer as unibyte.
1884 (buffer-file-name nil))
1886 ;; If we're doing this for find-file,
1888 ;; part of producing the buffer's initial contents.
1889 (let ((buffer-undo-list t))
1890 (set-buffer-multibyte nil))
1891 (set-buffer-multibyte nil))
1893 (restore-buffer-modified-p modified-p))))
1898 ;; 1. That of buffer-file-coding-system locally bound.
1901 (defun find-new-buffer-file-coding-system (coding)
1902 "Return a coding system for a buffer when a file of CODING is inserted.
1903 The local variable `buffer-file-coding-system' of the current buffer
1905 Return nil if there's no need to set `buffer-file-coding-system'."
1913 ;; Get information of `buffer-file-coding-system' in LOCAL-EOL
1915 (setq local-eol (coding-system-eol-type buffer-file-coding-system))
1919 (if (and buffer-file-coding-system
1920 (not (eq (coding-system-type buffer-file-coding-system) t)))
1922 (setq local-coding (coding-system-base buffer-file-coding-system)))
1924 (if (and (local-variable-p 'buffer-file-coding-system)
1926 ;; The current buffer has already set full coding-system, we
1946 (setq new-coding (if (local-variable-p 'buffer-file-coding-system)
1949 (setq new-eol (if (local-variable-p 'buffer-file-coding-system)
1960 There are three of such tables, `file-coding-system-alist',
1964 If it is `file', it affects `file-coding-system-alist' (which see).
1969 The target is a file name if TARGET-TYPE is `file', a program name if
1977 (or (memq target-type '(file process network))
1989 (cond ((eq target-type 'file)
1990 (let ((slot (assoc regexp file-coding-system-alist)))
1993 (setq file-coding-system-alist
1995 file-coding-system-alist)))))
2011 (defun decode-coding-inserted-region (from to filename
2013 "Decode the region between FROM and TO as if it is read from file FILENAME.
2016 of the function `insert-file-contents'.
2017 Part of the job of this function is setting `buffer-undo-list' appropriately."
2024 ;; text of a visited file.
2025 (setq buffer-undo-list t)
2029 (let ((last (car-safe buffer-undo-list)))
2030 (if (and (consp last) (eql (car last) from) (eql (cdr last) to))
2031 (setq undo-list-saved (cdr buffer-undo-list)
2032 buffer-undo-list t))))
2033 (narrow-to-region from to)
2039 (setq coding (car (find-operation-coding-system
2040 'insert-file-contents
2041 (cons filename (current-buffer))
2051 ;; If we're decoding the text of a visited file,
2054 (setq buffer-undo-list nil)
2058 (setq buffer-undo-list
2059 (cons (cons from (point-max)) undo-list-saved))))))))
2066 (let ((coding (or buffer-file-coding-system last-coding-system-used)))
2081 "Make a translation table from arguments.
2102 (let* ((from (car (car elts)))
2103 (from-i 0) ; degree of freedom of FROM
2104 (from-rev (nreverse (split-char from)))
2109 (while (eq (car from-rev) 0)
2110 (setq from-i (1+ from-i) from-rev (cdr from-rev)))
2113 (if (and (/= from-i to-i) (/= to-i 0))
2114 (error "Invalid character pair (%d . %d)" from to))
2123 (if (> from-i 0)
2124 (set-char-table-default table from to)
2125 (aset table from to))
2128 (let ((l (assq from revlist)))
2139 (setcdr l (cons from (cdr l)))
2140 (setq revlist (cons (list to from) revlist)))))
2146 (defun make-translation-table-from-vector (vec)
2147 "Make translation table from decoding vector VEC.
2233 "Evaluate BODY with category table of current buffer set to TABLE.
2234 The category table of the current buffer is saved, BODY is evaluated,
2238 (old-buffer (make-symbol "old-buffer")))
2240 (,old-buffer (current-buffer)))
2245 (with-current-buffer ,old-buffer
2287 "Determine whether the buffer is XML, and if so, its encoding.
2305 "If the buffer has an HTML meta tag, use it to determine encoding.
2314 ;; Make sure that the buffer really contains an HTML document, by