2021-01-05 01:57:42 +00:00
|
|
|
;;; format.el --- read and save files in multiple formats -*- lexical-binding: t; -*-
|
1996-01-14 07:34:30 +00:00
|
|
|
|
2021-01-01 09:13:56 +00:00
|
|
|
;; Copyright (C) 1994-1995, 1997, 1999, 2001-2021 Free Software
|
2013-01-01 09:11:05 +00:00
|
|
|
;; Foundation, Inc.
|
1995-03-17 18:14:30 +00:00
|
|
|
|
1999-01-23 21:52:40 +00:00
|
|
|
;; Author: Boris Goldowsky <boris@gnu.org>
|
2010-08-29 16:17:13 +00:00
|
|
|
;; Package: emacs
|
1995-03-17 18:14:30 +00:00
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1995-03-17 18:14:30 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:06:51 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
1996-01-14 07:34:30 +00:00
|
|
|
|
1995-03-17 18:14:30 +00:00
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
1996-01-14 07:34:30 +00:00
|
|
|
|
1995-03-17 18:14:30 +00:00
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 22:52:52 +00:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
1995-03-17 18:14:30 +00:00
|
|
|
|
|
|
|
;;; Commentary:
|
1996-01-14 07:34:30 +00:00
|
|
|
|
|
|
|
;; This file defines a unified mechanism for saving & loading files stored
|
|
|
|
;; in different formats. `format-alist' contains information that directs
|
1995-03-17 18:14:30 +00:00
|
|
|
;; Emacs to call an encoding or decoding function when reading or writing
|
1999-01-23 21:52:40 +00:00
|
|
|
;; files that match certain conditions.
|
1995-03-17 18:14:30 +00:00
|
|
|
;;
|
1996-01-14 07:34:30 +00:00
|
|
|
;; When a file is visited, its format is determined by matching the
|
|
|
|
;; beginning of the file against regular expressions stored in
|
|
|
|
;; `format-alist'. If this fails, you can manually translate the buffer
|
|
|
|
;; using `format-decode-buffer'. In either case, the formats used are
|
|
|
|
;; listed in the variable `buffer-file-format', and become the default
|
|
|
|
;; format for saving the buffer. To save a buffer in a different format,
|
|
|
|
;; change this variable, or use `format-write-file'.
|
1995-03-17 18:14:30 +00:00
|
|
|
;;
|
|
|
|
;; Auto-save files are normally created in the same format as the visited
|
2004-09-08 02:44:32 +00:00
|
|
|
;; file, but the variable `buffer-auto-save-file-format' can be set to a
|
1996-01-14 07:34:30 +00:00
|
|
|
;; particularly fast or otherwise preferred format to be used for
|
|
|
|
;; auto-saving (or nil to do no encoding on auto-save files, but then you
|
|
|
|
;; risk losing any text-properties in the buffer).
|
1995-03-17 18:14:30 +00:00
|
|
|
;;
|
1996-01-14 07:34:30 +00:00
|
|
|
;; You can manually translate a buffer into or out of a particular format
|
|
|
|
;; with the functions `format-encode-buffer' and `format-decode-buffer'.
|
|
|
|
;; To translate just the region use the functions `format-encode-region'
|
1999-01-23 21:52:40 +00:00
|
|
|
;; and `format-decode-region'.
|
1995-03-17 18:14:30 +00:00
|
|
|
;;
|
1996-01-14 07:34:30 +00:00
|
|
|
;; You can define a new format by writing the encoding and decoding
|
|
|
|
;; functions, and adding an entry to `format-alist'. See enriched.el for
|
|
|
|
;; an example of how to implement a file format. There are various
|
|
|
|
;; functions defined in this file that may be useful for writing the
|
|
|
|
;; encoding and decoding functions:
|
|
|
|
;; * `format-annotate-region' and `format-deannotate-region' allow a
|
|
|
|
;; single alist of information to be used for encoding and decoding.
|
|
|
|
;; The alist defines a correspondence between strings in the file
|
|
|
|
;; ("annotations") and text-properties in the buffer.
|
1995-03-17 18:14:30 +00:00
|
|
|
;; * `format-replace-strings' is similarly useful for doing simple
|
|
|
|
;; string->string translations in a reversible manner.
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
;;; Code:
|
|
|
|
|
1995-03-17 18:14:30 +00:00
|
|
|
(put 'buffer-file-format 'permanent-local t)
|
2004-09-08 02:44:32 +00:00
|
|
|
(put 'buffer-auto-save-file-format 'permanent-local t)
|
1995-03-17 18:14:30 +00:00
|
|
|
|
1999-01-23 21:52:40 +00:00
|
|
|
(defvar format-alist
|
2009-11-11 05:49:09 +00:00
|
|
|
;; FIXME: maybe each item can be purecopied instead of just the strings.
|
|
|
|
`((text/enriched ,(purecopy "Extended MIME text/enriched format.")
|
|
|
|
,(purecopy "Content-[Tt]ype:[ \t]*text/enriched")
|
1995-03-17 18:14:30 +00:00
|
|
|
enriched-decode enriched-encode t enriched-mode)
|
2009-11-11 05:49:09 +00:00
|
|
|
(plain ,(purecopy "ISO 8859-1 standard format, no text properties.")
|
1995-03-17 18:14:30 +00:00
|
|
|
;; Plain only exists so that there is an obvious neutral choice in
|
|
|
|
;; the completion list.
|
1997-06-04 19:06:35 +00:00
|
|
|
nil nil nil nil nil)
|
2009-11-11 05:49:09 +00:00
|
|
|
(TeX ,(purecopy "TeX (encoding)")
|
1999-01-23 21:52:40 +00:00
|
|
|
nil
|
1997-06-04 19:06:35 +00:00
|
|
|
iso-tex2iso iso-iso2tex t nil)
|
2009-11-11 05:49:09 +00:00
|
|
|
(gtex ,(purecopy "German TeX (encoding)")
|
1999-01-23 21:52:40 +00:00
|
|
|
nil
|
1997-06-04 19:06:35 +00:00
|
|
|
iso-gtex2iso iso-iso2gtex t nil)
|
2009-11-11 05:49:09 +00:00
|
|
|
(html ,(purecopy "HTML/SGML \"ISO 8879:1986//ENTITIES Added Latin 1//EN\" (encoding)")
|
1999-01-23 21:52:40 +00:00
|
|
|
nil
|
2000-03-29 18:37:25 +00:00
|
|
|
iso-sgml2iso iso-iso2sgml t nil)
|
2009-11-11 05:49:09 +00:00
|
|
|
(rot13 ,(purecopy "rot13")
|
1999-01-23 21:52:40 +00:00
|
|
|
nil
|
2017-10-24 05:01:14 +00:00
|
|
|
rot13-region rot13-region t nil)
|
2009-11-11 05:49:09 +00:00
|
|
|
(duden ,(purecopy "Duden Ersatzdarstellung")
|
1999-01-23 21:52:40 +00:00
|
|
|
nil
|
2009-11-11 05:49:09 +00:00
|
|
|
,(purecopy "diac") iso-iso2duden t nil)
|
|
|
|
(de646 ,(purecopy "German ASCII (ISO 646)")
|
1999-01-23 21:52:40 +00:00
|
|
|
nil
|
2011-04-19 13:44:55 +00:00
|
|
|
,(purecopy "recode -f iso646-ge:latin1")
|
2009-11-11 05:49:09 +00:00
|
|
|
,(purecopy "recode -f latin1:iso646-ge") t nil)
|
|
|
|
(denet ,(purecopy "net German")
|
1999-01-23 21:52:40 +00:00
|
|
|
nil
|
1997-06-04 19:06:35 +00:00
|
|
|
iso-german iso-cvt-read-only t nil)
|
2009-11-11 05:49:09 +00:00
|
|
|
(esnet ,(purecopy "net Spanish")
|
1999-01-23 21:52:40 +00:00
|
|
|
nil
|
1997-07-09 04:20:46 +00:00
|
|
|
iso-spanish iso-cvt-read-only t nil))
|
1995-03-17 18:14:30 +00:00
|
|
|
"List of information about understood file formats.
|
2008-11-20 02:44:05 +00:00
|
|
|
Elements are of the form
|
|
|
|
\(NAME DOC-STR REGEXP FROM-FN TO-FN MODIFY MODE-FN PRESERVE).
|
1997-08-09 08:01:07 +00:00
|
|
|
|
1995-03-17 18:14:30 +00:00
|
|
|
NAME is a symbol, which is stored in `buffer-file-format'.
|
1997-08-09 08:01:07 +00:00
|
|
|
|
1995-03-17 18:14:30 +00:00
|
|
|
DOC-STR should be a single line providing more information about the
|
|
|
|
format. It is currently unused, but in the future will be shown to
|
|
|
|
the user if they ask for more information.
|
1997-08-09 08:01:07 +00:00
|
|
|
|
1995-03-17 18:14:30 +00:00
|
|
|
REGEXP is a regular expression to match against the beginning of the file;
|
2009-08-25 03:03:27 +00:00
|
|
|
it should match only files in that format. REGEXP may be nil, in
|
|
|
|
which case the format will never be applied automatically to a file.
|
|
|
|
Use this for formats that you only ever want to apply manually.
|
1997-08-09 08:01:07 +00:00
|
|
|
|
2006-08-02 22:51:44 +00:00
|
|
|
FROM-FN is called to decode files in that format; it takes two args, BEGIN
|
1995-03-17 18:14:30 +00:00
|
|
|
and END, and can make any modifications it likes, returning the new
|
|
|
|
end. It must make sure that the beginning of the file no longer
|
|
|
|
matches REGEXP, or else it will get called again.
|
1997-08-09 08:01:07 +00:00
|
|
|
Alternatively, FROM-FN can be a string, which specifies a shell command
|
|
|
|
(including options) to be used as a filter to perform the conversion.
|
|
|
|
|
2006-08-02 22:51:44 +00:00
|
|
|
TO-FN is called to encode a region into that format; it takes three
|
1996-09-01 03:25:54 +00:00
|
|
|
arguments: BEGIN, END, and BUFFER. BUFFER is the original buffer that
|
|
|
|
the data being written came from, which the function could use, for
|
|
|
|
example, to find the values of local variables. TO-FN should either
|
|
|
|
return a list of annotations like `write-region-annotate-functions',
|
|
|
|
or modify the region and return the new end.
|
1997-08-09 08:01:07 +00:00
|
|
|
Alternatively, TO-FN can be a string, which specifies a shell command
|
|
|
|
(including options) to be used as a filter to perform the conversion.
|
|
|
|
|
1996-09-01 03:25:54 +00:00
|
|
|
MODIFY, if non-nil, means the TO-FN wants to modify the region. If nil,
|
|
|
|
TO-FN will not make any changes but will instead return a list of
|
1999-01-23 21:52:40 +00:00
|
|
|
annotations.
|
1997-08-09 08:01:07 +00:00
|
|
|
|
2001-06-15 07:26:20 +00:00
|
|
|
MODE-FN, if specified, is called when visiting a file with that format.
|
|
|
|
It is called with a single positive argument, on the assumption
|
2006-08-02 22:51:44 +00:00
|
|
|
that this would turn on some minor mode.
|
2002-06-11 19:26:45 +00:00
|
|
|
|
|
|
|
PRESERVE, if non-nil, means that `format-write-file' should not remove
|
2007-08-24 05:43:36 +00:00
|
|
|
this format from `buffer-file-format'.")
|
2009-10-15 06:18:02 +00:00
|
|
|
;;;###autoload
|
2009-08-26 03:07:25 +00:00
|
|
|
(put 'format-alist 'risky-local-variable t)
|
1995-03-17 18:14:30 +00:00
|
|
|
|
|
|
|
;;; Basic Functions (called from Lisp)
|
|
|
|
|
1997-06-04 19:06:35 +00:00
|
|
|
(defun format-encode-run-method (method from to &optional buffer)
|
2006-08-02 22:51:44 +00:00
|
|
|
"Translate using METHOD the text from FROM to TO.
|
|
|
|
If METHOD is a string, it is a shell command (including options);
|
1997-06-04 19:06:35 +00:00
|
|
|
otherwise, it should be a Lisp function.
|
|
|
|
BUFFER should be the buffer that the output originally came from."
|
|
|
|
(if (stringp method)
|
1999-01-23 21:52:40 +00:00
|
|
|
(let ((error-buff (get-buffer-create "*Format Errors*"))
|
1999-02-18 15:46:31 +00:00
|
|
|
(coding-system-for-read 'no-conversion)
|
1999-01-23 21:52:40 +00:00
|
|
|
format-alist)
|
|
|
|
(with-current-buffer error-buff
|
|
|
|
(widen)
|
|
|
|
(erase-buffer))
|
2000-08-17 20:24:27 +00:00
|
|
|
(if (and (zerop (save-window-excursion
|
|
|
|
(shell-command-on-region from to method t t
|
|
|
|
error-buff)))
|
1999-01-23 21:52:40 +00:00
|
|
|
;; gzip gives zero exit status with bad args, for instance.
|
|
|
|
(zerop (with-current-buffer error-buff
|
|
|
|
(buffer-size))))
|
|
|
|
(bury-buffer error-buff)
|
|
|
|
(switch-to-buffer-other-window error-buff)
|
2000-08-17 20:24:27 +00:00
|
|
|
(error "Format encoding failed")))
|
1997-06-04 19:06:35 +00:00
|
|
|
(funcall method from to buffer)))
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
(defun format-decode-run-method (method from to &optional _buffer)
|
2006-08-02 22:51:44 +00:00
|
|
|
"Decode using METHOD the text from FROM to TO.
|
|
|
|
If METHOD is a string, it is a shell command (including options); otherwise,
|
2011-04-19 13:44:55 +00:00
|
|
|
it should be a Lisp function. BUFFER is currently ignored."
|
1997-06-04 19:06:35 +00:00
|
|
|
(if (stringp method)
|
1999-01-23 21:52:40 +00:00
|
|
|
(let ((error-buff (get-buffer-create "*Format Errors*"))
|
1999-02-18 15:46:31 +00:00
|
|
|
(coding-system-for-write 'no-conversion)
|
1999-01-23 21:52:40 +00:00
|
|
|
format-alist)
|
|
|
|
(with-current-buffer error-buff
|
|
|
|
(widen)
|
|
|
|
(erase-buffer))
|
|
|
|
;; We should perhaps go via a temporary buffer and copy it
|
|
|
|
;; back, in case of errors.
|
|
|
|
(if (and (zerop (save-window-excursion
|
2021-06-01 08:22:57 +00:00
|
|
|
(shell-command-on-region from to method t 'no-mark
|
1999-01-23 21:52:40 +00:00
|
|
|
error-buff)))
|
|
|
|
;; gzip gives zero exit status with bad args, for instance.
|
|
|
|
(zerop (with-current-buffer error-buff
|
|
|
|
(buffer-size))))
|
|
|
|
(bury-buffer error-buff)
|
|
|
|
(switch-to-buffer-other-window error-buff)
|
|
|
|
(error "Format decoding failed"))
|
1997-06-04 19:06:35 +00:00
|
|
|
(point))
|
|
|
|
(funcall method from to)))
|
|
|
|
|
2000-08-17 20:24:27 +00:00
|
|
|
(defun format-annotate-function (format from to orig-buf format-count)
|
1999-01-23 21:52:40 +00:00
|
|
|
"Return annotations for writing region as FORMAT.
|
2006-08-02 22:51:44 +00:00
|
|
|
FORMAT is a symbol naming one of the formats defined in `format-alist'.
|
|
|
|
It must be a single symbol, not a list like `buffer-file-format'.
|
1996-09-01 03:25:54 +00:00
|
|
|
FROM and TO delimit the region to be operated on in the current buffer.
|
|
|
|
ORIG-BUF is the original buffer that the data came from.
|
2000-08-17 20:24:27 +00:00
|
|
|
|
|
|
|
FORMAT-COUNT is an integer specifying how many times this function has
|
|
|
|
been called in the process of decoding ORIG-BUF.
|
|
|
|
|
2006-08-02 22:51:44 +00:00
|
|
|
This function works like a function in `write-region-annotate-functions':
|
1995-03-17 18:14:30 +00:00
|
|
|
it either returns a list of annotations, or returns with a different buffer
|
2000-08-17 20:24:27 +00:00
|
|
|
current, which contains the modified text to write. In the latter case,
|
|
|
|
this function's value is nil.
|
1995-03-17 18:14:30 +00:00
|
|
|
|
|
|
|
For most purposes, consider using `format-encode-region' instead."
|
2000-08-17 20:24:27 +00:00
|
|
|
;; This function is called by write-region (actually
|
|
|
|
;; build_annotations) for each element of buffer-file-format.
|
1995-03-17 18:14:30 +00:00
|
|
|
(let* ((info (assq format format-alist))
|
|
|
|
(to-fn (nth 4 info))
|
|
|
|
(modify (nth 5 info)))
|
|
|
|
(if to-fn
|
|
|
|
(if modify
|
|
|
|
;; To-function wants to modify region. Copy to safe place.
|
2000-08-17 20:24:27 +00:00
|
|
|
(let ((copy-buf (get-buffer-create (format " *Format Temp %d*"
|
2002-06-21 09:53:47 +00:00
|
|
|
format-count)))
|
|
|
|
(sel-disp selective-display)
|
2003-05-14 21:30:21 +00:00
|
|
|
(multibyte enable-multibyte-characters)
|
|
|
|
(coding-system buffer-file-coding-system))
|
2002-06-21 09:53:47 +00:00
|
|
|
(with-current-buffer copy-buf
|
|
|
|
(setq selective-display sel-disp)
|
2003-05-14 21:30:21 +00:00
|
|
|
(set-buffer-multibyte multibyte)
|
|
|
|
(setq buffer-file-coding-system coding-system))
|
2013-07-27 00:29:42 +00:00
|
|
|
(let ((inhibit-read-only t)) ; bug#14887
|
|
|
|
(copy-to-buffer copy-buf from to)
|
|
|
|
(set-buffer copy-buf)
|
|
|
|
(format-insert-annotations write-region-annotations-so-far from)
|
|
|
|
(format-encode-run-method to-fn (point-min) (point-max)
|
|
|
|
orig-buf))
|
2010-01-10 05:22:54 +00:00
|
|
|
(when (buffer-live-p copy-buf)
|
|
|
|
(with-current-buffer copy-buf
|
|
|
|
;; Set write-region-post-annotation-function to
|
|
|
|
;; delete the buffer once the write is done, but do
|
|
|
|
;; it after running to-fn so it doesn't affect
|
|
|
|
;; write-region calls in to-fn.
|
2020-12-09 08:44:38 +00:00
|
|
|
(setq-local write-region-post-annotation-function
|
|
|
|
#'kill-buffer)))
|
1995-03-17 18:14:30 +00:00
|
|
|
nil)
|
|
|
|
;; Otherwise just call function, it will return annotations.
|
1996-09-01 03:25:54 +00:00
|
|
|
(funcall to-fn from to orig-buf)))))
|
1995-03-17 18:14:30 +00:00
|
|
|
|
|
|
|
(defun format-decode (format length &optional visit-flag)
|
|
|
|
;; This function is called by insert-file-contents whenever a file is read.
|
|
|
|
"Decode text from any known FORMAT.
|
1999-01-23 21:52:40 +00:00
|
|
|
FORMAT is a symbol appearing in `format-alist' or a list of such symbols,
|
1995-03-17 18:14:30 +00:00
|
|
|
or nil, in which case this function tries to guess the format of the data by
|
|
|
|
matching against the regular expressions in `format-alist'. After a match is
|
|
|
|
found and the region decoded, the alist is searched again from the beginning
|
|
|
|
for another match.
|
|
|
|
|
|
|
|
Second arg LENGTH is the number of characters following point to operate on.
|
|
|
|
If optional third arg VISIT-FLAG is true, set `buffer-file-format'
|
2002-11-08 02:38:54 +00:00
|
|
|
to the reverted list of formats used, and call any mode functions defined
|
|
|
|
for those formats.
|
1995-03-17 18:14:30 +00:00
|
|
|
|
2006-08-02 22:51:44 +00:00
|
|
|
Return the new length of the decoded region.
|
1995-03-17 18:14:30 +00:00
|
|
|
|
|
|
|
For most purposes, consider using `format-decode-region' instead."
|
|
|
|
(let ((mod (buffer-modified-p))
|
2000-08-17 20:24:27 +00:00
|
|
|
(begin (point))
|
1995-03-17 18:14:30 +00:00
|
|
|
(end (+ (point) length)))
|
2000-08-17 20:24:27 +00:00
|
|
|
(unwind-protect
|
|
|
|
(progn
|
|
|
|
;; Don't record undo information for the decoding.
|
2003-02-04 11:26:42 +00:00
|
|
|
|
2000-08-17 20:24:27 +00:00
|
|
|
(if (null format)
|
|
|
|
;; Figure out which format it is in, remember list in `format'.
|
|
|
|
(let ((try format-alist))
|
|
|
|
(while try
|
|
|
|
(let* ((f (car try))
|
|
|
|
(regexp (nth 2 f))
|
|
|
|
(p (point)))
|
|
|
|
(if (and regexp (looking-at regexp)
|
|
|
|
(< (match-end 0) (+ begin length)))
|
|
|
|
(progn
|
2002-11-08 02:38:54 +00:00
|
|
|
(push (car f) format)
|
2000-08-17 20:24:27 +00:00
|
|
|
;; Decode it
|
|
|
|
(if (nth 3 f)
|
|
|
|
(setq end (format-decode-run-method (nth 3 f) begin end)))
|
|
|
|
;; Call visit function if required
|
|
|
|
(if (and visit-flag (nth 6 f)) (funcall (nth 6 f) 1))
|
|
|
|
;; Safeguard against either of the functions changing pt.
|
|
|
|
(goto-char p)
|
|
|
|
;; Rewind list to look for another format
|
|
|
|
(setq try format-alist))
|
|
|
|
(setq try (cdr try))))))
|
|
|
|
;; Deal with given format(s)
|
|
|
|
(or (listp format) (setq format (list format)))
|
|
|
|
(let ((do format) f)
|
|
|
|
(while do
|
|
|
|
(or (setq f (assq (car do) format-alist))
|
2004-04-16 12:51:06 +00:00
|
|
|
(error "Unknown format %s" (car do)))
|
2000-08-17 20:24:27 +00:00
|
|
|
;; Decode:
|
|
|
|
(if (nth 3 f)
|
|
|
|
(setq end (format-decode-run-method (nth 3 f) begin end)))
|
|
|
|
;; Call visit function if required
|
|
|
|
(if (and visit-flag (nth 6 f)) (funcall (nth 6 f) 1))
|
2002-11-08 02:38:54 +00:00
|
|
|
(setq do (cdr do))))
|
|
|
|
;; Encode in the opposite order.
|
|
|
|
(setq format (reverse format)))
|
2000-08-17 20:24:27 +00:00
|
|
|
(if visit-flag
|
|
|
|
(setq buffer-file-format format)))
|
2003-02-04 11:26:42 +00:00
|
|
|
|
2000-12-04 13:32:26 +00:00
|
|
|
(set-buffer-modified-p mod))
|
|
|
|
|
2000-08-17 20:24:27 +00:00
|
|
|
;; Return new length of region
|
1995-03-17 18:14:30 +00:00
|
|
|
(- end begin)))
|
|
|
|
|
|
|
|
;;;
|
|
|
|
;;; Interactive functions & entry points
|
|
|
|
;;;
|
|
|
|
|
|
|
|
(defun format-decode-buffer (&optional format)
|
|
|
|
"Translate the buffer from some FORMAT.
|
2006-08-02 22:51:44 +00:00
|
|
|
If the format is not specified, attempt a regexp-based guess.
|
|
|
|
Set `buffer-file-format' to the format used, and call any
|
|
|
|
format-specific mode functions."
|
1995-03-17 18:14:30 +00:00
|
|
|
(interactive
|
2005-09-24 Emilio C. Lopes <eclig@gmx.net>
* woman.el (woman-file-name):
* wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* w32-fns.el (set-w32-system-coding-system):
* vc.el (vc-version-diff, vc-annotate):
* textmodes/reftex-auc.el (reftex-arg-cite)
(reftex-arg-index-tag):
* textmodes/refer.el (refer-get-bib-files):
* textmodes/artist.el (artist-figlet-choose-font):
* terminal.el (terminal-emulator):
* replace.el (occur-read-primary-args):
* rect.el (string-rectangle, string-insert-rectangle):
* ps-print.el (ps-print-preprint):
* progmodes/pascal.el (pascal-goto-defun):
* progmodes/etags.el (visit-tags-table, visit-tags-table-buffer):
* progmodes/compile.el (compilation-find-file):
* printing.el (pr-interactive-n-up):
* play/animate.el (animate-birthday-present):
* net/rcompile.el (remote-compile):
* man.el (man, Man-goto-section, Man-follow-manual-reference):
* mail/rmailsum.el (rmail-summary-search-backward)
(rmail-summary-search):
* mail/rmailout.el (rmail-output-read-rmail-file-name)
(rmail-output-read-file-name):
* mail/rmail.el (rmail-search, rmail-search-backwards):
* mail/mailabbrev.el (merge-mail-abbrevs, rebuild-mail-abbrevs):
* locate.el (locate):
* international/quail.el (quail-show-keyboard-layout):
* international/mule.el (set-buffer-file-coding-system)
(revert-buffer-with-coding-system, set-file-name-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system):
* international/mule-diag.el (describe-coding-system)
(describe-font, describe-fontset):
* international/mule-cmds.el (universal-coding-system-argument)
(search-unencodable-char, describe-input-method)
(set-language-environment, describe-language-environment):
* international/codepage.el (codepage-setup):
* international/code-pages.el (codepage-setup):
* info.el (Info-search, Info-follow-reference)
(Info-search-backward):
* emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-clear-cache, ad-activate)
(ad-deactivate, ad-update, ad-unadvise, ad-read-advice-name)
(ad-enable-advice, ad-disable-advice, ad-remove-advice)
(ad-read-regexp):
* ediff-util.el (ediff-toggle-regexp-match):
* ediff-ptch.el (ediff-prompt-for-patch-file):
* dired-aux.el (dired-diff):
* diff.el (diff):
* cus-edit.el (custom-variable-prompt):
* calendar/timeclock.el (timeclock-ask-for-project):
* calc/calcalg3.el (calc-get-fit-variables):
* calc/calc-store.el (calc-edit-variable)
(calc-permanent-variable):
* vc-mcvs.el (vc-mcvs-register):
* shadowfile.el (shadow-define-literal-group):
* woman.el (woman-file-name):
* vc.el (vc-version-diff, vc-merge):
* textmodes/reftex-index.el (reftex-index-complete-tag):
* format.el (format-decode-buffer, format-decode-region):
* emulation/viper-cmd.el (viper-read-string-with-history):
* emacs-lisp/debug.el (cancel-debug-on-entry):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* ediff.el (ediff-merge-revisions)
(ediff-merge-revisions-with-ancestor, ediff-revision):
* completion.el (interactive-completion-string-reader):
* calc/calc-prog.el (calc-user-define-formula):
Follow convention for reading with the minibuffer.
2005-09-24 13:44:02 +00:00
|
|
|
(list (format-read "Translate buffer from format (default guess): ")))
|
1995-03-17 18:14:30 +00:00
|
|
|
(save-excursion
|
|
|
|
(goto-char (point-min))
|
|
|
|
(format-decode format (buffer-size) t)))
|
|
|
|
|
|
|
|
(defun format-decode-region (from to &optional format)
|
|
|
|
"Decode the region from some format.
|
|
|
|
Arg FORMAT is optional; if omitted the format will be determined by looking
|
|
|
|
for identifying regular expressions at the beginning of the region."
|
|
|
|
(interactive
|
1999-01-23 21:52:40 +00:00
|
|
|
(list (region-beginning) (region-end)
|
2005-09-24 Emilio C. Lopes <eclig@gmx.net>
* woman.el (woman-file-name):
* wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* w32-fns.el (set-w32-system-coding-system):
* vc.el (vc-version-diff, vc-annotate):
* textmodes/reftex-auc.el (reftex-arg-cite)
(reftex-arg-index-tag):
* textmodes/refer.el (refer-get-bib-files):
* textmodes/artist.el (artist-figlet-choose-font):
* terminal.el (terminal-emulator):
* replace.el (occur-read-primary-args):
* rect.el (string-rectangle, string-insert-rectangle):
* ps-print.el (ps-print-preprint):
* progmodes/pascal.el (pascal-goto-defun):
* progmodes/etags.el (visit-tags-table, visit-tags-table-buffer):
* progmodes/compile.el (compilation-find-file):
* printing.el (pr-interactive-n-up):
* play/animate.el (animate-birthday-present):
* net/rcompile.el (remote-compile):
* man.el (man, Man-goto-section, Man-follow-manual-reference):
* mail/rmailsum.el (rmail-summary-search-backward)
(rmail-summary-search):
* mail/rmailout.el (rmail-output-read-rmail-file-name)
(rmail-output-read-file-name):
* mail/rmail.el (rmail-search, rmail-search-backwards):
* mail/mailabbrev.el (merge-mail-abbrevs, rebuild-mail-abbrevs):
* locate.el (locate):
* international/quail.el (quail-show-keyboard-layout):
* international/mule.el (set-buffer-file-coding-system)
(revert-buffer-with-coding-system, set-file-name-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system):
* international/mule-diag.el (describe-coding-system)
(describe-font, describe-fontset):
* international/mule-cmds.el (universal-coding-system-argument)
(search-unencodable-char, describe-input-method)
(set-language-environment, describe-language-environment):
* international/codepage.el (codepage-setup):
* international/code-pages.el (codepage-setup):
* info.el (Info-search, Info-follow-reference)
(Info-search-backward):
* emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-clear-cache, ad-activate)
(ad-deactivate, ad-update, ad-unadvise, ad-read-advice-name)
(ad-enable-advice, ad-disable-advice, ad-remove-advice)
(ad-read-regexp):
* ediff-util.el (ediff-toggle-regexp-match):
* ediff-ptch.el (ediff-prompt-for-patch-file):
* dired-aux.el (dired-diff):
* diff.el (diff):
* cus-edit.el (custom-variable-prompt):
* calendar/timeclock.el (timeclock-ask-for-project):
* calc/calcalg3.el (calc-get-fit-variables):
* calc/calc-store.el (calc-edit-variable)
(calc-permanent-variable):
* vc-mcvs.el (vc-mcvs-register):
* shadowfile.el (shadow-define-literal-group):
* woman.el (woman-file-name):
* vc.el (vc-version-diff, vc-merge):
* textmodes/reftex-index.el (reftex-index-complete-tag):
* format.el (format-decode-buffer, format-decode-region):
* emulation/viper-cmd.el (viper-read-string-with-history):
* emacs-lisp/debug.el (cancel-debug-on-entry):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* ediff.el (ediff-merge-revisions)
(ediff-merge-revisions-with-ancestor, ediff-revision):
* completion.el (interactive-completion-string-reader):
* calc/calc-prog.el (calc-user-define-formula):
Follow convention for reading with the minibuffer.
2005-09-24 13:44:02 +00:00
|
|
|
(format-read "Translate region from format (default guess): ")))
|
1995-03-17 18:14:30 +00:00
|
|
|
(save-excursion
|
|
|
|
(goto-char from)
|
|
|
|
(format-decode format (- to from) nil)))
|
|
|
|
|
|
|
|
(defun format-encode-buffer (&optional format)
|
|
|
|
"Translate the buffer into FORMAT.
|
|
|
|
FORMAT defaults to `buffer-file-format'. It is a symbol naming one of the
|
|
|
|
formats defined in `format-alist', or a list of such symbols."
|
|
|
|
(interactive
|
Use `format-prompt' when prompting with default values
* lisp/woman.el (woman-file-name):
* lisp/wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* lisp/w32-fns.el (w32-set-system-coding-system):
* lisp/vc/vc.el (vc-print-root-log):
* lisp/vc/vc-annotate.el (vc-annotate):
* lisp/vc/emerge.el (emerge-read-file-name):
* lisp/vc/ediff.el (ediff-directories)
(ediff-directory-revisions, ediff-directories3)
(ediff-merge-directories, )
(ediff-merge-directories-with-ancestor)
(ediff-merge-directory-revisions)
(ediff-merge-directory-revisions-with-ancestor)
(ediff-merge-revisions, ediff-merge-revisions-with-ancestor)
(ediff-revision):
* lisp/vc/ediff-util.el (ediff-toggle-regexp-match):
* lisp/vc/ediff-mult.el (ediff-filegroup-action):
* lisp/vc/add-log.el (prompt-for-change-log-name):
* lisp/textmodes/table.el (table-insert-row-column)
(table-span-cell, table-split-cell-horizontally)
(table-split-cell, table-justify, table-generate-source)
(table-insert-sequence, table-capture)
(table--read-from-minibuffer, table--query-justification):
* lisp/textmodes/sgml-mode.el (sgml-tag, sgml-tag-help):
* lisp/textmodes/reftex-ref.el (reftex-goto-label):
* lisp/textmodes/refer.el (refer-get-bib-files):
* lisp/textmodes/css-mode.el (css-lookup-symbol):
* lisp/term.el (serial-read-name, serial-read-speed):
* lisp/speedbar.el (speedbar-change-initial-expansion-list):
* lisp/simple.el (previous-matching-history-element)
(set-variable):
* lisp/ses.el (ses-read-cell, ses-set-column-width):
* lisp/replace.el (query-replace-read-from)
(occur-read-primary-args):
* lisp/rect.el (string-rectangle, string-insert-rectangle):
* lisp/progmodes/tcl.el (tcl-help-on-word):
* lisp/progmodes/sh-script.el (sh-set-shell):
* lisp/progmodes/python.el (python-eldoc-at-point):
* lisp/progmodes/octave.el (octave-completing-read)
(octave-update-function-file-comment, octave-insert-defun):
* lisp/progmodes/inf-lisp.el (lisp-symprompt):
* lisp/progmodes/cperl-mode.el (cperl-info-on-command)
(cperl-perldoc):
* lisp/progmodes/compile.el (compilation-find-file):
* lisp/net/rcirc.el (rcirc-prompt-for-encryption):
* lisp/net/eww.el (eww):
* lisp/net/browse-url.el (browse-url-with-browser-kind):
* lisp/man.el (man):
* lisp/mail/sendmail.el (sendmail-query-user-about-smtp):
* lisp/mail/mailalias.el (build-mail-aliases):
* lisp/mail/mailabbrev.el (merge-mail-abbrevs)
(rebuild-mail-abbrevs):
* lisp/locate.el (locate-prompt-for-search-string):
* lisp/isearch.el (isearch-occur):
* lisp/international/ogonek.el (ogonek-read-encoding)
(ogonek-read-prefix):
* lisp/international/mule.el (read-buffer-file-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system, recode-region):
* lisp/international/mule-cmds.el ()
(universal-coding-system-argument, search-unencodable-char)
(select-safe-coding-system-interactively):
* lisp/info.el (Info-search, Info-search-backward, Info-menu):
* lisp/info-look.el (info-lookup-interactive-arguments):
* lisp/imenu.el (imenu--completion-buffer):
* lisp/ibuf-ext.el (mode, used-mode, ibuffer-mark-by-mode):
* lisp/hi-lock.el (hi-lock-unface-buffer)
(hi-lock-read-face-name):
* lisp/help.el (view-emacs-news, where-is):
* lisp/help-fns.el (describe-variable, describe-symbol)
(describe-keymap):
* lisp/gnus/mm-decode.el (mm-save-part):
* lisp/gnus/gnus-sum.el (gnus-summary-browse-url):
* lisp/gnus/gnus-group.el (gnus-group--read-bug-ids)
(gnus-group-set-current-level):
* lisp/frame.el (make-frame-on-monitor)
(close-display-connection, select-frame-by-name):
* lisp/format.el (format-encode-buffer, format-encode-region):
* lisp/files.el (recode-file-name):
* lisp/files-x.el (read-file-local-variable)
(read-file-local-variable-value, )
(read-file-local-variable-mode):
* lisp/ffap.el (ffap-menu-ask):
* lisp/faces.el (face-read-string):
* lisp/facemenu.el (facemenu-set-charset):
* lisp/erc/erc-dcc.el (erc-dcc-do-GET-command):
* lisp/emulation/edt-mapper.el (edt-mapper):
* lisp/emacs-lisp/trace.el (trace--read-args)
(trace-function-foreground, trace-function-background):
* lisp/emacs-lisp/smie.el (smie-config-set-indent):
* lisp/emacs-lisp/re-builder.el (reb-change-syntax):
* lisp/emacs-lisp/package.el (describe-package):
* lisp/emacs-lisp/find-func.el (read-library-name)
(find-function-read):
* lisp/emacs-lisp/ert.el (ert-read-test-name)
(ert-run-tests-interactively):
* lisp/emacs-lisp/disass.el (disassemble):
* lisp/emacs-lisp/debug.el (debug-on-entry)
(debug-on-variable-change):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-read-regexp):
* lisp/dired-x.el (dired--mark-suffix-interactive-spec):
* lisp/dired-aux.el (dired-diff):
* lisp/cus-edit.el (custom-variable-prompt, customize-mode)
(customize-changed-options):
* lisp/completion.el (interactive-completion-string-reader):
* lisp/calendar/timeclock.el (timeclock-ask-for-project):
* lisp/calc/calcalg3.el (calc-get-fit-variables):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-bin.el (calc-word-size):
* lisp/bookmark.el (bookmark-set-internal):
* lisp/abbrev.el (read-abbrev-file): Use `format-prompt' for
prompting (bug#12443).
2020-09-06 14:56:44 +00:00
|
|
|
(list (format-read (format-prompt "Translate buffer to format"
|
|
|
|
buffer-file-format))))
|
1995-03-17 18:14:30 +00:00
|
|
|
(format-encode-region (point-min) (point-max) format))
|
|
|
|
|
|
|
|
(defun format-encode-region (beg end &optional format)
|
1999-01-23 21:52:40 +00:00
|
|
|
"Translate the region into some FORMAT.
|
2006-08-02 22:51:44 +00:00
|
|
|
FORMAT defaults to `buffer-file-format'. It is a symbol naming
|
1995-03-17 18:14:30 +00:00
|
|
|
one of the formats defined in `format-alist', or a list of such symbols."
|
1999-01-23 21:52:40 +00:00
|
|
|
(interactive
|
|
|
|
(list (region-beginning) (region-end)
|
Use `format-prompt' when prompting with default values
* lisp/woman.el (woman-file-name):
* lisp/wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* lisp/w32-fns.el (w32-set-system-coding-system):
* lisp/vc/vc.el (vc-print-root-log):
* lisp/vc/vc-annotate.el (vc-annotate):
* lisp/vc/emerge.el (emerge-read-file-name):
* lisp/vc/ediff.el (ediff-directories)
(ediff-directory-revisions, ediff-directories3)
(ediff-merge-directories, )
(ediff-merge-directories-with-ancestor)
(ediff-merge-directory-revisions)
(ediff-merge-directory-revisions-with-ancestor)
(ediff-merge-revisions, ediff-merge-revisions-with-ancestor)
(ediff-revision):
* lisp/vc/ediff-util.el (ediff-toggle-regexp-match):
* lisp/vc/ediff-mult.el (ediff-filegroup-action):
* lisp/vc/add-log.el (prompt-for-change-log-name):
* lisp/textmodes/table.el (table-insert-row-column)
(table-span-cell, table-split-cell-horizontally)
(table-split-cell, table-justify, table-generate-source)
(table-insert-sequence, table-capture)
(table--read-from-minibuffer, table--query-justification):
* lisp/textmodes/sgml-mode.el (sgml-tag, sgml-tag-help):
* lisp/textmodes/reftex-ref.el (reftex-goto-label):
* lisp/textmodes/refer.el (refer-get-bib-files):
* lisp/textmodes/css-mode.el (css-lookup-symbol):
* lisp/term.el (serial-read-name, serial-read-speed):
* lisp/speedbar.el (speedbar-change-initial-expansion-list):
* lisp/simple.el (previous-matching-history-element)
(set-variable):
* lisp/ses.el (ses-read-cell, ses-set-column-width):
* lisp/replace.el (query-replace-read-from)
(occur-read-primary-args):
* lisp/rect.el (string-rectangle, string-insert-rectangle):
* lisp/progmodes/tcl.el (tcl-help-on-word):
* lisp/progmodes/sh-script.el (sh-set-shell):
* lisp/progmodes/python.el (python-eldoc-at-point):
* lisp/progmodes/octave.el (octave-completing-read)
(octave-update-function-file-comment, octave-insert-defun):
* lisp/progmodes/inf-lisp.el (lisp-symprompt):
* lisp/progmodes/cperl-mode.el (cperl-info-on-command)
(cperl-perldoc):
* lisp/progmodes/compile.el (compilation-find-file):
* lisp/net/rcirc.el (rcirc-prompt-for-encryption):
* lisp/net/eww.el (eww):
* lisp/net/browse-url.el (browse-url-with-browser-kind):
* lisp/man.el (man):
* lisp/mail/sendmail.el (sendmail-query-user-about-smtp):
* lisp/mail/mailalias.el (build-mail-aliases):
* lisp/mail/mailabbrev.el (merge-mail-abbrevs)
(rebuild-mail-abbrevs):
* lisp/locate.el (locate-prompt-for-search-string):
* lisp/isearch.el (isearch-occur):
* lisp/international/ogonek.el (ogonek-read-encoding)
(ogonek-read-prefix):
* lisp/international/mule.el (read-buffer-file-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system, recode-region):
* lisp/international/mule-cmds.el ()
(universal-coding-system-argument, search-unencodable-char)
(select-safe-coding-system-interactively):
* lisp/info.el (Info-search, Info-search-backward, Info-menu):
* lisp/info-look.el (info-lookup-interactive-arguments):
* lisp/imenu.el (imenu--completion-buffer):
* lisp/ibuf-ext.el (mode, used-mode, ibuffer-mark-by-mode):
* lisp/hi-lock.el (hi-lock-unface-buffer)
(hi-lock-read-face-name):
* lisp/help.el (view-emacs-news, where-is):
* lisp/help-fns.el (describe-variable, describe-symbol)
(describe-keymap):
* lisp/gnus/mm-decode.el (mm-save-part):
* lisp/gnus/gnus-sum.el (gnus-summary-browse-url):
* lisp/gnus/gnus-group.el (gnus-group--read-bug-ids)
(gnus-group-set-current-level):
* lisp/frame.el (make-frame-on-monitor)
(close-display-connection, select-frame-by-name):
* lisp/format.el (format-encode-buffer, format-encode-region):
* lisp/files.el (recode-file-name):
* lisp/files-x.el (read-file-local-variable)
(read-file-local-variable-value, )
(read-file-local-variable-mode):
* lisp/ffap.el (ffap-menu-ask):
* lisp/faces.el (face-read-string):
* lisp/facemenu.el (facemenu-set-charset):
* lisp/erc/erc-dcc.el (erc-dcc-do-GET-command):
* lisp/emulation/edt-mapper.el (edt-mapper):
* lisp/emacs-lisp/trace.el (trace--read-args)
(trace-function-foreground, trace-function-background):
* lisp/emacs-lisp/smie.el (smie-config-set-indent):
* lisp/emacs-lisp/re-builder.el (reb-change-syntax):
* lisp/emacs-lisp/package.el (describe-package):
* lisp/emacs-lisp/find-func.el (read-library-name)
(find-function-read):
* lisp/emacs-lisp/ert.el (ert-read-test-name)
(ert-run-tests-interactively):
* lisp/emacs-lisp/disass.el (disassemble):
* lisp/emacs-lisp/debug.el (debug-on-entry)
(debug-on-variable-change):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-read-regexp):
* lisp/dired-x.el (dired--mark-suffix-interactive-spec):
* lisp/dired-aux.el (dired-diff):
* lisp/cus-edit.el (custom-variable-prompt, customize-mode)
(customize-changed-options):
* lisp/completion.el (interactive-completion-string-reader):
* lisp/calendar/timeclock.el (timeclock-ask-for-project):
* lisp/calc/calcalg3.el (calc-get-fit-variables):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-bin.el (calc-word-size):
* lisp/bookmark.el (bookmark-set-internal):
* lisp/abbrev.el (read-abbrev-file): Use `format-prompt' for
prompting (bug#12443).
2020-09-06 14:56:44 +00:00
|
|
|
(format-read (format-prompt "Translate region to format"
|
|
|
|
buffer-file-format))))
|
1999-01-23 21:52:40 +00:00
|
|
|
(if (null format) (setq format buffer-file-format))
|
|
|
|
(if (symbolp format) (setq format (list format)))
|
|
|
|
(save-excursion
|
|
|
|
(goto-char end)
|
2011-04-19 13:44:55 +00:00
|
|
|
(let ((end (point-marker)))
|
1999-01-23 21:52:40 +00:00
|
|
|
(while format
|
|
|
|
(let* ((info (assq (car format) format-alist))
|
|
|
|
(to-fn (nth 4 info))
|
2011-04-19 13:44:55 +00:00
|
|
|
(modify (nth 5 info)))
|
1999-01-23 21:52:40 +00:00
|
|
|
(if to-fn
|
|
|
|
(if modify
|
|
|
|
(setq end (format-encode-run-method to-fn beg end
|
|
|
|
(current-buffer)))
|
|
|
|
(format-insert-annotations
|
|
|
|
(funcall to-fn beg end (current-buffer)))))
|
|
|
|
(setq format (cdr format)))))))
|
1995-03-17 18:14:30 +00:00
|
|
|
|
2004-04-16 12:51:06 +00:00
|
|
|
(defun format-write-file (filename format &optional confirm)
|
2008-12-02 03:31:40 +00:00
|
|
|
"Write current buffer into FILENAME, using a format based on FORMAT.
|
|
|
|
Constructs the actual format starting from FORMAT, then appending
|
|
|
|
any elements from the value of `buffer-file-format' with a non-nil
|
|
|
|
`preserve' flag (see the documentation of `format-alist'), if they
|
|
|
|
are not already present in FORMAT. It then updates `buffer-file-format'
|
|
|
|
with this format, making it the default for future saves.
|
|
|
|
|
|
|
|
If the buffer is already visiting a file, you can specify a
|
|
|
|
directory name as FILENAME, to write a file of the same old name
|
2008-11-28 03:31:30 +00:00
|
|
|
in that directory.
|
2004-04-16 12:51:06 +00:00
|
|
|
|
2008-12-02 03:31:40 +00:00
|
|
|
If optional third arg CONFIRM is non-nil, asks for confirmation before
|
|
|
|
overwriting an existing file. Interactively, requires confirmation
|
|
|
|
unless you supply a prefix argument."
|
1995-03-17 18:14:30 +00:00
|
|
|
(interactive
|
|
|
|
;; Same interactive spec as write-file, plus format question.
|
|
|
|
(let* ((file (if buffer-file-name
|
|
|
|
(read-file-name "Write file: "
|
|
|
|
nil nil nil nil)
|
|
|
|
(read-file-name "Write file: "
|
|
|
|
(cdr (assq 'default-directory
|
|
|
|
(buffer-local-variables)))
|
|
|
|
nil nil (buffer-name))))
|
Go back to grave quoting in source-code docstrings etc.
This reverts almost all my recent changes to use curved quotes
in docstrings and/or strings used for error diagnostics.
There are a few exceptions, e.g., Bahá’í proper names.
* admin/unidata/unidata-gen.el (unidata-gen-table):
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/align.el (align-region):
* lisp/allout.el (allout-mode, allout-solicit-alternate-bullet)
(outlineify-sticky):
* lisp/apropos.el (apropos-library):
* lisp/bookmark.el (bookmark-default-annotation-text):
* lisp/button.el (button-category-symbol, button-put)
(make-text-button):
* lisp/calc/calc-aent.el (math-read-if, math-read-factor):
* lisp/calc/calc-embed.el (calc-do-embedded):
* lisp/calc/calc-ext.el (calc-user-function-list):
* lisp/calc/calc-graph.el (calc-graph-show-dumb):
* lisp/calc/calc-help.el (calc-describe-key)
(calc-describe-thing, calc-full-help):
* lisp/calc/calc-lang.el (calc-c-language)
(math-parse-fortran-vector-end, math-parse-tex-sum)
(math-parse-eqn-matrix, math-parse-eqn-prime)
(calc-yacas-language, calc-maxima-language, calc-giac-language)
(math-read-giac-subscr, math-read-math-subscr)
(math-read-big-rec, math-read-big-balance):
* lisp/calc/calc-misc.el (calc-help, report-calc-bug):
* lisp/calc/calc-mode.el (calc-auto-why, calc-save-modes)
(calc-auto-recompute):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-read-parse-table-part, calc-user-define-invocation)
(math-do-arg-check):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-units.el (math-build-units-table-buffer):
* lisp/calc/calc-vec.el (math-read-brackets):
* lisp/calc/calc-yank.el (calc-edit-mode):
* lisp/calc/calc.el (calc, calc-do, calc-user-invocation):
* lisp/calendar/appt.el (appt-display-message):
* lisp/calendar/diary-lib.el (diary-check-diary-file)
(diary-mail-entries, diary-from-outlook):
* lisp/calendar/icalendar.el (icalendar-export-region)
(icalendar--convert-float-to-ical)
(icalendar--convert-date-to-ical)
(icalendar--convert-ical-to-diary)
(icalendar--convert-recurring-to-diary)
(icalendar--add-diary-entry):
* lisp/calendar/time-date.el (format-seconds):
* lisp/calendar/timeclock.el (timeclock-mode-line-display)
(timeclock-make-hours-explicit, timeclock-log-data):
* lisp/calendar/todo-mode.el (todo-prefix, todo-delete-category)
(todo-item-mark, todo-check-format)
(todo-insert-item--next-param, todo-edit-item--next-key)
(todo-mode):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/mode-local.el (describe-mode-local-overload)
(mode-local-print-binding, mode-local-describe-bindings-2):
* lisp/cedet/semantic/complete.el (semantic-displayor-show-request):
* lisp/cedet/srecode/srt-mode.el (srecode-macro-help):
* lisp/cus-start.el (standard):
* lisp/cus-theme.el (describe-theme-1):
* lisp/custom.el (custom-add-dependencies, custom-check-theme)
(custom--sort-vars-1, load-theme):
* lisp/descr-text.el (describe-text-properties-1, describe-char):
* lisp/dired-x.el (dired-do-run-mail):
* lisp/dired.el (dired-log):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-enable-advice)
(ad-disable-advice, ad-remove-advice, ad-set-argument)
(ad-set-arguments, ad--defalias-fset, ad-activate)
(ad-deactivate):
* lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand)
(byte-compile-unfold-lambda, byte-optimize-form-code-walker)
(byte-optimize-while, byte-optimize-apply):
* lisp/emacs-lisp/byte-run.el (defun, defsubst):
* lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode)
(byte-compile-log-file, byte-compile-format-warn)
(byte-compile-nogroup-warn, byte-compile-arglist-warn)
(byte-compile-cl-warn)
(byte-compile-warn-about-unresolved-functions)
(byte-compile-file, byte-compile--declare-var)
(byte-compile-file-form-defmumble, byte-compile-form)
(byte-compile-normal-call, byte-compile-check-variable)
(byte-compile-variable-ref, byte-compile-variable-set)
(byte-compile-subr-wrong-args, byte-compile-setq-default)
(byte-compile-negation-optimizer)
(byte-compile-condition-case--old)
(byte-compile-condition-case--new, byte-compile-save-excursion)
(byte-compile-defvar, byte-compile-autoload)
(byte-compile-lambda-form)
(byte-compile-make-variable-buffer-local, display-call-tree)
(batch-byte-compile):
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use):
* lisp/emacs-lisp/chart.el (chart-space-usage):
* lisp/emacs-lisp/check-declare.el (check-declare-scan)
(check-declare-warn, check-declare-file)
(check-declare-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine)
(checkdoc-message-text-engine):
* lisp/emacs-lisp/cl-extra.el (cl-parse-integer)
(cl--describe-class):
* lisp/emacs-lisp/cl-generic.el (cl-defgeneric)
(cl--generic-describe, cl-generic-generalizers):
* lisp/emacs-lisp/cl-macs.el (cl--parse-loop-clause, cl-tagbody)
(cl-symbol-macrolet):
* lisp/emacs-lisp/cl.el (cl-unload-function, flet):
* lisp/emacs-lisp/copyright.el (copyright)
(copyright-update-directory):
* lisp/emacs-lisp/edebug.el (edebug-read-list):
* lisp/emacs-lisp/eieio-base.el (eieio-persistent-read):
* lisp/emacs-lisp/eieio-core.el (eieio--slot-override)
(eieio-oref):
* lisp/emacs-lisp/eieio-opt.el (eieio-help-constructor):
* lisp/emacs-lisp/eieio-speedbar.el:
(eieio-speedbar-child-make-tag-lines)
(eieio-speedbar-child-description):
* lisp/emacs-lisp/eieio.el (defclass, change-class):
* lisp/emacs-lisp/elint.el (elint-file, elint-get-top-forms)
(elint-init-form, elint-check-defalias-form)
(elint-check-let-form):
* lisp/emacs-lisp/ert.el (ert-get-test, ert-results-mode-menu)
(ert-results-pop-to-backtrace-for-test-at-point)
(ert-results-pop-to-messages-for-test-at-point)
(ert-results-pop-to-should-forms-for-test-at-point)
(ert-describe-test):
* lisp/emacs-lisp/find-func.el (find-function-search-for-symbol)
(find-function-library):
* lisp/emacs-lisp/generator.el (iter-yield):
* lisp/emacs-lisp/gv.el (gv-define-simple-setter):
* lisp/emacs-lisp/lisp-mnt.el (lm-verify):
* lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/nadvice.el (advice--make-docstring)
(advice--make, define-advice):
* lisp/emacs-lisp/package-x.el (package-upload-file):
* lisp/emacs-lisp/package.el (package-version-join)
(package-disabled-p, package-activate-1, package-activate)
(package--download-one-archive)
(package--download-and-read-archives)
(package-compute-transaction, package-install-from-archive)
(package-install, package-install-selected-packages)
(package-delete, package-autoremove, describe-package-1)
(package-install-button-action, package-delete-button-action)
(package-menu-hide-package, package-menu--list-to-prompt)
(package-menu--perform-transaction)
(package-menu--find-and-notify-upgrades):
* lisp/emacs-lisp/pcase.el (pcase-exhaustive, pcase--u1):
* lisp/emacs-lisp/re-builder.el (reb-enter-subexp-mode):
* lisp/emacs-lisp/ring.el (ring-previous, ring-next):
* lisp/emacs-lisp/rx.el (rx-check, rx-anything)
(rx-check-any-string, rx-check-any, rx-check-not, rx-=)
(rx-repeat, rx-check-backref, rx-syntax, rx-check-category)
(rx-form):
* lisp/emacs-lisp/smie.el (smie-config-save):
* lisp/emacs-lisp/subr-x.el (internal--check-binding):
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-put-tag):
* lisp/emacs-lisp/testcover.el (testcover-1value):
* lisp/emacs-lisp/timer.el (timer-event-handler):
* lisp/emulation/viper-cmd.el (viper-toggle-parse-sexp-ignore-comments)
(viper-toggle-search-style, viper-kill-buffer)
(viper-brac-function):
* lisp/emulation/viper-macs.el (viper-record-kbd-macro):
* lisp/env.el (setenv):
* lisp/erc/erc-button.el (erc-nick-popup):
* lisp/erc/erc.el (erc-cmd-LOAD, erc-handle-login, english):
* lisp/eshell/em-dirs.el (eshell/cd):
* lisp/eshell/em-glob.el (eshell-glob-regexp)
(eshell-glob-entries):
* lisp/eshell/em-pred.el (eshell-parse-modifiers):
* lisp/eshell/esh-opt.el (eshell-show-usage):
* lisp/facemenu.el (facemenu-add-new-face)
(facemenu-add-new-color):
* lisp/faces.el (read-face-name, read-face-font, describe-face)
(x-resolve-font-name):
* lisp/files-x.el (modify-file-local-variable):
* lisp/files.el (locate-user-emacs-file, find-alternate-file)
(set-auto-mode, hack-one-local-variable--obsolete)
(dir-locals-set-directory-class, write-file, basic-save-buffer)
(delete-directory, copy-directory, recover-session)
(recover-session-finish, insert-directory)
(file-modes-char-to-who, file-modes-symbolic-to-number)
(move-file-to-trash):
* lisp/filesets.el (filesets-add-buffer, filesets-remove-buffer):
* lisp/find-cmd.el (find-generic, find-to-string):
* lisp/finder.el (finder-commentary):
* lisp/font-lock.el (font-lock-fontify-buffer):
* lisp/format.el (format-write-file, format-find-file)
(format-insert-file):
* lisp/frame.el (get-device-terminal, select-frame-by-name):
* lisp/fringe.el (fringe--check-style):
* lisp/gnus/nnmairix.el (nnmairix-widget-create-query):
* lisp/help-fns.el (help-fns--key-bindings)
(help-fns--compiler-macro, help-fns--parent-mode)
(help-fns--obsolete, help-fns--interactive-only)
(describe-function-1, describe-variable):
* lisp/help.el (describe-mode)
(describe-minor-mode-from-indicator):
* lisp/image.el (image-type):
* lisp/international/ccl.el (ccl-dump):
* lisp/international/fontset.el (x-must-resolve-font-name):
* lisp/international/mule-cmds.el (prefer-coding-system)
(select-safe-coding-system-interactively)
(select-safe-coding-system, activate-input-method)
(toggle-input-method, describe-current-input-method)
(describe-language-environment):
* lisp/international/mule-conf.el (code-offset):
* lisp/international/mule-diag.el (describe-character-set)
(list-input-methods-1):
* lisp/mail/feedmail.el (feedmail-run-the-queue):
* lisp/mouse.el (minor-mode-menu-from-indicator):
* lisp/mpc.el (mpc-playlist-rename):
* lisp/msb.el (msb--choose-menu):
* lisp/net/ange-ftp.el (ange-ftp-shell-command):
* lisp/net/imap.el (imap-interactive-login):
* lisp/net/mairix.el (mairix-widget-create-query):
* lisp/net/newst-backend.el (newsticker--sentinel-work):
* lisp/net/newst-treeview.el (newsticker--treeview-load):
* lisp/net/rlogin.el (rlogin):
* lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer):
* lisp/obsolete/otodo-mode.el (todo-more-important-p):
* lisp/obsolete/pgg-gpg.el (pgg-gpg-process-region):
* lisp/obsolete/pgg-pgp.el (pgg-pgp-process-region):
* lisp/obsolete/pgg-pgp5.el (pgg-pgp5-process-region):
* lisp/org/ob-core.el (org-babel-goto-named-src-block)
(org-babel-goto-named-result):
* lisp/org/ob-fortran.el (org-babel-fortran-ensure-main-wrap):
* lisp/org/ob-ref.el (org-babel-ref-resolve):
* lisp/org/org-agenda.el (org-agenda-prepare):
* lisp/org/org-clock.el (org-clock-notify-once-if-expired)
(org-clock-resolve):
* lisp/org/org-ctags.el (org-ctags-ask-rebuild-tags-file-then-find-tag):
* lisp/org/org-feed.el (org-feed-parse-atom-entry):
* lisp/org/org-habit.el (org-habit-parse-todo):
* lisp/org/org-mouse.el (org-mouse-popup-global-menu)
(org-mouse-context-menu):
* lisp/org/org-table.el (org-table-edit-formulas):
* lisp/org/ox.el (org-export-async-start):
* lisp/proced.el (proced-log):
* lisp/progmodes/ada-mode.el (ada-get-indent-case)
(ada-check-matching-start, ada-goto-matching-start):
* lisp/progmodes/ada-prj.el (ada-prj-display-page):
* lisp/progmodes/ada-xref.el (ada-find-executable):
* lisp/progmodes/ebrowse.el (ebrowse-tags-apropos):
* lisp/progmodes/etags.el (etags-tags-apropos-additional):
* lisp/progmodes/flymake.el (flymake-parse-err-lines)
(flymake-start-syntax-check-process):
* lisp/progmodes/python.el (python-shell-get-process-or-error)
(python-define-auxiliary-skeleton):
* lisp/progmodes/sql.el (sql-comint):
* lisp/progmodes/verilog-mode.el (verilog-load-file-at-point):
* lisp/progmodes/vhdl-mode.el (vhdl-widget-directory-validate):
* lisp/recentf.el (recentf-open-files):
* lisp/replace.el (query-replace-read-from)
(occur-after-change-function, occur-1):
* lisp/scroll-bar.el (scroll-bar-columns):
* lisp/server.el (server-get-auth-key):
* lisp/simple.el (execute-extended-command)
(undo-outer-limit-truncate, list-processes--refresh)
(compose-mail, set-variable, choose-completion-string)
(define-alternatives):
* lisp/startup.el (site-run-file, tty-handle-args, command-line)
(command-line-1):
* lisp/subr.el (noreturn, define-error, add-to-list)
(read-char-choice, version-to-list):
* lisp/term/common-win.el (x-handle-xrm-switch)
(x-handle-name-switch, x-handle-args):
* lisp/term/x-win.el (x-handle-parent-id, x-handle-smid):
* lisp/textmodes/reftex-ref.el (reftex-label):
* lisp/textmodes/reftex-toc.el (reftex-toc-rename-label):
* lisp/textmodes/two-column.el (2C-split):
* lisp/tutorial.el (tutorial--describe-nonstandard-key)
(tutorial--find-changed-keys):
* lisp/type-break.el (type-break-noninteractive-query):
* lisp/wdired.el (wdired-do-renames, wdired-do-symlink-changes)
(wdired-do-perm-changes):
* lisp/whitespace.el (whitespace-report-region):
Prefer grave quoting in source-code strings used to generate help
and diagnostics.
* lisp/faces.el (face-documentation):
No need to convert quotes, since the result is a docstring.
* lisp/info.el (Info-virtual-index-find-node)
(Info-virtual-index, info-apropos):
Simplify by generating only curved quotes, since info files are
typically that ways nowadays anyway.
* lisp/international/mule-diag.el (list-input-methods):
Don’t assume text quoting style is curved.
* lisp/org/org-bibtex.el (org-bibtex-fields):
Revert my recent changes, going back to the old quoting style.
2015-09-07 15:41:44 +00:00
|
|
|
(fmt (format-read (format-message "Write file `%s' in format: "
|
More-conservative ‘format’ quote restyling
Instead of restyling curved quotes for every call to ‘format’,
create a new function ‘format-message’ that does the restyling,
and using the new function instead of ‘format’ only in contexts
where this seems appropriate.
Problem reported by Dmitry Gutov and Andreas Schwab in:
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00826.html
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00827.html
* doc/lispref/commands.texi (Using Interactive):
* doc/lispref/control.texi (Signaling Errors, Signaling Errors):
* doc/lispref/display.texi (Displaying Messages, Progress):
* doc/lispref/elisp.texi:
* doc/lispref/help.texi (Keys in Documentation):
* doc/lispref/minibuf.texi (Minibuffer Misc):
* doc/lispref/strings.texi (Formatting Strings):
* etc/NEWS:
Document the changes.
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/apropos.el (apropos-library):
* lisp/calc/calc-ext.el (calc-record-message)
(calc-user-function-list):
* lisp/calc/calc-help.el (calc-describe-key, calc-full-help):
* lisp/calc/calc-lang.el (math-read-big-balance):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-units.el (math-build-units-table-buffer):
* lisp/calc/calc-yank.el (calc-edit-mode):
* lisp/calendar/icalendar.el (icalendar-export-region)
(icalendar--add-diary-entry):
* lisp/cedet/mode-local.el (mode-local-print-binding)
(mode-local-describe-bindings-2):
* lisp/cedet/semantic/complete.el (semantic-completion-message):
* lisp/cedet/semantic/edit.el (semantic-parse-changes-failed):
* lisp/cedet/semantic/wisent/comp.el (wisent-log):
* lisp/cedet/srecode/insert.el (srecode-insert-show-error-report):
* lisp/descr-text.el (describe-text-properties-1, describe-char):
* lisp/dframe.el (dframe-message):
* lisp/dired-aux.el (dired-query):
* lisp/emacs-lisp/byte-opt.el (byte-compile-log-lap-1):
* lisp/emacs-lisp/bytecomp.el (byte-compile-log)
(byte-compile-log-file, byte-compile-warn, byte-compile-form):
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use)
(cconv-analyze-form):
* lisp/emacs-lisp/check-declare.el (check-declare-warn):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet):
* lisp/emacs-lisp/edebug.el (edebug-format):
* lisp/emacs-lisp/eieio-core.el (eieio-oref):
* lisp/emacs-lisp/eldoc.el (eldoc-minibuffer-message)
(eldoc-message):
* lisp/emacs-lisp/elint.el (elint-file, elint-log):
* lisp/emacs-lisp/find-func.el (find-function-library):
* lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/nadvice.el (advice--make-docstring):
* lisp/emacs-lisp/package.el (package-compute-transaction)
(package-install-button-action, package-delete-button-action)
(package-menu--list-to-prompt):
* lisp/emacs-lisp/timer.el (timer-event-handler):
* lisp/emacs-lisp/warnings.el (lwarn, warn):
* lisp/emulation/viper-cmd.el:
(viper-toggle-parse-sexp-ignore-comments)
(viper-kill-buffer, viper-brac-function):
* lisp/emulation/viper-macs.el (viper-record-kbd-macro):
* lisp/facemenu.el (facemenu-add-new-face):
* lisp/faces.el (face-documentation, read-face-name)
(face-read-string, read-face-font, describe-face):
* lisp/files.el (find-alternate-file, hack-local-variables)
(hack-one-local-variable--obsolete, write-file)
(basic-save-buffer, delete-directory):
* lisp/format.el (format-write-file, format-find-file)
(format-insert-file):
* lisp/help-fns.el (help-fns--key-bindings)
(help-fns--compiler-macro, help-fns--obsolete)
(help-fns--interactive-only, describe-function-1)
(describe-variable):
* lisp/help.el (describe-mode):
* lisp/info-xref.el (info-xref-output):
* lisp/info.el (Info-virtual-index-find-node)
(Info-virtual-index, info-apropos):
* lisp/international/kkc.el (kkc-error):
* lisp/international/mule-cmds.el:
(select-safe-coding-system-interactively)
(select-safe-coding-system, describe-input-method):
* lisp/international/mule-conf.el (code-offset):
* lisp/international/mule-diag.el (describe-character-set)
(list-input-methods-1):
* lisp/international/quail.el (quail-error):
* lisp/minibuffer.el (minibuffer-message):
* lisp/mpc.el (mpc--debug):
* lisp/msb.el (msb--choose-menu):
* lisp/net/ange-ftp.el (ange-ftp-message):
* lisp/net/gnutls.el (gnutls-message-maybe):
* lisp/net/newst-backend.el (newsticker--sentinel-work):
* lisp/net/newst-treeview.el (newsticker--treeview-load):
* lisp/net/nsm.el (nsm-query-user):
* lisp/net/rlogin.el (rlogin):
* lisp/net/soap-client.el (soap-warning):
* lisp/net/tramp.el (tramp-debug-message):
* lisp/nxml/nxml-outln.el (nxml-report-outline-error):
* lisp/nxml/nxml-parse.el (nxml-parse-error):
* lisp/nxml/rng-cmpct.el (rng-c-error):
* lisp/nxml/rng-match.el (rng-compile-error):
* lisp/nxml/rng-uri.el (rng-uri-error):
* lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer):
* lisp/org/org-ctags.el:
(org-ctags-ask-rebuild-tags-file-then-find-tag):
* lisp/proced.el (proced-log):
* lisp/progmodes/ebnf2ps.el (ebnf-log):
* lisp/progmodes/flymake.el (flymake-log):
* lisp/progmodes/vhdl-mode.el (vhdl-warning-when-idle):
* lisp/replace.el (occur-1):
* lisp/simple.el (execute-extended-command)
(undo-outer-limit-truncate, define-alternatives):
* lisp/startup.el (command-line):
* lisp/subr.el (error, user-error, add-to-list):
* lisp/tutorial.el (tutorial--describe-nonstandard-key)
(tutorial--find-changed-keys):
* src/callint.c (Fcall_interactively):
* src/editfns.c (Fmessage, Fmessage_box):
Restyle the quotes of format strings intended for use as a
diagnostic, when restyling seems appropriate.
* lisp/subr.el (format-message): New function.
* src/doc.c (Finternal__text_restyle): New function.
(syms_of_doc): Define it.
2015-08-24 05:38:02 +00:00
|
|
|
(file-name-nondirectory file)))))
|
2004-04-16 12:51:06 +00:00
|
|
|
(list file fmt (not current-prefix-arg))))
|
2002-06-11 19:26:45 +00:00
|
|
|
(let ((old-formats buffer-file-format)
|
|
|
|
preserve-formats)
|
|
|
|
(dolist (fmt old-formats)
|
|
|
|
(let ((aelt (assq fmt format-alist)))
|
|
|
|
(if (nth 7 aelt)
|
|
|
|
(push fmt preserve-formats))))
|
|
|
|
(setq buffer-file-format format)
|
|
|
|
(dolist (fmt preserve-formats)
|
|
|
|
(unless (memq fmt buffer-file-format)
|
|
|
|
(setq buffer-file-format (append buffer-file-format (list fmt))))))
|
2004-04-16 12:51:06 +00:00
|
|
|
(write-file filename confirm))
|
1995-03-17 18:14:30 +00:00
|
|
|
|
1995-06-09 01:23:01 +00:00
|
|
|
(defun format-find-file (filename format)
|
1999-01-23 21:52:40 +00:00
|
|
|
"Find the file FILENAME using data format FORMAT.
|
1995-06-09 01:23:01 +00:00
|
|
|
If FORMAT is nil then do not do any format conversion."
|
|
|
|
(interactive
|
|
|
|
;; Same interactive spec as write-file, plus format question.
|
|
|
|
(let* ((file (read-file-name "Find file: "))
|
Go back to grave quoting in source-code docstrings etc.
This reverts almost all my recent changes to use curved quotes
in docstrings and/or strings used for error diagnostics.
There are a few exceptions, e.g., Bahá’í proper names.
* admin/unidata/unidata-gen.el (unidata-gen-table):
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/align.el (align-region):
* lisp/allout.el (allout-mode, allout-solicit-alternate-bullet)
(outlineify-sticky):
* lisp/apropos.el (apropos-library):
* lisp/bookmark.el (bookmark-default-annotation-text):
* lisp/button.el (button-category-symbol, button-put)
(make-text-button):
* lisp/calc/calc-aent.el (math-read-if, math-read-factor):
* lisp/calc/calc-embed.el (calc-do-embedded):
* lisp/calc/calc-ext.el (calc-user-function-list):
* lisp/calc/calc-graph.el (calc-graph-show-dumb):
* lisp/calc/calc-help.el (calc-describe-key)
(calc-describe-thing, calc-full-help):
* lisp/calc/calc-lang.el (calc-c-language)
(math-parse-fortran-vector-end, math-parse-tex-sum)
(math-parse-eqn-matrix, math-parse-eqn-prime)
(calc-yacas-language, calc-maxima-language, calc-giac-language)
(math-read-giac-subscr, math-read-math-subscr)
(math-read-big-rec, math-read-big-balance):
* lisp/calc/calc-misc.el (calc-help, report-calc-bug):
* lisp/calc/calc-mode.el (calc-auto-why, calc-save-modes)
(calc-auto-recompute):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-read-parse-table-part, calc-user-define-invocation)
(math-do-arg-check):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-units.el (math-build-units-table-buffer):
* lisp/calc/calc-vec.el (math-read-brackets):
* lisp/calc/calc-yank.el (calc-edit-mode):
* lisp/calc/calc.el (calc, calc-do, calc-user-invocation):
* lisp/calendar/appt.el (appt-display-message):
* lisp/calendar/diary-lib.el (diary-check-diary-file)
(diary-mail-entries, diary-from-outlook):
* lisp/calendar/icalendar.el (icalendar-export-region)
(icalendar--convert-float-to-ical)
(icalendar--convert-date-to-ical)
(icalendar--convert-ical-to-diary)
(icalendar--convert-recurring-to-diary)
(icalendar--add-diary-entry):
* lisp/calendar/time-date.el (format-seconds):
* lisp/calendar/timeclock.el (timeclock-mode-line-display)
(timeclock-make-hours-explicit, timeclock-log-data):
* lisp/calendar/todo-mode.el (todo-prefix, todo-delete-category)
(todo-item-mark, todo-check-format)
(todo-insert-item--next-param, todo-edit-item--next-key)
(todo-mode):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/mode-local.el (describe-mode-local-overload)
(mode-local-print-binding, mode-local-describe-bindings-2):
* lisp/cedet/semantic/complete.el (semantic-displayor-show-request):
* lisp/cedet/srecode/srt-mode.el (srecode-macro-help):
* lisp/cus-start.el (standard):
* lisp/cus-theme.el (describe-theme-1):
* lisp/custom.el (custom-add-dependencies, custom-check-theme)
(custom--sort-vars-1, load-theme):
* lisp/descr-text.el (describe-text-properties-1, describe-char):
* lisp/dired-x.el (dired-do-run-mail):
* lisp/dired.el (dired-log):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-enable-advice)
(ad-disable-advice, ad-remove-advice, ad-set-argument)
(ad-set-arguments, ad--defalias-fset, ad-activate)
(ad-deactivate):
* lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand)
(byte-compile-unfold-lambda, byte-optimize-form-code-walker)
(byte-optimize-while, byte-optimize-apply):
* lisp/emacs-lisp/byte-run.el (defun, defsubst):
* lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode)
(byte-compile-log-file, byte-compile-format-warn)
(byte-compile-nogroup-warn, byte-compile-arglist-warn)
(byte-compile-cl-warn)
(byte-compile-warn-about-unresolved-functions)
(byte-compile-file, byte-compile--declare-var)
(byte-compile-file-form-defmumble, byte-compile-form)
(byte-compile-normal-call, byte-compile-check-variable)
(byte-compile-variable-ref, byte-compile-variable-set)
(byte-compile-subr-wrong-args, byte-compile-setq-default)
(byte-compile-negation-optimizer)
(byte-compile-condition-case--old)
(byte-compile-condition-case--new, byte-compile-save-excursion)
(byte-compile-defvar, byte-compile-autoload)
(byte-compile-lambda-form)
(byte-compile-make-variable-buffer-local, display-call-tree)
(batch-byte-compile):
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use):
* lisp/emacs-lisp/chart.el (chart-space-usage):
* lisp/emacs-lisp/check-declare.el (check-declare-scan)
(check-declare-warn, check-declare-file)
(check-declare-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine)
(checkdoc-message-text-engine):
* lisp/emacs-lisp/cl-extra.el (cl-parse-integer)
(cl--describe-class):
* lisp/emacs-lisp/cl-generic.el (cl-defgeneric)
(cl--generic-describe, cl-generic-generalizers):
* lisp/emacs-lisp/cl-macs.el (cl--parse-loop-clause, cl-tagbody)
(cl-symbol-macrolet):
* lisp/emacs-lisp/cl.el (cl-unload-function, flet):
* lisp/emacs-lisp/copyright.el (copyright)
(copyright-update-directory):
* lisp/emacs-lisp/edebug.el (edebug-read-list):
* lisp/emacs-lisp/eieio-base.el (eieio-persistent-read):
* lisp/emacs-lisp/eieio-core.el (eieio--slot-override)
(eieio-oref):
* lisp/emacs-lisp/eieio-opt.el (eieio-help-constructor):
* lisp/emacs-lisp/eieio-speedbar.el:
(eieio-speedbar-child-make-tag-lines)
(eieio-speedbar-child-description):
* lisp/emacs-lisp/eieio.el (defclass, change-class):
* lisp/emacs-lisp/elint.el (elint-file, elint-get-top-forms)
(elint-init-form, elint-check-defalias-form)
(elint-check-let-form):
* lisp/emacs-lisp/ert.el (ert-get-test, ert-results-mode-menu)
(ert-results-pop-to-backtrace-for-test-at-point)
(ert-results-pop-to-messages-for-test-at-point)
(ert-results-pop-to-should-forms-for-test-at-point)
(ert-describe-test):
* lisp/emacs-lisp/find-func.el (find-function-search-for-symbol)
(find-function-library):
* lisp/emacs-lisp/generator.el (iter-yield):
* lisp/emacs-lisp/gv.el (gv-define-simple-setter):
* lisp/emacs-lisp/lisp-mnt.el (lm-verify):
* lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/nadvice.el (advice--make-docstring)
(advice--make, define-advice):
* lisp/emacs-lisp/package-x.el (package-upload-file):
* lisp/emacs-lisp/package.el (package-version-join)
(package-disabled-p, package-activate-1, package-activate)
(package--download-one-archive)
(package--download-and-read-archives)
(package-compute-transaction, package-install-from-archive)
(package-install, package-install-selected-packages)
(package-delete, package-autoremove, describe-package-1)
(package-install-button-action, package-delete-button-action)
(package-menu-hide-package, package-menu--list-to-prompt)
(package-menu--perform-transaction)
(package-menu--find-and-notify-upgrades):
* lisp/emacs-lisp/pcase.el (pcase-exhaustive, pcase--u1):
* lisp/emacs-lisp/re-builder.el (reb-enter-subexp-mode):
* lisp/emacs-lisp/ring.el (ring-previous, ring-next):
* lisp/emacs-lisp/rx.el (rx-check, rx-anything)
(rx-check-any-string, rx-check-any, rx-check-not, rx-=)
(rx-repeat, rx-check-backref, rx-syntax, rx-check-category)
(rx-form):
* lisp/emacs-lisp/smie.el (smie-config-save):
* lisp/emacs-lisp/subr-x.el (internal--check-binding):
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-put-tag):
* lisp/emacs-lisp/testcover.el (testcover-1value):
* lisp/emacs-lisp/timer.el (timer-event-handler):
* lisp/emulation/viper-cmd.el (viper-toggle-parse-sexp-ignore-comments)
(viper-toggle-search-style, viper-kill-buffer)
(viper-brac-function):
* lisp/emulation/viper-macs.el (viper-record-kbd-macro):
* lisp/env.el (setenv):
* lisp/erc/erc-button.el (erc-nick-popup):
* lisp/erc/erc.el (erc-cmd-LOAD, erc-handle-login, english):
* lisp/eshell/em-dirs.el (eshell/cd):
* lisp/eshell/em-glob.el (eshell-glob-regexp)
(eshell-glob-entries):
* lisp/eshell/em-pred.el (eshell-parse-modifiers):
* lisp/eshell/esh-opt.el (eshell-show-usage):
* lisp/facemenu.el (facemenu-add-new-face)
(facemenu-add-new-color):
* lisp/faces.el (read-face-name, read-face-font, describe-face)
(x-resolve-font-name):
* lisp/files-x.el (modify-file-local-variable):
* lisp/files.el (locate-user-emacs-file, find-alternate-file)
(set-auto-mode, hack-one-local-variable--obsolete)
(dir-locals-set-directory-class, write-file, basic-save-buffer)
(delete-directory, copy-directory, recover-session)
(recover-session-finish, insert-directory)
(file-modes-char-to-who, file-modes-symbolic-to-number)
(move-file-to-trash):
* lisp/filesets.el (filesets-add-buffer, filesets-remove-buffer):
* lisp/find-cmd.el (find-generic, find-to-string):
* lisp/finder.el (finder-commentary):
* lisp/font-lock.el (font-lock-fontify-buffer):
* lisp/format.el (format-write-file, format-find-file)
(format-insert-file):
* lisp/frame.el (get-device-terminal, select-frame-by-name):
* lisp/fringe.el (fringe--check-style):
* lisp/gnus/nnmairix.el (nnmairix-widget-create-query):
* lisp/help-fns.el (help-fns--key-bindings)
(help-fns--compiler-macro, help-fns--parent-mode)
(help-fns--obsolete, help-fns--interactive-only)
(describe-function-1, describe-variable):
* lisp/help.el (describe-mode)
(describe-minor-mode-from-indicator):
* lisp/image.el (image-type):
* lisp/international/ccl.el (ccl-dump):
* lisp/international/fontset.el (x-must-resolve-font-name):
* lisp/international/mule-cmds.el (prefer-coding-system)
(select-safe-coding-system-interactively)
(select-safe-coding-system, activate-input-method)
(toggle-input-method, describe-current-input-method)
(describe-language-environment):
* lisp/international/mule-conf.el (code-offset):
* lisp/international/mule-diag.el (describe-character-set)
(list-input-methods-1):
* lisp/mail/feedmail.el (feedmail-run-the-queue):
* lisp/mouse.el (minor-mode-menu-from-indicator):
* lisp/mpc.el (mpc-playlist-rename):
* lisp/msb.el (msb--choose-menu):
* lisp/net/ange-ftp.el (ange-ftp-shell-command):
* lisp/net/imap.el (imap-interactive-login):
* lisp/net/mairix.el (mairix-widget-create-query):
* lisp/net/newst-backend.el (newsticker--sentinel-work):
* lisp/net/newst-treeview.el (newsticker--treeview-load):
* lisp/net/rlogin.el (rlogin):
* lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer):
* lisp/obsolete/otodo-mode.el (todo-more-important-p):
* lisp/obsolete/pgg-gpg.el (pgg-gpg-process-region):
* lisp/obsolete/pgg-pgp.el (pgg-pgp-process-region):
* lisp/obsolete/pgg-pgp5.el (pgg-pgp5-process-region):
* lisp/org/ob-core.el (org-babel-goto-named-src-block)
(org-babel-goto-named-result):
* lisp/org/ob-fortran.el (org-babel-fortran-ensure-main-wrap):
* lisp/org/ob-ref.el (org-babel-ref-resolve):
* lisp/org/org-agenda.el (org-agenda-prepare):
* lisp/org/org-clock.el (org-clock-notify-once-if-expired)
(org-clock-resolve):
* lisp/org/org-ctags.el (org-ctags-ask-rebuild-tags-file-then-find-tag):
* lisp/org/org-feed.el (org-feed-parse-atom-entry):
* lisp/org/org-habit.el (org-habit-parse-todo):
* lisp/org/org-mouse.el (org-mouse-popup-global-menu)
(org-mouse-context-menu):
* lisp/org/org-table.el (org-table-edit-formulas):
* lisp/org/ox.el (org-export-async-start):
* lisp/proced.el (proced-log):
* lisp/progmodes/ada-mode.el (ada-get-indent-case)
(ada-check-matching-start, ada-goto-matching-start):
* lisp/progmodes/ada-prj.el (ada-prj-display-page):
* lisp/progmodes/ada-xref.el (ada-find-executable):
* lisp/progmodes/ebrowse.el (ebrowse-tags-apropos):
* lisp/progmodes/etags.el (etags-tags-apropos-additional):
* lisp/progmodes/flymake.el (flymake-parse-err-lines)
(flymake-start-syntax-check-process):
* lisp/progmodes/python.el (python-shell-get-process-or-error)
(python-define-auxiliary-skeleton):
* lisp/progmodes/sql.el (sql-comint):
* lisp/progmodes/verilog-mode.el (verilog-load-file-at-point):
* lisp/progmodes/vhdl-mode.el (vhdl-widget-directory-validate):
* lisp/recentf.el (recentf-open-files):
* lisp/replace.el (query-replace-read-from)
(occur-after-change-function, occur-1):
* lisp/scroll-bar.el (scroll-bar-columns):
* lisp/server.el (server-get-auth-key):
* lisp/simple.el (execute-extended-command)
(undo-outer-limit-truncate, list-processes--refresh)
(compose-mail, set-variable, choose-completion-string)
(define-alternatives):
* lisp/startup.el (site-run-file, tty-handle-args, command-line)
(command-line-1):
* lisp/subr.el (noreturn, define-error, add-to-list)
(read-char-choice, version-to-list):
* lisp/term/common-win.el (x-handle-xrm-switch)
(x-handle-name-switch, x-handle-args):
* lisp/term/x-win.el (x-handle-parent-id, x-handle-smid):
* lisp/textmodes/reftex-ref.el (reftex-label):
* lisp/textmodes/reftex-toc.el (reftex-toc-rename-label):
* lisp/textmodes/two-column.el (2C-split):
* lisp/tutorial.el (tutorial--describe-nonstandard-key)
(tutorial--find-changed-keys):
* lisp/type-break.el (type-break-noninteractive-query):
* lisp/wdired.el (wdired-do-renames, wdired-do-symlink-changes)
(wdired-do-perm-changes):
* lisp/whitespace.el (whitespace-report-region):
Prefer grave quoting in source-code strings used to generate help
and diagnostics.
* lisp/faces.el (face-documentation):
No need to convert quotes, since the result is a docstring.
* lisp/info.el (Info-virtual-index-find-node)
(Info-virtual-index, info-apropos):
Simplify by generating only curved quotes, since info files are
typically that ways nowadays anyway.
* lisp/international/mule-diag.el (list-input-methods):
Don’t assume text quoting style is curved.
* lisp/org/org-bibtex.el (org-bibtex-fields):
Revert my recent changes, going back to the old quoting style.
2015-09-07 15:41:44 +00:00
|
|
|
(fmt (format-read (format-message "Read file `%s' in format: "
|
More-conservative ‘format’ quote restyling
Instead of restyling curved quotes for every call to ‘format’,
create a new function ‘format-message’ that does the restyling,
and using the new function instead of ‘format’ only in contexts
where this seems appropriate.
Problem reported by Dmitry Gutov and Andreas Schwab in:
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00826.html
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00827.html
* doc/lispref/commands.texi (Using Interactive):
* doc/lispref/control.texi (Signaling Errors, Signaling Errors):
* doc/lispref/display.texi (Displaying Messages, Progress):
* doc/lispref/elisp.texi:
* doc/lispref/help.texi (Keys in Documentation):
* doc/lispref/minibuf.texi (Minibuffer Misc):
* doc/lispref/strings.texi (Formatting Strings):
* etc/NEWS:
Document the changes.
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/apropos.el (apropos-library):
* lisp/calc/calc-ext.el (calc-record-message)
(calc-user-function-list):
* lisp/calc/calc-help.el (calc-describe-key, calc-full-help):
* lisp/calc/calc-lang.el (math-read-big-balance):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-units.el (math-build-units-table-buffer):
* lisp/calc/calc-yank.el (calc-edit-mode):
* lisp/calendar/icalendar.el (icalendar-export-region)
(icalendar--add-diary-entry):
* lisp/cedet/mode-local.el (mode-local-print-binding)
(mode-local-describe-bindings-2):
* lisp/cedet/semantic/complete.el (semantic-completion-message):
* lisp/cedet/semantic/edit.el (semantic-parse-changes-failed):
* lisp/cedet/semantic/wisent/comp.el (wisent-log):
* lisp/cedet/srecode/insert.el (srecode-insert-show-error-report):
* lisp/descr-text.el (describe-text-properties-1, describe-char):
* lisp/dframe.el (dframe-message):
* lisp/dired-aux.el (dired-query):
* lisp/emacs-lisp/byte-opt.el (byte-compile-log-lap-1):
* lisp/emacs-lisp/bytecomp.el (byte-compile-log)
(byte-compile-log-file, byte-compile-warn, byte-compile-form):
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use)
(cconv-analyze-form):
* lisp/emacs-lisp/check-declare.el (check-declare-warn):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet):
* lisp/emacs-lisp/edebug.el (edebug-format):
* lisp/emacs-lisp/eieio-core.el (eieio-oref):
* lisp/emacs-lisp/eldoc.el (eldoc-minibuffer-message)
(eldoc-message):
* lisp/emacs-lisp/elint.el (elint-file, elint-log):
* lisp/emacs-lisp/find-func.el (find-function-library):
* lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/nadvice.el (advice--make-docstring):
* lisp/emacs-lisp/package.el (package-compute-transaction)
(package-install-button-action, package-delete-button-action)
(package-menu--list-to-prompt):
* lisp/emacs-lisp/timer.el (timer-event-handler):
* lisp/emacs-lisp/warnings.el (lwarn, warn):
* lisp/emulation/viper-cmd.el:
(viper-toggle-parse-sexp-ignore-comments)
(viper-kill-buffer, viper-brac-function):
* lisp/emulation/viper-macs.el (viper-record-kbd-macro):
* lisp/facemenu.el (facemenu-add-new-face):
* lisp/faces.el (face-documentation, read-face-name)
(face-read-string, read-face-font, describe-face):
* lisp/files.el (find-alternate-file, hack-local-variables)
(hack-one-local-variable--obsolete, write-file)
(basic-save-buffer, delete-directory):
* lisp/format.el (format-write-file, format-find-file)
(format-insert-file):
* lisp/help-fns.el (help-fns--key-bindings)
(help-fns--compiler-macro, help-fns--obsolete)
(help-fns--interactive-only, describe-function-1)
(describe-variable):
* lisp/help.el (describe-mode):
* lisp/info-xref.el (info-xref-output):
* lisp/info.el (Info-virtual-index-find-node)
(Info-virtual-index, info-apropos):
* lisp/international/kkc.el (kkc-error):
* lisp/international/mule-cmds.el:
(select-safe-coding-system-interactively)
(select-safe-coding-system, describe-input-method):
* lisp/international/mule-conf.el (code-offset):
* lisp/international/mule-diag.el (describe-character-set)
(list-input-methods-1):
* lisp/international/quail.el (quail-error):
* lisp/minibuffer.el (minibuffer-message):
* lisp/mpc.el (mpc--debug):
* lisp/msb.el (msb--choose-menu):
* lisp/net/ange-ftp.el (ange-ftp-message):
* lisp/net/gnutls.el (gnutls-message-maybe):
* lisp/net/newst-backend.el (newsticker--sentinel-work):
* lisp/net/newst-treeview.el (newsticker--treeview-load):
* lisp/net/nsm.el (nsm-query-user):
* lisp/net/rlogin.el (rlogin):
* lisp/net/soap-client.el (soap-warning):
* lisp/net/tramp.el (tramp-debug-message):
* lisp/nxml/nxml-outln.el (nxml-report-outline-error):
* lisp/nxml/nxml-parse.el (nxml-parse-error):
* lisp/nxml/rng-cmpct.el (rng-c-error):
* lisp/nxml/rng-match.el (rng-compile-error):
* lisp/nxml/rng-uri.el (rng-uri-error):
* lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer):
* lisp/org/org-ctags.el:
(org-ctags-ask-rebuild-tags-file-then-find-tag):
* lisp/proced.el (proced-log):
* lisp/progmodes/ebnf2ps.el (ebnf-log):
* lisp/progmodes/flymake.el (flymake-log):
* lisp/progmodes/vhdl-mode.el (vhdl-warning-when-idle):
* lisp/replace.el (occur-1):
* lisp/simple.el (execute-extended-command)
(undo-outer-limit-truncate, define-alternatives):
* lisp/startup.el (command-line):
* lisp/subr.el (error, user-error, add-to-list):
* lisp/tutorial.el (tutorial--describe-nonstandard-key)
(tutorial--find-changed-keys):
* src/callint.c (Fcall_interactively):
* src/editfns.c (Fmessage, Fmessage_box):
Restyle the quotes of format strings intended for use as a
diagnostic, when restyling seems appropriate.
* lisp/subr.el (format-message): New function.
* src/doc.c (Finternal__text_restyle): New function.
(syms_of_doc): Define it.
2015-08-24 05:38:02 +00:00
|
|
|
(file-name-nondirectory file)))))
|
1995-06-09 01:23:01 +00:00
|
|
|
(list file fmt)))
|
|
|
|
(let ((format-alist nil))
|
2021-01-05 01:57:42 +00:00
|
|
|
(with-suppressed-warnings ((interactive-only find-file))
|
|
|
|
(find-file filename)))
|
1995-06-09 01:23:01 +00:00
|
|
|
(if format
|
|
|
|
(format-decode-buffer format)))
|
|
|
|
|
|
|
|
(defun format-insert-file (filename format &optional beg end)
|
1999-01-23 21:52:40 +00:00
|
|
|
"Insert the contents of file FILENAME using data format FORMAT.
|
1995-06-09 01:23:01 +00:00
|
|
|
If FORMAT is nil then do not do any format conversion.
|
|
|
|
The optional third and fourth arguments BEG and END specify
|
2006-08-02 22:51:44 +00:00
|
|
|
the part (in bytes) of the file to read.
|
1995-06-09 01:23:01 +00:00
|
|
|
|
|
|
|
The return value is like the value of `insert-file-contents':
|
2004-04-16 12:51:06 +00:00
|
|
|
a list (ABSOLUTE-FILE-NAME SIZE)."
|
1995-06-09 01:23:01 +00:00
|
|
|
(interactive
|
|
|
|
;; Same interactive spec as write-file, plus format question.
|
|
|
|
(let* ((file (read-file-name "Find file: "))
|
Go back to grave quoting in source-code docstrings etc.
This reverts almost all my recent changes to use curved quotes
in docstrings and/or strings used for error diagnostics.
There are a few exceptions, e.g., Bahá’í proper names.
* admin/unidata/unidata-gen.el (unidata-gen-table):
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/align.el (align-region):
* lisp/allout.el (allout-mode, allout-solicit-alternate-bullet)
(outlineify-sticky):
* lisp/apropos.el (apropos-library):
* lisp/bookmark.el (bookmark-default-annotation-text):
* lisp/button.el (button-category-symbol, button-put)
(make-text-button):
* lisp/calc/calc-aent.el (math-read-if, math-read-factor):
* lisp/calc/calc-embed.el (calc-do-embedded):
* lisp/calc/calc-ext.el (calc-user-function-list):
* lisp/calc/calc-graph.el (calc-graph-show-dumb):
* lisp/calc/calc-help.el (calc-describe-key)
(calc-describe-thing, calc-full-help):
* lisp/calc/calc-lang.el (calc-c-language)
(math-parse-fortran-vector-end, math-parse-tex-sum)
(math-parse-eqn-matrix, math-parse-eqn-prime)
(calc-yacas-language, calc-maxima-language, calc-giac-language)
(math-read-giac-subscr, math-read-math-subscr)
(math-read-big-rec, math-read-big-balance):
* lisp/calc/calc-misc.el (calc-help, report-calc-bug):
* lisp/calc/calc-mode.el (calc-auto-why, calc-save-modes)
(calc-auto-recompute):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-read-parse-table-part, calc-user-define-invocation)
(math-do-arg-check):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-units.el (math-build-units-table-buffer):
* lisp/calc/calc-vec.el (math-read-brackets):
* lisp/calc/calc-yank.el (calc-edit-mode):
* lisp/calc/calc.el (calc, calc-do, calc-user-invocation):
* lisp/calendar/appt.el (appt-display-message):
* lisp/calendar/diary-lib.el (diary-check-diary-file)
(diary-mail-entries, diary-from-outlook):
* lisp/calendar/icalendar.el (icalendar-export-region)
(icalendar--convert-float-to-ical)
(icalendar--convert-date-to-ical)
(icalendar--convert-ical-to-diary)
(icalendar--convert-recurring-to-diary)
(icalendar--add-diary-entry):
* lisp/calendar/time-date.el (format-seconds):
* lisp/calendar/timeclock.el (timeclock-mode-line-display)
(timeclock-make-hours-explicit, timeclock-log-data):
* lisp/calendar/todo-mode.el (todo-prefix, todo-delete-category)
(todo-item-mark, todo-check-format)
(todo-insert-item--next-param, todo-edit-item--next-key)
(todo-mode):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/mode-local.el (describe-mode-local-overload)
(mode-local-print-binding, mode-local-describe-bindings-2):
* lisp/cedet/semantic/complete.el (semantic-displayor-show-request):
* lisp/cedet/srecode/srt-mode.el (srecode-macro-help):
* lisp/cus-start.el (standard):
* lisp/cus-theme.el (describe-theme-1):
* lisp/custom.el (custom-add-dependencies, custom-check-theme)
(custom--sort-vars-1, load-theme):
* lisp/descr-text.el (describe-text-properties-1, describe-char):
* lisp/dired-x.el (dired-do-run-mail):
* lisp/dired.el (dired-log):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-enable-advice)
(ad-disable-advice, ad-remove-advice, ad-set-argument)
(ad-set-arguments, ad--defalias-fset, ad-activate)
(ad-deactivate):
* lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand)
(byte-compile-unfold-lambda, byte-optimize-form-code-walker)
(byte-optimize-while, byte-optimize-apply):
* lisp/emacs-lisp/byte-run.el (defun, defsubst):
* lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode)
(byte-compile-log-file, byte-compile-format-warn)
(byte-compile-nogroup-warn, byte-compile-arglist-warn)
(byte-compile-cl-warn)
(byte-compile-warn-about-unresolved-functions)
(byte-compile-file, byte-compile--declare-var)
(byte-compile-file-form-defmumble, byte-compile-form)
(byte-compile-normal-call, byte-compile-check-variable)
(byte-compile-variable-ref, byte-compile-variable-set)
(byte-compile-subr-wrong-args, byte-compile-setq-default)
(byte-compile-negation-optimizer)
(byte-compile-condition-case--old)
(byte-compile-condition-case--new, byte-compile-save-excursion)
(byte-compile-defvar, byte-compile-autoload)
(byte-compile-lambda-form)
(byte-compile-make-variable-buffer-local, display-call-tree)
(batch-byte-compile):
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use):
* lisp/emacs-lisp/chart.el (chart-space-usage):
* lisp/emacs-lisp/check-declare.el (check-declare-scan)
(check-declare-warn, check-declare-file)
(check-declare-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine)
(checkdoc-message-text-engine):
* lisp/emacs-lisp/cl-extra.el (cl-parse-integer)
(cl--describe-class):
* lisp/emacs-lisp/cl-generic.el (cl-defgeneric)
(cl--generic-describe, cl-generic-generalizers):
* lisp/emacs-lisp/cl-macs.el (cl--parse-loop-clause, cl-tagbody)
(cl-symbol-macrolet):
* lisp/emacs-lisp/cl.el (cl-unload-function, flet):
* lisp/emacs-lisp/copyright.el (copyright)
(copyright-update-directory):
* lisp/emacs-lisp/edebug.el (edebug-read-list):
* lisp/emacs-lisp/eieio-base.el (eieio-persistent-read):
* lisp/emacs-lisp/eieio-core.el (eieio--slot-override)
(eieio-oref):
* lisp/emacs-lisp/eieio-opt.el (eieio-help-constructor):
* lisp/emacs-lisp/eieio-speedbar.el:
(eieio-speedbar-child-make-tag-lines)
(eieio-speedbar-child-description):
* lisp/emacs-lisp/eieio.el (defclass, change-class):
* lisp/emacs-lisp/elint.el (elint-file, elint-get-top-forms)
(elint-init-form, elint-check-defalias-form)
(elint-check-let-form):
* lisp/emacs-lisp/ert.el (ert-get-test, ert-results-mode-menu)
(ert-results-pop-to-backtrace-for-test-at-point)
(ert-results-pop-to-messages-for-test-at-point)
(ert-results-pop-to-should-forms-for-test-at-point)
(ert-describe-test):
* lisp/emacs-lisp/find-func.el (find-function-search-for-symbol)
(find-function-library):
* lisp/emacs-lisp/generator.el (iter-yield):
* lisp/emacs-lisp/gv.el (gv-define-simple-setter):
* lisp/emacs-lisp/lisp-mnt.el (lm-verify):
* lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/nadvice.el (advice--make-docstring)
(advice--make, define-advice):
* lisp/emacs-lisp/package-x.el (package-upload-file):
* lisp/emacs-lisp/package.el (package-version-join)
(package-disabled-p, package-activate-1, package-activate)
(package--download-one-archive)
(package--download-and-read-archives)
(package-compute-transaction, package-install-from-archive)
(package-install, package-install-selected-packages)
(package-delete, package-autoremove, describe-package-1)
(package-install-button-action, package-delete-button-action)
(package-menu-hide-package, package-menu--list-to-prompt)
(package-menu--perform-transaction)
(package-menu--find-and-notify-upgrades):
* lisp/emacs-lisp/pcase.el (pcase-exhaustive, pcase--u1):
* lisp/emacs-lisp/re-builder.el (reb-enter-subexp-mode):
* lisp/emacs-lisp/ring.el (ring-previous, ring-next):
* lisp/emacs-lisp/rx.el (rx-check, rx-anything)
(rx-check-any-string, rx-check-any, rx-check-not, rx-=)
(rx-repeat, rx-check-backref, rx-syntax, rx-check-category)
(rx-form):
* lisp/emacs-lisp/smie.el (smie-config-save):
* lisp/emacs-lisp/subr-x.el (internal--check-binding):
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-put-tag):
* lisp/emacs-lisp/testcover.el (testcover-1value):
* lisp/emacs-lisp/timer.el (timer-event-handler):
* lisp/emulation/viper-cmd.el (viper-toggle-parse-sexp-ignore-comments)
(viper-toggle-search-style, viper-kill-buffer)
(viper-brac-function):
* lisp/emulation/viper-macs.el (viper-record-kbd-macro):
* lisp/env.el (setenv):
* lisp/erc/erc-button.el (erc-nick-popup):
* lisp/erc/erc.el (erc-cmd-LOAD, erc-handle-login, english):
* lisp/eshell/em-dirs.el (eshell/cd):
* lisp/eshell/em-glob.el (eshell-glob-regexp)
(eshell-glob-entries):
* lisp/eshell/em-pred.el (eshell-parse-modifiers):
* lisp/eshell/esh-opt.el (eshell-show-usage):
* lisp/facemenu.el (facemenu-add-new-face)
(facemenu-add-new-color):
* lisp/faces.el (read-face-name, read-face-font, describe-face)
(x-resolve-font-name):
* lisp/files-x.el (modify-file-local-variable):
* lisp/files.el (locate-user-emacs-file, find-alternate-file)
(set-auto-mode, hack-one-local-variable--obsolete)
(dir-locals-set-directory-class, write-file, basic-save-buffer)
(delete-directory, copy-directory, recover-session)
(recover-session-finish, insert-directory)
(file-modes-char-to-who, file-modes-symbolic-to-number)
(move-file-to-trash):
* lisp/filesets.el (filesets-add-buffer, filesets-remove-buffer):
* lisp/find-cmd.el (find-generic, find-to-string):
* lisp/finder.el (finder-commentary):
* lisp/font-lock.el (font-lock-fontify-buffer):
* lisp/format.el (format-write-file, format-find-file)
(format-insert-file):
* lisp/frame.el (get-device-terminal, select-frame-by-name):
* lisp/fringe.el (fringe--check-style):
* lisp/gnus/nnmairix.el (nnmairix-widget-create-query):
* lisp/help-fns.el (help-fns--key-bindings)
(help-fns--compiler-macro, help-fns--parent-mode)
(help-fns--obsolete, help-fns--interactive-only)
(describe-function-1, describe-variable):
* lisp/help.el (describe-mode)
(describe-minor-mode-from-indicator):
* lisp/image.el (image-type):
* lisp/international/ccl.el (ccl-dump):
* lisp/international/fontset.el (x-must-resolve-font-name):
* lisp/international/mule-cmds.el (prefer-coding-system)
(select-safe-coding-system-interactively)
(select-safe-coding-system, activate-input-method)
(toggle-input-method, describe-current-input-method)
(describe-language-environment):
* lisp/international/mule-conf.el (code-offset):
* lisp/international/mule-diag.el (describe-character-set)
(list-input-methods-1):
* lisp/mail/feedmail.el (feedmail-run-the-queue):
* lisp/mouse.el (minor-mode-menu-from-indicator):
* lisp/mpc.el (mpc-playlist-rename):
* lisp/msb.el (msb--choose-menu):
* lisp/net/ange-ftp.el (ange-ftp-shell-command):
* lisp/net/imap.el (imap-interactive-login):
* lisp/net/mairix.el (mairix-widget-create-query):
* lisp/net/newst-backend.el (newsticker--sentinel-work):
* lisp/net/newst-treeview.el (newsticker--treeview-load):
* lisp/net/rlogin.el (rlogin):
* lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer):
* lisp/obsolete/otodo-mode.el (todo-more-important-p):
* lisp/obsolete/pgg-gpg.el (pgg-gpg-process-region):
* lisp/obsolete/pgg-pgp.el (pgg-pgp-process-region):
* lisp/obsolete/pgg-pgp5.el (pgg-pgp5-process-region):
* lisp/org/ob-core.el (org-babel-goto-named-src-block)
(org-babel-goto-named-result):
* lisp/org/ob-fortran.el (org-babel-fortran-ensure-main-wrap):
* lisp/org/ob-ref.el (org-babel-ref-resolve):
* lisp/org/org-agenda.el (org-agenda-prepare):
* lisp/org/org-clock.el (org-clock-notify-once-if-expired)
(org-clock-resolve):
* lisp/org/org-ctags.el (org-ctags-ask-rebuild-tags-file-then-find-tag):
* lisp/org/org-feed.el (org-feed-parse-atom-entry):
* lisp/org/org-habit.el (org-habit-parse-todo):
* lisp/org/org-mouse.el (org-mouse-popup-global-menu)
(org-mouse-context-menu):
* lisp/org/org-table.el (org-table-edit-formulas):
* lisp/org/ox.el (org-export-async-start):
* lisp/proced.el (proced-log):
* lisp/progmodes/ada-mode.el (ada-get-indent-case)
(ada-check-matching-start, ada-goto-matching-start):
* lisp/progmodes/ada-prj.el (ada-prj-display-page):
* lisp/progmodes/ada-xref.el (ada-find-executable):
* lisp/progmodes/ebrowse.el (ebrowse-tags-apropos):
* lisp/progmodes/etags.el (etags-tags-apropos-additional):
* lisp/progmodes/flymake.el (flymake-parse-err-lines)
(flymake-start-syntax-check-process):
* lisp/progmodes/python.el (python-shell-get-process-or-error)
(python-define-auxiliary-skeleton):
* lisp/progmodes/sql.el (sql-comint):
* lisp/progmodes/verilog-mode.el (verilog-load-file-at-point):
* lisp/progmodes/vhdl-mode.el (vhdl-widget-directory-validate):
* lisp/recentf.el (recentf-open-files):
* lisp/replace.el (query-replace-read-from)
(occur-after-change-function, occur-1):
* lisp/scroll-bar.el (scroll-bar-columns):
* lisp/server.el (server-get-auth-key):
* lisp/simple.el (execute-extended-command)
(undo-outer-limit-truncate, list-processes--refresh)
(compose-mail, set-variable, choose-completion-string)
(define-alternatives):
* lisp/startup.el (site-run-file, tty-handle-args, command-line)
(command-line-1):
* lisp/subr.el (noreturn, define-error, add-to-list)
(read-char-choice, version-to-list):
* lisp/term/common-win.el (x-handle-xrm-switch)
(x-handle-name-switch, x-handle-args):
* lisp/term/x-win.el (x-handle-parent-id, x-handle-smid):
* lisp/textmodes/reftex-ref.el (reftex-label):
* lisp/textmodes/reftex-toc.el (reftex-toc-rename-label):
* lisp/textmodes/two-column.el (2C-split):
* lisp/tutorial.el (tutorial--describe-nonstandard-key)
(tutorial--find-changed-keys):
* lisp/type-break.el (type-break-noninteractive-query):
* lisp/wdired.el (wdired-do-renames, wdired-do-symlink-changes)
(wdired-do-perm-changes):
* lisp/whitespace.el (whitespace-report-region):
Prefer grave quoting in source-code strings used to generate help
and diagnostics.
* lisp/faces.el (face-documentation):
No need to convert quotes, since the result is a docstring.
* lisp/info.el (Info-virtual-index-find-node)
(Info-virtual-index, info-apropos):
Simplify by generating only curved quotes, since info files are
typically that ways nowadays anyway.
* lisp/international/mule-diag.el (list-input-methods):
Don’t assume text quoting style is curved.
* lisp/org/org-bibtex.el (org-bibtex-fields):
Revert my recent changes, going back to the old quoting style.
2015-09-07 15:41:44 +00:00
|
|
|
(fmt (format-read (format-message "Read file `%s' in format: "
|
More-conservative ‘format’ quote restyling
Instead of restyling curved quotes for every call to ‘format’,
create a new function ‘format-message’ that does the restyling,
and using the new function instead of ‘format’ only in contexts
where this seems appropriate.
Problem reported by Dmitry Gutov and Andreas Schwab in:
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00826.html
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00827.html
* doc/lispref/commands.texi (Using Interactive):
* doc/lispref/control.texi (Signaling Errors, Signaling Errors):
* doc/lispref/display.texi (Displaying Messages, Progress):
* doc/lispref/elisp.texi:
* doc/lispref/help.texi (Keys in Documentation):
* doc/lispref/minibuf.texi (Minibuffer Misc):
* doc/lispref/strings.texi (Formatting Strings):
* etc/NEWS:
Document the changes.
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/apropos.el (apropos-library):
* lisp/calc/calc-ext.el (calc-record-message)
(calc-user-function-list):
* lisp/calc/calc-help.el (calc-describe-key, calc-full-help):
* lisp/calc/calc-lang.el (math-read-big-balance):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-units.el (math-build-units-table-buffer):
* lisp/calc/calc-yank.el (calc-edit-mode):
* lisp/calendar/icalendar.el (icalendar-export-region)
(icalendar--add-diary-entry):
* lisp/cedet/mode-local.el (mode-local-print-binding)
(mode-local-describe-bindings-2):
* lisp/cedet/semantic/complete.el (semantic-completion-message):
* lisp/cedet/semantic/edit.el (semantic-parse-changes-failed):
* lisp/cedet/semantic/wisent/comp.el (wisent-log):
* lisp/cedet/srecode/insert.el (srecode-insert-show-error-report):
* lisp/descr-text.el (describe-text-properties-1, describe-char):
* lisp/dframe.el (dframe-message):
* lisp/dired-aux.el (dired-query):
* lisp/emacs-lisp/byte-opt.el (byte-compile-log-lap-1):
* lisp/emacs-lisp/bytecomp.el (byte-compile-log)
(byte-compile-log-file, byte-compile-warn, byte-compile-form):
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use)
(cconv-analyze-form):
* lisp/emacs-lisp/check-declare.el (check-declare-warn):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet):
* lisp/emacs-lisp/edebug.el (edebug-format):
* lisp/emacs-lisp/eieio-core.el (eieio-oref):
* lisp/emacs-lisp/eldoc.el (eldoc-minibuffer-message)
(eldoc-message):
* lisp/emacs-lisp/elint.el (elint-file, elint-log):
* lisp/emacs-lisp/find-func.el (find-function-library):
* lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/nadvice.el (advice--make-docstring):
* lisp/emacs-lisp/package.el (package-compute-transaction)
(package-install-button-action, package-delete-button-action)
(package-menu--list-to-prompt):
* lisp/emacs-lisp/timer.el (timer-event-handler):
* lisp/emacs-lisp/warnings.el (lwarn, warn):
* lisp/emulation/viper-cmd.el:
(viper-toggle-parse-sexp-ignore-comments)
(viper-kill-buffer, viper-brac-function):
* lisp/emulation/viper-macs.el (viper-record-kbd-macro):
* lisp/facemenu.el (facemenu-add-new-face):
* lisp/faces.el (face-documentation, read-face-name)
(face-read-string, read-face-font, describe-face):
* lisp/files.el (find-alternate-file, hack-local-variables)
(hack-one-local-variable--obsolete, write-file)
(basic-save-buffer, delete-directory):
* lisp/format.el (format-write-file, format-find-file)
(format-insert-file):
* lisp/help-fns.el (help-fns--key-bindings)
(help-fns--compiler-macro, help-fns--obsolete)
(help-fns--interactive-only, describe-function-1)
(describe-variable):
* lisp/help.el (describe-mode):
* lisp/info-xref.el (info-xref-output):
* lisp/info.el (Info-virtual-index-find-node)
(Info-virtual-index, info-apropos):
* lisp/international/kkc.el (kkc-error):
* lisp/international/mule-cmds.el:
(select-safe-coding-system-interactively)
(select-safe-coding-system, describe-input-method):
* lisp/international/mule-conf.el (code-offset):
* lisp/international/mule-diag.el (describe-character-set)
(list-input-methods-1):
* lisp/international/quail.el (quail-error):
* lisp/minibuffer.el (minibuffer-message):
* lisp/mpc.el (mpc--debug):
* lisp/msb.el (msb--choose-menu):
* lisp/net/ange-ftp.el (ange-ftp-message):
* lisp/net/gnutls.el (gnutls-message-maybe):
* lisp/net/newst-backend.el (newsticker--sentinel-work):
* lisp/net/newst-treeview.el (newsticker--treeview-load):
* lisp/net/nsm.el (nsm-query-user):
* lisp/net/rlogin.el (rlogin):
* lisp/net/soap-client.el (soap-warning):
* lisp/net/tramp.el (tramp-debug-message):
* lisp/nxml/nxml-outln.el (nxml-report-outline-error):
* lisp/nxml/nxml-parse.el (nxml-parse-error):
* lisp/nxml/rng-cmpct.el (rng-c-error):
* lisp/nxml/rng-match.el (rng-compile-error):
* lisp/nxml/rng-uri.el (rng-uri-error):
* lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer):
* lisp/org/org-ctags.el:
(org-ctags-ask-rebuild-tags-file-then-find-tag):
* lisp/proced.el (proced-log):
* lisp/progmodes/ebnf2ps.el (ebnf-log):
* lisp/progmodes/flymake.el (flymake-log):
* lisp/progmodes/vhdl-mode.el (vhdl-warning-when-idle):
* lisp/replace.el (occur-1):
* lisp/simple.el (execute-extended-command)
(undo-outer-limit-truncate, define-alternatives):
* lisp/startup.el (command-line):
* lisp/subr.el (error, user-error, add-to-list):
* lisp/tutorial.el (tutorial--describe-nonstandard-key)
(tutorial--find-changed-keys):
* src/callint.c (Fcall_interactively):
* src/editfns.c (Fmessage, Fmessage_box):
Restyle the quotes of format strings intended for use as a
diagnostic, when restyling seems appropriate.
* lisp/subr.el (format-message): New function.
* src/doc.c (Finternal__text_restyle): New function.
(syms_of_doc): Define it.
2015-08-24 05:38:02 +00:00
|
|
|
(file-name-nondirectory file)))))
|
1995-06-09 01:23:01 +00:00
|
|
|
(list file fmt)))
|
2007-08-07 12:43:40 +00:00
|
|
|
(let (value size old-undo)
|
|
|
|
;; Record only one undo entry for the insertion. Inhibit point-motion and
|
|
|
|
;; modification hooks as with `insert-file-contents'.
|
|
|
|
(let ((inhibit-point-motion-hooks t)
|
|
|
|
(inhibit-modification-hooks t))
|
|
|
|
;; Don't bind `buffer-undo-list' to t here to assert that
|
|
|
|
;; `insert-file-contents' may record whether the buffer was unmodified
|
|
|
|
;; before.
|
|
|
|
(let ((format-alist nil))
|
|
|
|
(setq value (insert-file-contents filename nil beg end))
|
|
|
|
(setq size (nth 1 value)))
|
|
|
|
(when (consp buffer-undo-list)
|
|
|
|
(let ((head (car buffer-undo-list)))
|
|
|
|
(when (and (consp head)
|
|
|
|
(equal (car head) (point))
|
|
|
|
(equal (cdr head) (+ (point) size)))
|
|
|
|
;; Remove first entry from `buffer-undo-list', we shall insert
|
|
|
|
;; another one below.
|
|
|
|
(setq old-undo (cdr buffer-undo-list)))))
|
|
|
|
(when format
|
|
|
|
(let ((buffer-undo-list t))
|
|
|
|
(setq size (format-decode format size)
|
|
|
|
value (list (car value) size)))
|
|
|
|
(unless (eq buffer-undo-list t)
|
|
|
|
(setq buffer-undo-list
|
|
|
|
(cons (cons (point) (+ (point) size)) old-undo)))))
|
|
|
|
(unless inhibit-modification-hooks
|
|
|
|
(run-hook-with-args 'after-change-functions (point) (+ (point) size) 0))
|
1995-06-09 01:23:01 +00:00
|
|
|
value))
|
|
|
|
|
1995-03-17 18:14:30 +00:00
|
|
|
(defun format-read (&optional prompt)
|
|
|
|
"Read and return the name of a format.
|
|
|
|
Return value is a list, like `buffer-file-format'; it may be nil.
|
|
|
|
Formats are defined in `format-alist'. Optional arg is the PROMPT to use."
|
|
|
|
(let* ((table (mapcar (lambda (x) (list (symbol-name (car x))))
|
|
|
|
format-alist))
|
|
|
|
(ans (completing-read (or prompt "Format: ") table nil t)))
|
|
|
|
(if (not (equal "" ans)) (list (intern ans)))))
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
;;; Below are some functions that may be useful in writing encoding and
|
|
|
|
;;; decoding functions for use in format-alist.
|
|
|
|
;;;
|
|
|
|
|
|
|
|
(defun format-replace-strings (alist &optional reverse beg end)
|
|
|
|
"Do multiple replacements on the buffer.
|
2002-01-05 09:06:53 +00:00
|
|
|
ALIST is a list of (FROM . TO) pairs, which should be proper arguments to
|
2006-08-02 22:51:44 +00:00
|
|
|
`search-forward' and `replace-match', respectively.
|
|
|
|
Optional second arg REVERSE, if non-nil, means the pairs are (TO . FROM),
|
|
|
|
so that you can use the same list in both directions if it contains only
|
|
|
|
literal strings.
|
1999-01-23 21:52:40 +00:00
|
|
|
Optional args BEG and END specify a region of the buffer on which to operate."
|
1995-03-17 18:14:30 +00:00
|
|
|
(save-excursion
|
|
|
|
(save-restriction
|
|
|
|
(or beg (setq beg (point-min)))
|
|
|
|
(if end (narrow-to-region (point-min) end))
|
|
|
|
(while alist
|
|
|
|
(let ((from (if reverse (cdr (car alist)) (car (car alist))))
|
1999-02-14 06:00:44 +00:00
|
|
|
(to (if reverse (car (car alist)) (cdr (car alist)))))
|
1995-03-17 18:14:30 +00:00
|
|
|
(goto-char beg)
|
|
|
|
(while (search-forward from nil t)
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
(insert to)
|
|
|
|
(set-text-properties (- (point) (length to)) (point)
|
|
|
|
(text-properties-at (point)))
|
|
|
|
(delete-region (point) (+ (point) (- (match-end 0)
|
|
|
|
(match-beginning 0)))))
|
|
|
|
(setq alist (cdr alist)))))))
|
|
|
|
|
|
|
|
;;; Some list-manipulation functions that we need.
|
|
|
|
|
|
|
|
(defun format-delq-cons (cons list)
|
1999-01-23 21:52:40 +00:00
|
|
|
"Remove the given CONS from LIST by side effect and return the new LIST.
|
|
|
|
Since CONS could be the first element of LIST, write
|
2015-09-17 19:28:45 +00:00
|
|
|
\(setq foo \(format-delq-cons element foo)) to be sure of changing
|
1999-01-23 21:52:40 +00:00
|
|
|
the value of `foo'."
|
1995-03-17 18:14:30 +00:00
|
|
|
(if (eq cons list)
|
|
|
|
(cdr list)
|
|
|
|
(let ((p list))
|
|
|
|
(while (not (eq (cdr p) cons))
|
2021-09-27 21:56:55 +00:00
|
|
|
(if (null p) (error "format-delq-cons: Not an element"))
|
1995-03-17 18:14:30 +00:00
|
|
|
(setq p (cdr p)))
|
|
|
|
;; Now (cdr p) is the cons to delete
|
|
|
|
(setcdr p (cdr cons))
|
|
|
|
list)))
|
2003-02-04 11:26:42 +00:00
|
|
|
|
1995-03-17 18:14:30 +00:00
|
|
|
(defun format-make-relatively-unique (a b)
|
|
|
|
"Delete common elements of lists A and B, return as pair.
|
2006-08-02 22:51:44 +00:00
|
|
|
Compare using `equal'."
|
1995-03-17 18:14:30 +00:00
|
|
|
(let* ((acopy (copy-sequence a))
|
|
|
|
(bcopy (copy-sequence b))
|
|
|
|
(tail acopy))
|
|
|
|
(while tail
|
|
|
|
(let ((dup (member (car tail) bcopy))
|
|
|
|
(next (cdr tail)))
|
|
|
|
(if dup (setq acopy (format-delq-cons tail acopy)
|
|
|
|
bcopy (format-delq-cons dup bcopy)))
|
|
|
|
(setq tail next)))
|
|
|
|
(cons acopy bcopy)))
|
|
|
|
|
2018-07-16 01:28:35 +00:00
|
|
|
(define-obsolete-function-alias 'format-proper-list-p 'proper-list-p "27.1")
|
|
|
|
|
1995-03-17 18:14:30 +00:00
|
|
|
(defun format-reorder (items order)
|
2006-08-02 22:51:44 +00:00
|
|
|
"Arrange ITEMS to follow partial ORDER.
|
|
|
|
Elements of ITEMS equal to elements of ORDER will be rearranged
|
|
|
|
to follow the ORDER. Unmatched items will go last."
|
1995-03-17 18:14:30 +00:00
|
|
|
(if order
|
|
|
|
(let ((item (member (car order) items)))
|
|
|
|
(if item
|
1999-01-23 21:52:40 +00:00
|
|
|
(cons (car item)
|
1995-03-17 18:14:30 +00:00
|
|
|
(format-reorder (format-delq-cons item items)
|
|
|
|
(cdr order)))
|
|
|
|
(format-reorder items (cdr order))))
|
|
|
|
items))
|
|
|
|
|
|
|
|
(put 'face 'format-list-valued t) ; These text-properties take values
|
|
|
|
(put 'unknown 'format-list-valued t) ; that are lists, the elements of which
|
|
|
|
; should be considered separately.
|
|
|
|
; See format-deannotate-region and
|
|
|
|
; format-annotate-region.
|
|
|
|
|
1999-07-21 21:43:03 +00:00
|
|
|
;; This text property has list values, but they are treated atomically.
|
|
|
|
|
|
|
|
(put 'display 'format-list-atomic-p t)
|
|
|
|
|
1995-03-17 18:14:30 +00:00
|
|
|
;;;
|
|
|
|
;;; Decoding
|
|
|
|
;;;
|
|
|
|
|
|
|
|
(defun format-deannotate-region (from to translations next-fn)
|
|
|
|
"Translate annotations in the region into text properties.
|
1999-01-23 21:52:40 +00:00
|
|
|
This sets text properties between FROM to TO as directed by the
|
1995-03-17 18:14:30 +00:00
|
|
|
TRANSLATIONS and NEXT-FN arguments.
|
|
|
|
|
|
|
|
NEXT-FN is a function that searches forward from point for an annotation.
|
|
|
|
It should return a list of 4 elements: \(BEGIN END NAME POSITIVE). BEGIN and
|
|
|
|
END are buffer positions bounding the annotation, NAME is the name searched
|
|
|
|
for in TRANSLATIONS, and POSITIVE should be non-nil if this annotation marks
|
|
|
|
the beginning of a region with some property, or nil if it ends the region.
|
|
|
|
NEXT-FN should return nil if there are no annotations after point.
|
|
|
|
|
|
|
|
The basic format of the TRANSLATIONS argument is described in the
|
|
|
|
documentation for the `format-annotate-region' function. There are some
|
|
|
|
additional things to keep in mind for decoding, though:
|
|
|
|
|
|
|
|
When an annotation is found, the TRANSLATIONS list is searched for a
|
|
|
|
text-property name and value that corresponds to that annotation. If the
|
|
|
|
text-property has several annotations associated with it, it will be used only
|
|
|
|
if the other annotations are also in effect at that point. The first match
|
|
|
|
found whose annotations are all present is used.
|
|
|
|
|
|
|
|
The text property thus determined is set to the value over the region between
|
|
|
|
the opening and closing annotations. However, if the text-property name has a
|
|
|
|
non-nil `format-list-valued' property, then the value will be consed onto the
|
|
|
|
surrounding value of the property, rather than replacing that value.
|
|
|
|
|
|
|
|
There are some special symbols that can be used in the \"property\" slot of
|
|
|
|
the TRANSLATIONS list: PARAMETER and FUNCTION \(spelled in uppercase).
|
|
|
|
Annotations listed under the pseudo-property PARAMETER are considered to be
|
|
|
|
arguments of the immediately surrounding annotation; the text between the
|
|
|
|
opening and closing parameter annotations is deleted from the buffer but saved
|
2002-04-03 15:29:25 +00:00
|
|
|
as a string.
|
|
|
|
|
|
|
|
The surrounding annotation should be listed under the pseudo-property
|
|
|
|
FUNCTION. Instead of inserting a text-property for this annotation,
|
|
|
|
the function listed in the VALUE slot is called to make whatever
|
|
|
|
changes are appropriate. It can also return a list of the form
|
|
|
|
\(START LOC PROP VALUE) which specifies a property to put on. The
|
|
|
|
function's first two arguments are the START and END locations, and
|
|
|
|
the rest of the arguments are any PARAMETERs found in that region.
|
1995-03-17 18:14:30 +00:00
|
|
|
|
|
|
|
Any annotations that are found by NEXT-FN but not defined by TRANSLATIONS
|
|
|
|
are saved as values of the `unknown' text-property \(which is list-valued).
|
|
|
|
The TRANSLATIONS list should usually contain an entry of the form
|
2015-09-17 23:08:20 +00:00
|
|
|
(unknown (nil format-annotate-value))
|
1995-03-17 18:14:30 +00:00
|
|
|
to write these unknown annotations back into the file."
|
|
|
|
(save-excursion
|
|
|
|
(save-restriction
|
|
|
|
(narrow-to-region (point-min) to)
|
|
|
|
(goto-char from)
|
2011-04-19 13:44:55 +00:00
|
|
|
(let (next open-ans todo unknown-ans)
|
1995-03-17 18:14:30 +00:00
|
|
|
(while (setq next (funcall next-fn))
|
|
|
|
(let* ((loc (nth 0 next))
|
|
|
|
(end (nth 1 next))
|
|
|
|
(name (nth 2 next))
|
|
|
|
(positive (nth 3 next))
|
|
|
|
(found nil))
|
|
|
|
|
|
|
|
;; Delete the annotation
|
|
|
|
(delete-region loc end)
|
1997-08-30 23:25:29 +00:00
|
|
|
(cond
|
|
|
|
;; Positive annotations are stacked, remembering location
|
2002-11-08 02:38:54 +00:00
|
|
|
(positive (push `(,name ((,loc . nil))) open-ans))
|
1997-08-30 23:25:29 +00:00
|
|
|
;; It is a negative annotation:
|
|
|
|
;; Close the top annotation & add its text property.
|
|
|
|
;; If the file's nesting is messed up, the close might not match
|
|
|
|
;; the top thing on the open-annotations stack.
|
|
|
|
;; If no matching annotation is open, just ignore the close.
|
|
|
|
((not (assoc name open-ans))
|
|
|
|
(message "Extra closing annotation (%s) in file" name))
|
|
|
|
;; If one is open, but not on the top of the stack, close
|
|
|
|
;; the things in between as well. Set `found' when the real
|
|
|
|
;; one is closed.
|
|
|
|
(t
|
|
|
|
(while (not found)
|
|
|
|
(let* ((top (car open-ans)) ; first on stack: should match.
|
|
|
|
(top-name (car top)) ; text property name
|
|
|
|
(top-extents (nth 1 top)) ; property regions
|
|
|
|
(params (cdr (cdr top))) ; parameters
|
|
|
|
(aalist translations)
|
|
|
|
(matched nil))
|
|
|
|
(if (equal name top-name)
|
|
|
|
(setq found t)
|
|
|
|
(message "Improper nesting in file."))
|
|
|
|
;; Look through property names in TRANSLATIONS
|
|
|
|
(while aalist
|
|
|
|
(let ((prop (car (car aalist)))
|
|
|
|
(alist (cdr (car aalist))))
|
|
|
|
;; And look through values for each property
|
|
|
|
(while alist
|
|
|
|
(let ((value (car (car alist)))
|
|
|
|
(ans (cdr (car alist))))
|
|
|
|
(if (member top-name ans)
|
|
|
|
;; This annotation is listed, but still have to
|
|
|
|
;; check if multiple annotations are satisfied
|
|
|
|
(if (member nil (mapcar (lambda (r)
|
|
|
|
(assoc r open-ans))
|
|
|
|
ans))
|
|
|
|
nil ; multiple ans not satisfied
|
|
|
|
;; If there are multiple annotations going
|
|
|
|
;; into one text property, split up the other
|
|
|
|
;; annotations so they apply individually to
|
|
|
|
;; the other regions.
|
|
|
|
(setcdr (car top-extents) loc)
|
|
|
|
(let ((to-split ans) this-one extents)
|
|
|
|
(while to-split
|
|
|
|
(setq this-one
|
|
|
|
(assoc (car to-split) open-ans)
|
|
|
|
extents (nth 1 this-one))
|
|
|
|
(if (not (eq this-one top))
|
|
|
|
(setcar (cdr this-one)
|
|
|
|
(format-subtract-regions
|
|
|
|
extents top-extents)))
|
|
|
|
(setq to-split (cdr to-split))))
|
|
|
|
;; Set loop variables to nil so loop
|
|
|
|
;; will exit.
|
|
|
|
(setq alist nil aalist nil matched t
|
|
|
|
;; pop annotation off stack.
|
|
|
|
open-ans (cdr open-ans))
|
|
|
|
(let ((extents top-extents)
|
|
|
|
(start (car (car top-extents)))
|
|
|
|
(loc (cdr (car top-extents))))
|
|
|
|
(while extents
|
|
|
|
(cond
|
|
|
|
;; Check for pseudo-properties
|
|
|
|
((eq prop 'PARAMETER)
|
|
|
|
;; A parameter of the top open ann:
|
|
|
|
;; delete text and use as arg.
|
|
|
|
(if open-ans
|
|
|
|
;; (If nothing open, discard).
|
|
|
|
(setq open-ans
|
|
|
|
(cons
|
|
|
|
(append (car open-ans)
|
|
|
|
(list
|
|
|
|
(buffer-substring
|
|
|
|
start loc)))
|
|
|
|
(cdr open-ans))))
|
|
|
|
(delete-region start loc))
|
|
|
|
((eq prop 'FUNCTION)
|
|
|
|
;; Not a property, but a function.
|
|
|
|
(let ((rtn
|
|
|
|
(apply value start loc params)))
|
2002-11-08 02:38:54 +00:00
|
|
|
(if rtn (push rtn todo))))
|
1997-08-30 23:25:29 +00:00
|
|
|
(t
|
|
|
|
;; Normal property/value pair
|
|
|
|
(setq todo
|
|
|
|
(cons (list start loc prop value)
|
|
|
|
todo))))
|
|
|
|
(setq extents (cdr extents)
|
|
|
|
start (car (car extents))
|
|
|
|
loc (cdr (car extents))))))))
|
|
|
|
(setq alist (cdr alist))))
|
|
|
|
(setq aalist (cdr aalist)))
|
|
|
|
(if (not matched)
|
1995-03-17 18:14:30 +00:00
|
|
|
;; Didn't find any match for the annotation:
|
|
|
|
;; Store as value of text-property `unknown'.
|
1997-08-30 23:25:29 +00:00
|
|
|
(let ((extents top-extents)
|
|
|
|
(start (car (car top-extents)))
|
1997-10-16 23:31:55 +00:00
|
|
|
(loc (or (cdr (car top-extents)) loc)))
|
1997-08-30 23:25:29 +00:00
|
|
|
(while extents
|
|
|
|
(setq open-ans (cdr open-ans)
|
|
|
|
todo (cons (list start loc 'unknown top-name)
|
|
|
|
todo)
|
|
|
|
unknown-ans (cons name unknown-ans)
|
|
|
|
extents (cdr extents)
|
|
|
|
start (car (car extents))
|
|
|
|
loc (cdr (car extents))))))))))))
|
1995-03-17 18:14:30 +00:00
|
|
|
|
|
|
|
;; Once entire file has been scanned, add the properties.
|
|
|
|
(while todo
|
|
|
|
(let* ((item (car todo))
|
|
|
|
(from (nth 0 item))
|
|
|
|
(to (nth 1 item))
|
|
|
|
(prop (nth 2 item))
|
|
|
|
(val (nth 3 item)))
|
1997-08-30 23:25:29 +00:00
|
|
|
|
|
|
|
(if (numberp val) ; add to ambient value if numeric
|
|
|
|
(format-property-increment-region from to prop val 0)
|
2021-03-20 08:48:07 +00:00
|
|
|
;; Kludge alert: ignore items with reversed order of
|
|
|
|
;; FROM and TO. They seem to be redundant anyway, and
|
|
|
|
;; in one case I've seen them refer to EOB.
|
|
|
|
(when (<= from to)
|
|
|
|
(put-text-property
|
|
|
|
from to prop
|
|
|
|
(cond ((get prop 'format-list-valued) ; value gets consed onto
|
|
|
|
; list-valued properties
|
|
|
|
(let ((prev (get-text-property from prop)))
|
|
|
|
(cons val (if (listp prev) prev (list prev)))))
|
|
|
|
(t val)))))) ; normally, just set to val.
|
1995-03-17 18:14:30 +00:00
|
|
|
(setq todo (cdr todo)))
|
1997-08-30 23:25:29 +00:00
|
|
|
|
1995-03-17 18:14:30 +00:00
|
|
|
(if unknown-ans
|
|
|
|
(message "Unknown annotations: %s" unknown-ans))))))
|
|
|
|
|
1997-08-30 23:25:29 +00:00
|
|
|
(defun format-subtract-regions (minu subtra)
|
2004-06-07 20:48:10 +00:00
|
|
|
"Remove from the regions in MINUEND the regions in SUBTRAHEND.
|
2002-01-05 09:06:53 +00:00
|
|
|
A region is a dotted pair (FROM . TO). Both parameters are lists of
|
1999-01-23 21:52:40 +00:00
|
|
|
regions. Each list must contain nonoverlapping, noncontiguous
|
|
|
|
regions, in descending order. The result is also nonoverlapping,
|
|
|
|
noncontiguous, and in descending order. The first element of MINUEND
|
|
|
|
can have a cdr of nil, indicating that the end of that region is not
|
2004-06-07 20:48:10 +00:00
|
|
|
yet known.
|
|
|
|
|
|
|
|
\(fn MINUEND SUBTRAHEND)"
|
1997-08-30 23:25:29 +00:00
|
|
|
(let* ((minuend (copy-alist minu))
|
|
|
|
(subtrahend (copy-alist subtra))
|
|
|
|
(m (car minuend))
|
|
|
|
(s (car subtrahend))
|
|
|
|
results)
|
|
|
|
(while (and minuend subtrahend)
|
1999-01-23 21:52:40 +00:00
|
|
|
(cond
|
1997-08-30 23:25:29 +00:00
|
|
|
;; The minuend starts after the subtrahend ends; keep it.
|
|
|
|
((> (car m) (cdr s))
|
2002-11-08 02:38:54 +00:00
|
|
|
(push m results)
|
|
|
|
(setq minuend (cdr minuend)
|
1997-08-30 23:25:29 +00:00
|
|
|
m (car minuend)))
|
|
|
|
;; The minuend extends beyond the end of the subtrahend. Chop it off.
|
|
|
|
((or (null (cdr m)) (> (cdr m) (cdr s)))
|
2002-11-08 02:38:54 +00:00
|
|
|
(push (cons (1+ (cdr s)) (cdr m)) results)
|
1997-08-30 23:25:29 +00:00
|
|
|
(setcdr m (cdr s)))
|
|
|
|
;; The subtrahend starts after the minuend ends; throw it away.
|
|
|
|
((< (cdr m) (car s))
|
|
|
|
(setq subtrahend (cdr subtrahend) s (car subtrahend)))
|
|
|
|
;; The subtrahend extends beyond the end of the minuend. Chop it off.
|
|
|
|
(t ;(<= (cdr m) (cdr s)))
|
|
|
|
(if (>= (car m) (car s))
|
|
|
|
(setq minuend (cdr minuend) m (car minuend))
|
|
|
|
(setcdr m (1- (car s)))
|
|
|
|
(setq subtrahend (cdr subtrahend) s (car subtrahend))))))
|
|
|
|
(nconc (nreverse results) minuend)))
|
|
|
|
|
|
|
|
;; This should probably go somewhere other than format.el. Then again,
|
|
|
|
;; indent.el has alter-text-property. NOTE: We can also use
|
|
|
|
;; next-single-property-change instead of text-property-not-all, but then
|
|
|
|
;; we have to see if we passed TO.
|
|
|
|
(defun format-property-increment-region (from to prop delta default)
|
2006-08-02 22:51:44 +00:00
|
|
|
"In the region from FROM to TO increment property PROP by amount DELTA.
|
1999-01-23 21:52:40 +00:00
|
|
|
DELTA may be negative. If property PROP is nil anywhere
|
1997-08-30 23:25:29 +00:00
|
|
|
in the region, it is treated as though it were DEFAULT."
|
|
|
|
(let ((cur from) val newval next)
|
|
|
|
(while cur
|
|
|
|
(setq val (get-text-property cur prop)
|
|
|
|
newval (+ (or val default) delta)
|
|
|
|
next (text-property-not-all cur to prop val))
|
|
|
|
(put-text-property cur (or next to) prop newval)
|
|
|
|
(setq cur next))))
|
|
|
|
|
1995-03-17 18:14:30 +00:00
|
|
|
;;;
|
|
|
|
;;; Encoding
|
|
|
|
;;;
|
|
|
|
|
|
|
|
(defun format-insert-annotations (list &optional offset)
|
|
|
|
"Apply list of annotations to buffer as `write-region' would.
|
2006-08-02 22:51:44 +00:00
|
|
|
Insert each element of the given LIST of buffer annotations at its
|
1995-03-17 18:14:30 +00:00
|
|
|
appropriate place. Use second arg OFFSET if the annotations' locations are
|
|
|
|
not relative to the beginning of the buffer: annotations will be inserted
|
2015-09-17 19:28:45 +00:00
|
|
|
at their location-OFFSET+1 \(i.e., the offset is treated as the position of
|
2004-06-07 20:48:10 +00:00
|
|
|
the first character in the buffer)."
|
1999-01-23 21:52:40 +00:00
|
|
|
(if (not offset)
|
1995-03-17 18:14:30 +00:00
|
|
|
(setq offset 0)
|
|
|
|
(setq offset (1- offset)))
|
|
|
|
(let ((l (reverse list)))
|
|
|
|
(while l
|
|
|
|
(goto-char (- (car (car l)) offset))
|
|
|
|
(insert (cdr (car l)))
|
|
|
|
(setq l (cdr l)))))
|
|
|
|
|
|
|
|
(defun format-annotate-value (old new)
|
2015-09-17 23:08:20 +00:00
|
|
|
"Return OLD and NEW as a (CLOSE . OPEN) annotation pair.
|
1995-03-17 18:14:30 +00:00
|
|
|
Useful as a default function for TRANSLATIONS alist when the value of the text
|
|
|
|
property is the name of the annotation that you want to use, as it is for the
|
|
|
|
`unknown' text property."
|
|
|
|
(cons (if old (list old))
|
|
|
|
(if new (list new))))
|
|
|
|
|
1999-01-23 21:52:40 +00:00
|
|
|
(defun format-annotate-region (from to translations format-fn ignore)
|
1995-03-17 18:14:30 +00:00
|
|
|
"Generate annotations for text properties in the region.
|
2006-08-02 22:51:44 +00:00
|
|
|
Search for changes between FROM and TO, and describe them with a list of
|
1995-03-17 18:14:30 +00:00
|
|
|
annotations as defined by alist TRANSLATIONS and FORMAT-FN. IGNORE lists text
|
|
|
|
properties not to consider; any text properties that are neither ignored nor
|
|
|
|
listed in TRANSLATIONS are warned about.
|
|
|
|
If you actually want to modify the region, give the return value of this
|
|
|
|
function to `format-insert-annotations'.
|
|
|
|
|
|
|
|
Format of the TRANSLATIONS argument:
|
|
|
|
|
|
|
|
Each element is a list whose car is a PROPERTY, and the following
|
2002-01-05 09:06:53 +00:00
|
|
|
elements have the form (VALUE ANNOTATIONS...).
|
|
|
|
Whenever the property takes on the value VALUE, the annotations
|
1995-03-17 18:14:30 +00:00
|
|
|
\(as formatted by FORMAT-FN) are inserted into the file.
|
|
|
|
When the property stops having that value, the matching negated annotation
|
|
|
|
will be inserted \(it may actually be closed earlier and reopened, if
|
1999-01-23 21:52:40 +00:00
|
|
|
necessary, to keep proper nesting).
|
1995-03-17 18:14:30 +00:00
|
|
|
|
2002-01-05 09:06:53 +00:00
|
|
|
If VALUE is a list, then each element of the list is dealt with
|
1995-03-17 18:14:30 +00:00
|
|
|
separately.
|
|
|
|
|
|
|
|
If a VALUE is numeric, then it is assumed that there is a single annotation
|
|
|
|
and each occurrence of it increments the value of the property by that number.
|
|
|
|
Thus, given the entry \(left-margin \(4 \"indent\")), if the left margin
|
|
|
|
changes from 4 to 12, two <indent> annotations will be generated.
|
|
|
|
|
|
|
|
If the VALUE is nil, then instead of annotations, a function should be
|
|
|
|
specified. This function is used as a default: it is called for all
|
|
|
|
transitions not explicitly listed in the table. The function is called with
|
|
|
|
two arguments, the OLD and NEW values of the property. It should return
|
2002-01-05 09:06:53 +00:00
|
|
|
a cons cell (CLOSE . OPEN) as `format-annotate-single-property-change' does.
|
1995-03-17 18:14:30 +00:00
|
|
|
|
2002-01-05 09:06:53 +00:00
|
|
|
The same TRANSLATIONS structure can be used in reverse for reading files."
|
1995-03-17 18:14:30 +00:00
|
|
|
(let ((all-ans nil) ; All annotations - becomes return value
|
|
|
|
(open-ans nil) ; Annotations not yet closed
|
|
|
|
(loc nil) ; Current location
|
|
|
|
(not-found nil)) ; Properties that couldn't be saved
|
|
|
|
(while (or (null loc)
|
|
|
|
(and (setq loc (next-property-change loc nil to))
|
|
|
|
(< loc to)))
|
|
|
|
(or loc (setq loc from))
|
1999-01-23 21:52:40 +00:00
|
|
|
(let* ((ans (format-annotate-location loc (= loc from) ignore translations))
|
1995-03-17 18:14:30 +00:00
|
|
|
(neg-ans (format-reorder (aref ans 0) open-ans))
|
|
|
|
(pos-ans (aref ans 1))
|
|
|
|
(ignored (aref ans 2)))
|
|
|
|
(setq not-found (append ignored not-found)
|
|
|
|
ignore (append ignored ignore))
|
|
|
|
;; First do the negative (closing) annotations
|
|
|
|
(while neg-ans
|
|
|
|
;; Check if it's missing. This can happen (eg, a numeric property
|
|
|
|
;; going negative can generate closing annotations before there are
|
|
|
|
;; any open). Warn user & ignore.
|
|
|
|
(if (not (member (car neg-ans) open-ans))
|
|
|
|
(message "Can't close %s: not open." (car neg-ans))
|
|
|
|
(while (not (equal (car neg-ans) (car open-ans)))
|
|
|
|
;; To close anno. N, need to first close ans 1 to N-1,
|
|
|
|
;; remembering to re-open them later.
|
2002-11-08 02:38:54 +00:00
|
|
|
(push (car open-ans) pos-ans)
|
1999-01-23 21:52:40 +00:00
|
|
|
(setq all-ans
|
1995-03-17 18:14:30 +00:00
|
|
|
(cons (cons loc (funcall format-fn (car open-ans) nil))
|
|
|
|
all-ans))
|
|
|
|
(setq open-ans (cdr open-ans)))
|
|
|
|
;; Now remove the one we're really interested in from open list.
|
|
|
|
(setq open-ans (cdr open-ans))
|
|
|
|
;; And put the closing annotation here.
|
2002-11-08 02:38:54 +00:00
|
|
|
(push (cons loc (funcall format-fn (car neg-ans) nil))
|
|
|
|
all-ans))
|
1995-03-17 18:14:30 +00:00
|
|
|
(setq neg-ans (cdr neg-ans)))
|
|
|
|
;; Now deal with positive (opening) annotations
|
2011-04-19 13:44:55 +00:00
|
|
|
(while pos-ans
|
|
|
|
(push (car pos-ans) open-ans)
|
|
|
|
(push (cons loc (funcall format-fn (car pos-ans) t))
|
|
|
|
all-ans)
|
|
|
|
(setq pos-ans (cdr pos-ans)))))
|
1995-03-17 18:14:30 +00:00
|
|
|
|
|
|
|
;; Close any annotations still open
|
|
|
|
(while open-ans
|
1999-01-23 21:52:40 +00:00
|
|
|
(setq all-ans
|
1995-03-17 18:14:30 +00:00
|
|
|
(cons (cons to (funcall format-fn (car open-ans) nil))
|
|
|
|
all-ans))
|
|
|
|
(setq open-ans (cdr open-ans)))
|
|
|
|
(if not-found
|
|
|
|
(message "These text properties could not be saved:\n %s"
|
|
|
|
not-found))
|
|
|
|
(nreverse all-ans)))
|
|
|
|
|
|
|
|
;;; Internal functions for format-annotate-region.
|
|
|
|
|
1999-01-23 21:52:40 +00:00
|
|
|
(defun format-annotate-location (loc all ignore translations)
|
|
|
|
"Return annotation(s) needed at location LOC.
|
2004-06-07 20:48:10 +00:00
|
|
|
This includes any properties that change between LOC - 1 and LOC.
|
1995-03-17 18:14:30 +00:00
|
|
|
If ALL is true, don't look at previous location, but generate annotations for
|
|
|
|
all non-nil properties.
|
|
|
|
Third argument IGNORE is a list of text-properties not to consider.
|
2002-01-05 09:06:53 +00:00
|
|
|
Use the TRANSLATIONS alist (see `format-annotate-region' for doc).
|
1995-03-17 18:14:30 +00:00
|
|
|
|
|
|
|
Return value is a vector of 3 elements:
|
2002-01-05 09:06:53 +00:00
|
|
|
1. List of annotations to close
|
|
|
|
2. List of annotations to open.
|
|
|
|
3. List of properties that were ignored or couldn't be annotated.
|
|
|
|
|
|
|
|
The annotations in lists 1 and 2 need not be strings.
|
|
|
|
They can be whatever the FORMAT-FN in `format-annotate-region'
|
|
|
|
can handle. If that is `enriched-make-annotation', they can be
|
|
|
|
either strings, or lists of the form (PARAMETER VALUE)."
|
1995-03-17 18:14:30 +00:00
|
|
|
(let* ((prev-loc (1- loc))
|
|
|
|
(before-plist (if all nil (text-properties-at prev-loc)))
|
|
|
|
(after-plist (text-properties-at loc))
|
|
|
|
p negatives positives prop props not-found)
|
|
|
|
;; make list of all property names involved
|
|
|
|
(setq p before-plist)
|
|
|
|
(while p
|
|
|
|
(if (not (memq (car p) props))
|
2002-11-08 02:38:54 +00:00
|
|
|
(push (car p) props))
|
1995-03-17 18:14:30 +00:00
|
|
|
(setq p (cdr (cdr p))))
|
|
|
|
(setq p after-plist)
|
|
|
|
(while p
|
|
|
|
(if (not (memq (car p) props))
|
2002-11-08 02:38:54 +00:00
|
|
|
(push (car p) props))
|
1995-03-17 18:14:30 +00:00
|
|
|
(setq p (cdr (cdr p))))
|
|
|
|
|
|
|
|
(while props
|
2002-11-08 02:38:54 +00:00
|
|
|
(setq prop (pop props))
|
1995-03-17 18:14:30 +00:00
|
|
|
(if (memq prop ignore)
|
|
|
|
nil ; If it's been ignored before, ignore it now.
|
|
|
|
(let ((before (if all nil (car (cdr (memq prop before-plist)))))
|
|
|
|
(after (car (cdr (memq prop after-plist)))))
|
|
|
|
(if (equal before after)
|
|
|
|
nil ; no change; ignore
|
|
|
|
(let ((result (format-annotate-single-property-change
|
1999-01-23 21:52:40 +00:00
|
|
|
prop before after translations)))
|
1995-03-17 18:14:30 +00:00
|
|
|
(if (not result)
|
2002-11-08 02:38:54 +00:00
|
|
|
(push prop not-found)
|
1995-03-17 18:14:30 +00:00
|
|
|
(setq negatives (nconc negatives (car result))
|
|
|
|
positives (nconc positives (cdr result)))))))))
|
|
|
|
(vector negatives positives not-found)))
|
|
|
|
|
2002-01-05 09:06:53 +00:00
|
|
|
(defun format-annotate-single-property-change (prop old new translations)
|
1999-01-23 21:52:40 +00:00
|
|
|
"Return annotations for property PROP changing from OLD to NEW.
|
2002-01-05 09:06:53 +00:00
|
|
|
These are searched for in the translations alist TRANSLATIONS
|
|
|
|
(see `format-annotate-region' for the format).
|
2006-08-02 22:51:44 +00:00
|
|
|
If NEW does not appear in the list, but there is a default function,
|
|
|
|
then call that function.
|
|
|
|
Return a cons of the form (CLOSE . OPEN)
|
2002-01-05 09:06:53 +00:00
|
|
|
where CLOSE is a list of annotations to close
|
|
|
|
and OPEN is a list of annotations to open.
|
|
|
|
|
|
|
|
The annotations in CLOSE and OPEN need not be strings.
|
|
|
|
They can be whatever the FORMAT-FN in `format-annotate-region'
|
|
|
|
can handle. If that is `enriched-make-annotation', they can be
|
|
|
|
either strings, or lists of the form (PARAMETER VALUE)."
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
(let ((prop-alist (cdr (assoc prop translations))))
|
1995-03-17 18:14:30 +00:00
|
|
|
(if (not prop-alist)
|
|
|
|
nil
|
|
|
|
;; If either old or new is a list, have to treat both that way.
|
2000-02-21 13:00:25 +00:00
|
|
|
(if (and (or (listp old) (listp new))
|
1999-07-21 21:43:03 +00:00
|
|
|
(not (get prop 'format-list-atomic-p)))
|
2018-07-10 01:46:33 +00:00
|
|
|
(if (not (and (proper-list-p old)
|
|
|
|
(proper-list-p new)))
|
2000-02-21 13:00:25 +00:00
|
|
|
(format-annotate-atomic-property-change prop-alist old new)
|
2018-07-10 01:59:58 +00:00
|
|
|
(let (close open)
|
2000-02-21 13:00:25 +00:00
|
|
|
(while old
|
|
|
|
(setq close
|
|
|
|
(append (car (format-annotate-atomic-property-change
|
|
|
|
prop-alist (car old) nil))
|
|
|
|
close)
|
|
|
|
old (cdr old)))
|
2021-08-11 20:29:38 +00:00
|
|
|
;; If the font is on the format (:background "red"),
|
|
|
|
;; then we have a single face. We're assuming a list of
|
|
|
|
;; faces, so transform.
|
|
|
|
(when (and (listp new)
|
|
|
|
(keywordp (car new)))
|
|
|
|
(setq new (list new)))
|
2000-02-21 13:00:25 +00:00
|
|
|
(while new
|
|
|
|
(setq open
|
|
|
|
(append (cdr (format-annotate-atomic-property-change
|
|
|
|
prop-alist nil (car new)))
|
|
|
|
open)
|
|
|
|
new (cdr new)))
|
|
|
|
(format-make-relatively-unique close open)))
|
1995-03-17 18:14:30 +00:00
|
|
|
(format-annotate-atomic-property-change prop-alist old new)))))
|
|
|
|
|
|
|
|
(defun format-annotate-atomic-property-change (prop-alist old new)
|
2006-08-02 22:51:44 +00:00
|
|
|
"Internal function to annotate a single property change.
|
2002-01-05 09:06:53 +00:00
|
|
|
PROP-ALIST is the relevant element of a TRANSLATIONS list.
|
1995-03-17 18:14:30 +00:00
|
|
|
OLD and NEW are the values."
|
1997-08-05 04:44:55 +00:00
|
|
|
(let (num-ann)
|
|
|
|
;; If old and new values are numbers,
|
|
|
|
;; look for a number in PROP-ALIST.
|
1997-08-09 02:38:14 +00:00
|
|
|
(if (and (or (null old) (numberp old))
|
|
|
|
(or (null new) (numberp new)))
|
1997-08-05 04:44:55 +00:00
|
|
|
(progn
|
|
|
|
(setq num-ann prop-alist)
|
|
|
|
(while (and num-ann (not (numberp (car (car num-ann)))))
|
|
|
|
(setq num-ann (cdr num-ann)))))
|
|
|
|
(if num-ann
|
1997-08-09 02:38:14 +00:00
|
|
|
;; Numerical annotation - use difference
|
1997-08-15 19:30:25 +00:00
|
|
|
(progn
|
|
|
|
;; If property is numeric, nil means 0
|
|
|
|
(cond ((and (numberp old) (null new))
|
|
|
|
(setq new 0))
|
|
|
|
((and (numberp new) (null old))
|
|
|
|
(setq old 0)))
|
|
|
|
|
|
|
|
(let* ((entry (car num-ann))
|
|
|
|
(increment (car entry))
|
|
|
|
(n (ceiling (/ (float (- new old)) (float increment))))
|
|
|
|
(anno (car (cdr entry))))
|
|
|
|
(if (> n 0)
|
|
|
|
(cons nil (make-list n anno))
|
|
|
|
(cons (make-list (- n) anno) nil))))
|
1997-08-05 04:44:55 +00:00
|
|
|
|
|
|
|
;; Standard annotation
|
|
|
|
(let ((close (and old (cdr (assoc old prop-alist))))
|
1995-03-17 18:14:30 +00:00
|
|
|
(open (and new (cdr (assoc new prop-alist)))))
|
|
|
|
(if (or close open)
|
|
|
|
(format-make-relatively-unique close open)
|
|
|
|
;; Call "Default" function, if any
|
|
|
|
(let ((default (assq nil prop-alist)))
|
|
|
|
(if default
|
|
|
|
(funcall (car (cdr default)) old new))))))))
|
|
|
|
|
1997-06-04 19:06:35 +00:00
|
|
|
(provide 'format)
|
1999-01-23 21:52:40 +00:00
|
|
|
|
|
|
|
;;; format.el ends here
|