aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiles Bader2004-09-04 09:14:28 +0000
committerMiles Bader2004-09-04 09:14:28 +0000
commit6f7dde8273383c74cc722196c9b37c04faeb263f (patch)
tree5a4126925b754a52e74fa30de6521b3454f57a6d
parent32d61209ceb2b6c4b32e9d3ccc477014cc666c25 (diff)
parent90e118abf2dcc4aca4d7a7642247fa488554351e (diff)
downloademacs-6f7dde8273383c74cc722196c9b37c04faeb263f.tar.gz
emacs-6f7dde8273383c74cc722196c9b37c04faeb263f.zip
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-34
Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-514 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-522 Update from CVS
-rw-r--r--admin/ChangeLog11
-rw-r--r--admin/FOR-RELEASE6
-rw-r--r--etc/NEWS33
-rw-r--r--lisp/ChangeLog224
-rw-r--r--lisp/autorevert.el3
-rw-r--r--lisp/emacs-lisp/lisp-mode.el48
-rw-r--r--lisp/emacs-lisp/lisp.el6
-rw-r--r--lisp/emulation/cua-base.el91
-rw-r--r--lisp/emulation/cua-rect.el417
-rw-r--r--lisp/help-fns.el27
-rw-r--r--lisp/help.el55
-rw-r--r--lisp/indent.el4
-rw-r--r--lisp/info.el157
-rw-r--r--lisp/isearch.el179
-rw-r--r--lisp/macros.el17
-rw-r--r--lisp/progmodes/compile.el64
-rw-r--r--lisp/progmodes/etags.el20
-rw-r--r--lisp/progmodes/grep.el59
-rw-r--r--lisp/simple.el148
-rw-r--r--lisp/startup.el3
-rw-r--r--lisp/subr.el21
-rw-r--r--lisp/term/mac-win.el6
-rw-r--r--lisp/textmodes/ispell.el2
-rw-r--r--lisp/textmodes/tex-mode.el7
-rw-r--r--lisp/x-dnd.el17
-rw-r--r--lispref/ChangeLog6
-rw-r--r--lispref/abbrevs.texi53
-rw-r--r--lwlib/ChangeLog4
-rw-r--r--lwlib/lwlib.h2
-rw-r--r--man/ChangeLog90
-rw-r--r--man/ack.texi2
-rw-r--r--man/building.texi16
-rw-r--r--man/cmdargs.texi2
-rw-r--r--man/commands.texi8
-rw-r--r--man/doclicense.texi3
-rw-r--r--man/emacs.texi198
-rw-r--r--man/entering.texi8
-rw-r--r--man/faq.texi103
-rw-r--r--man/frames.texi35
-rw-r--r--man/indent.texi48
-rw-r--r--man/killing.texi22
-rw-r--r--man/kmacro.texi6
-rw-r--r--man/misc.texi13
-rw-r--r--man/programs.texi2
-rw-r--r--man/search.texi12
-rw-r--r--man/trouble.texi12
-rw-r--r--man/windows.texi42
-rw-r--r--src/ChangeLog86
-rw-r--r--src/fileio.c2
-rw-r--r--src/gtkutil.c2
-rw-r--r--src/gtkutil.h2
-rw-r--r--src/macfns.c49
-rw-r--r--src/macmenu.c71
-rw-r--r--src/macterm.c10
-rw-r--r--src/s/darwin.h17
-rw-r--r--src/w32fns.c12
-rw-r--r--src/w32menu.c198
-rw-r--r--src/xdisp.c77
-rw-r--r--src/xfns.c187
-rw-r--r--src/xmenu.c56
60 files changed, 2048 insertions, 1033 deletions
diff --git a/admin/ChangeLog b/admin/ChangeLog
index b164f414a88..dafae3c1158 100644
--- a/admin/ChangeLog
+++ b/admin/ChangeLog
@@ -1,6 +1,15 @@
12004-08-29 Kim F. Storm <storm@cua.dk>
2
3 * FOR-RELEASE (Documentation): Add man/ack.texi and AUTHORS.
4
52004-08-28 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
6
7 * FOR-RELEASE (Indications): Remove entry about GTK and geometry,
8 (now behaves as well as other ports).
9
12004-06-28 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> 102004-06-28 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
2 11
3 * FOR-RELEASE: Removed entry about GTK and monochrome displays (done). 12 * FOR-RELEASE: Remove entry about GTK and monochrome displays (done).
4 13
52002-06-26 Eli Zaretskii <eliz@is.elta.co.il> 142002-06-26 Eli Zaretskii <eliz@is.elta.co.il>
6 15
diff --git a/admin/FOR-RELEASE b/admin/FOR-RELEASE
index 2d5738a8683..fbbacaf6456 100644
--- a/admin/FOR-RELEASE
+++ b/admin/FOR-RELEASE
@@ -14,6 +14,10 @@ Tasks needed before the next release.
14 14
15** Update man/info.texi. 15** Update man/info.texi.
16 16
17** Update man/ack.texi.
18
19** Update AUTHORS.
20
17 21
18* NEW FEATURES 22* NEW FEATURES
19 23
@@ -38,8 +42,6 @@ isearch faces.
38 42
39* GTK RELATED BUGS 43* GTK RELATED BUGS
40 44
41** Make geometry specifications work correctly for GTK.
42
43** Make GTK scrollbars behave like others w.r.t. overscrolling. 45** Make GTK scrollbars behave like others w.r.t. overscrolling.
44 46
45 47
diff --git a/etc/NEWS b/etc/NEWS
index c0d5914ebc0..deecc910f41 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -173,6 +173,10 @@ types any more. Add -DUSE_LISP_UNION_TYPE if you want union types.
173 173
174* Changes in Emacs 21.4 174* Changes in Emacs 21.4
175 175
176+++
177** `apply-macro-to-region-lines' now operates on all lines that begin
178in the region, rather than on all complete lines in the region.
179
176** global-whitespace-mode is a new alias for whitespace-global-mode. 180** global-whitespace-mode is a new alias for whitespace-global-mode.
177 181
178+++ 182+++
@@ -590,6 +594,13 @@ mode toggling function instead.
590*** A numeric prefix argument of `info' selects an Info buffer 594*** A numeric prefix argument of `info' selects an Info buffer
591with the number appended to the *info* buffer name. 595with the number appended to the *info* buffer name.
592 596
597*** Regexp isearch (C-M-s and C-M-r) can search through multiple nodes.
598Failed isearch wraps to the top/final node.
599
600*** New search commands: `Info-search-case-sensitively' (bound to S),
601`Info-search-backward', and `Info-search-next' which repeats the last
602search without prompting for a new search string.
603
593*** New command `Info-history' (bound to L) displays a menu of visited nodes. 604*** New command `Info-history' (bound to L) displays a menu of visited nodes.
594 605
595*** New command `Info-toc' (bound to T) creates a node with table of contents 606*** New command `Info-toc' (bound to T) creates a node with table of contents
@@ -603,11 +614,6 @@ possible matches.
603the current Info node name into the kill ring. With a zero prefix 614the current Info node name into the kill ring. With a zero prefix
604arg, puts the node name inside the `info' function call. 615arg, puts the node name inside the `info' function call.
605 616
606*** New command `Info-search-case-sensitively' (bound to S).
607
608*** New command `Info-search-next' (unbound) repeats the last search
609without prompting for a new search string.
610
611*** New face `info-xref-visited' distinguishes visited nodes from unvisited 617*** New face `info-xref-visited' distinguishes visited nodes from unvisited
612and a new option `Info-fontify-visited-nodes' to control this. 618and a new option `Info-fontify-visited-nodes' to control this.
613 619
@@ -1184,9 +1190,9 @@ Another method to grab a character is to enter the minibuffer by `M-e'
1184and to type `C-f' at the end of the search string in the minibuffer. 1190and to type `C-f' at the end of the search string in the minibuffer.
1185 1191
1186+++ 1192+++
1187** M-% and C-M-% typed in isearch mode invoke `query-replace' and 1193** M-% typed in isearch mode invokes `query-replace' or
1188`query-replace-regexp' with the current search string inserted 1194`query-replace-regexp' (depending on search mode) with the current
1189in the minibuffer as initial input for the string to replace. 1195search string used as the string to replace.
1190 1196
1191+++ 1197+++
1192** Yanking text now discards certain text properties that can 1198** Yanking text now discards certain text properties that can
@@ -1933,7 +1939,9 @@ This option allows you to specify environment variables for inferior
1933compilation processes without affecting the environment that all 1939compilation processes without affecting the environment that all
1934subprocesses inherit. 1940subprocesses inherit.
1935 1941
1936*** `next-error' now temporarily highlights the corresponding source line. 1942*** New options `next-error-highlight' and `next-error-highlight-no-select'
1943specify the method of highlighting of the corresponding source line
1944in new face `next-error'.
1937 1945
1938** Grep has been decoupled from compilation mode setup. 1946** Grep has been decoupled from compilation mode setup.
1939 1947
@@ -1945,7 +1953,12 @@ subprocesses inherit.
1945`grep-scroll-output' can be used to override the corresponding 1953`grep-scroll-output' can be used to override the corresponding
1946compilation mode settings for grep commands. 1954compilation mode settings for grep commands.
1947 1955
1948*** Source line is temporarily highlighted when going to next match. 1956*** New option `grep-highlight-matches' highlightes matches in *grep*
1957buffer. It uses a special feature of some grep programs which accept
1958--color option to output markers around matches. When going to the next
1959match with `next-error' the exact match is highlighted in the source
1960buffer. Otherwise, if `grep-highlight-matches' is nil, the whole
1961source line is highlighted.
1949 1962
1950*** New key bindings in grep output window: 1963*** New key bindings in grep output window:
1951SPC and DEL scrolls window up and down. C-n and C-p moves to next and 1964SPC and DEL scrolls window up and down. C-n and C-p moves to next and
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 66ef44650d5..96fa1656f0a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,218 @@
12004-09-03 Luc Teirlinck <teirllm@auburn.edu>
2
3 * autorevert.el (auto-revert-handler): Bind `buffer-read-only'
4 locally around the call to `revert-buffer'.
5
62004-09-03 Juri Linkov <juri@jurta.org>
7
8 * isearch.el (isearch-toggle-regexp): Set `isearch-success' and
9 `isearch-adjusted' to `t'.
10 (isearch-toggle-case-fold): Set `isearch-success' to `t'.
11 (isearch-message-prefix): Add "pending" for isearch-adjusted.
12 (isearch-other-meta-char): Restore isearch-point unconditionally.
13 (isearch-query-replace): Add new arg `regexp-flag' and use it.
14 Set point to start of match if region is not active in transient
15 mark mode (to include the current match to region boundaries).
16 Push the search string to `query-replace-from-history-variable'.
17 Add prompt "Query replace regexp" for isearch-regexp.
18 Add region beginning/end as last arguments of `perform-replace.'
19 (isearch-query-replace-regexp): Replace code by the call to
20 `isearch-query-replace' with arg `t'.
21
222004-09-03 Richard M. Stallman <rms@gnu.org>
23
24 * startup.el (normal-top-level): Undo previous TERM change.
25
262004-09-03 Kim F. Storm <storm@cua.dk>
27
28 * emulation/cua-rect.el (cua--overlay-keymap): New keymap for
29 highlight overlays; allow using RET when cursor is over a button.
30 (cua--highlight-rectangle): Use it.
31 (cua--rectangle-set-corners): Don't move backwards at eol.
32 (cua--forward-line): Don't move into void after eob.
33
34 * emulation/cua-rect.el (cua--rectangle-set-corners): Ensure that
35 point is set (and displayed) inside rectangle.
36 (cua--rectangle-operation): Fix for highlight of empty lines.
37 (cua--highlight-rectangle): Fix highlight for tabs.
38 Position cursor at left/right edge of rectangle using new `cursor'
39 property on overlay strings.
40 (cua--indent-rectangle): Don't tabify.
41 (cua-rotate-rectangle): Ignore that point has moved.
42
432004-09-02 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
44
45 * term/mac-win.el: Add ASCII equivalents for some function keys.
46 (mode-line-frame-identification): Sync with x-win.el.
47
482004-09-02 Juri Linkov <juri@jurta.org>
49
50 * progmodes/compile.el (compilation-buffer-name): Compare major
51 mode with second element of compilation-arguments instead of third
52 to reflect latest changes in compilation-arguments structure.
53 (recompile): Use global variable `compilation-directory' to get
54 recent compilation directory only when `recompile' is invoked NOT
55 in the compilation buffer. Otherwise, use `default-directory' of
56 the compilation buffer.
57 (compilation-error-properties): Allow to funcall col and end-col.
58 (compilation-mode-font-lock-keywords): Check col and end-col by
59 `integerp'.
60 (compilation-goto-locus): If end-mk is non-nil in transient mark
61 mode don't activate the mark (and don't display message in
62 push-mark), but highlight overlay between mk and end-mk.
63
64 * progmodes/grep.el (grep-highlight-matches): New defcustom.
65 (grep-regexp-alist): Add rule to highlight grep matches.
66 (grep-process-setup): Set env-vars GREP_OPTIONS and GREP_COLOR.
67
68 * info.el (Info-fontify-node): Don't compute other-tag
69 if Info-hide-note-references=hide.
70
71 * help.el (function-called-at-point):
72 * help-fns.el (variable-at-point):
73 Try `find-tag-default' when other methods failed.
74
75 * emacs-lisp/lisp.el (beginning-of-defun, end-of-defun):
76 Do not push mark if inhibit-mark-movement is non-nil.
77
78 * textmodes/ispell.el (ispell-html-skip-alists):
79 Fix backslashes in docstring.
80
812004-09-01 Juri Linkov <juri@jurta.org>
82
83 * isearch.el (isearch-wrap-function)
84 (isearch-push-state-function): New defvars.
85 (isearch-pop-fun-state): New defsubst.
86 (isearch-top-state): Call function saved in `isearch-pop-fun-state'.
87 (isearch-push-state): Set the result of calling
88 `isearch-push-state-function' to the `isearch-pop-fun-state' field.
89 (isearch-cancel): Call function saved in `isearch-pop-fun-state' to
90 restore the mode-specific starting point of terminated search.
91 (isearch-abort): Call `isearch-cancel' instead of its duplicated code.
92 (isearch-repeat): Call `isearch-wrap-function' if defined.
93 (isearch-message-prefix): Don't add prefix "over" to the message
94 for wrapped search if `isearch-wrap-function' is defined.
95 (isearch-search): Call function saved in `isearch-pop-fun-state' to
96 restore the mode-specific starting point of failed search.
97
98 * info.el (Info-search-whitespace-regexp): Fix backslashes.
99 (Info-search): Add new optional arguments for the sake of isearch.
100 Replace whitespace in Info-search-whitespace-regexp literally.
101 Add backward search. Don't call `Info-select-node' if regexp is
102 found in the same Info node. Don't add node to Info-history for
103 wrapped isearch.
104 (Info-search-backward, Info-isearch-search, Info-isearch-wrap)
105 (Info-isearch-push-state, Info-isearch-pop-state): New funs.
106 (Info-mode): Set local variables `isearch-search-fun-function',
107 `isearch-wrap-function', `isearch-push-state-function',
108 `search-whitespace-regexp'.
109
110 * isearch.el: Remove ancient Change Log section.
111 (isearch-string, isearch-message-string, isearch-point)
112 (isearch-success, isearch-forward-flag, isearch-other-end)
113 (isearch-word, isearch-invalid-regexp, isearch-wrapped)
114 (isearch-barrier, isearch-within-brackets)
115 (isearch-case-fold-search): Add suffix `-state' to state-related
116 defsubsts to avoid name clashes with other function names.
117
118 * simple.el (next-error): New defgroup and defface.
119 (next-error-highlight, next-error-highlight-no-select):
120 New defcustoms.
121 (next-error-no-select): Let-bind next-error-highlight to the value
122 of next-error-highlight-no-select before calling `next-error'.
123
124 * progmodes/compile.el (compilation-goto-locus):
125 Use `next-error' face instead of `region'. Set 4-th argument of
126 `move-overlay' to `current-buffer' to move overlay to different
127 source buffers. Use new variable `next-error-highlight'.
128
129 * simple.el (next-error-find-buffer): Move the rule
130 "if current buffer is a next-error capable buffer" after the
131 rule "if next-error-last-buffer is set to a live buffer".
132 Simplify to test all rules in one `or'.
133 (next-error): Doc fix.
134 (next-error, previous-error, first-error)
135 (next-error-no-select, previous-error-no-select):
136 Make arguments optional.
137
1382004-08-31 Luc Teirlinck <teirllm@auburn.edu>
139
140 * macros.el (apply-macro-to-region-lines): Make it operate on all
141 lines that begin in the region, rather than on all complete lines
142 in the region.
143
1442004-08-31 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
145
146 * x-dnd.el (x-dnd-protocol-alist): Document update.
147 (x-dnd-known-types): Defcustom it.
148 (x-dnd-handle-motif): Print message-atom in error message.
149
1502004-08-30 John Paul Wallington <jpw@gnu.org>
151
152 * textmodes/tex-mode.el (tex-validate-buffer): Use distinct
153 strings rather than programatically constructing message.
154
1552004-08-30 Richard M. Stallman <rms@gnu.org>
156
157 * emacs-lisp/lisp-mode.el (prin1-char): Don't turn S-a into A.
158 Don't return a string that would read as the wrong character code.
159
1602004-08-29 Kim F. Storm <storm@cua.dk>
161
162 * emulation/cua-base.el (cua-auto-expand-rectangles): Remove
163 automatic rectangle padding feature; replace by non-destructive
164 virtual rectangle edges feature.
165 (cua-virtual-rectangle-edges): New defcustom.
166 (cua-auto-tabify-rectangles): New defcustom.
167 (cua-paste): If paste into a marked rectangle, insert rectangle at
168 current column, even if virtual; also paste exactly as many lines
169 as has been marked (ignore additional lines or add empty lines),
170 but paste whole source if only one line is marked.
171 (cua--update-indications): No longer use overwrite-cursor to
172 indicate rectangle padding
173
174 * emulation/cua-rect.el (cua--rectangle-padding): Remove.
175 (cua--rectangle-virtual-edges): New defun.
176 (cua--rectangle-get-corners): Remove optional PAD arg.
177 (cua--rectangle-set-corners): Never do padding.
178 (cua--forward-line): Remove optional PAD arg. Simplify.
179 (cua-resize-rectangle-right, cua-resize-rectangle-left)
180 (cua-resize-rectangle-down, cua-resize-rectangle-up):
181 (cua-resize-rectangle-bot, cua-resize-rectangle-top)
182 (cua-resize-rectangle-page-up, cua-resize-rectangle-page-down)
183 (cua--rectangle-move): Never do padding. Simplify.
184 (cua--tabify-start): New defun.
185 (cua--rectangle-operation): Add tabify arg. All callers changed.
186 (cua--pad-rectangle): Remove.
187 (cua--delete-rectangle): Handle delete with virtual edges.
188 (cua--extract-rectangle): Add spaces if rectangle has virtual edges.
189 (cua--insert-rectangle): Handle insert at virtual column.
190 Perform auto-tabify if necessary.
191 (cua--activate-rectangle): Remove optional FORCE arg.
192 Never do padding. Simplify.
193 (cua--highlight-rectangle): Enhance for virtual edges.
194 (cua-toggle-rectangle-padding): Remove command.
195 (cua-toggle-rectangle-virtual-edges): New command.
196 (cua-sequence-rectangle): Add optional TABIFY arg. Callers changed.
197 (cua--rectangle-post-command): Don't force rectangle padding.
198 (cua--init-rectangles): Bind M-p to cua-toggle-rectangle-virtual-edges.
199
2002004-08-28 Luc Teirlinck <teirllm@auburn.edu>
201
202 * indent.el (edit-tab-stops-buffer): Doc fix.
203
2042004-08-28 Richard M. Stallman <rms@gnu.org>
205
206 * progmodes/grep.el (grep-default-command): Use find-tag-default.
207 (grep-tag-default): Function deleted.
208
209 * subr.el (find-tag-default): Moved from etags.el.
210
211 * progmodes/etags.el (find-tag-default): Moved to subr.el.
212
213 * emacs-lisp/lisp-mode.el (prin1-char): Put `shift' modifier
214 into the basic character if it has an uppercase form.
215
12004-08-27 Kenichi Handa <handa@m17n.org> 2162004-08-27 Kenichi Handa <handa@m17n.org>
2 217
3 * international/utf-8.el (utf-8-post-read-conversion): If the 218 * international/utf-8.el (utf-8-post-read-conversion): If the
@@ -534,7 +749,6 @@
534 (ps-generate-string-list): Comment fix. 749 (ps-generate-string-list): Comment fix.
535 (ps-message-log-max): Code fix. 750 (ps-message-log-max): Code fix.
536 751
537
5382004-07-22 Michael Piotrowski <mxp@dynalabs.de> (tiny change) 7522004-07-22 Michael Piotrowski <mxp@dynalabs.de> (tiny change)
539 753
540 * ps-print.el (ps-begin-file): Improve the DSC compliance of the 754 * ps-print.el (ps-begin-file): Improve the DSC compliance of the
@@ -554,11 +768,9 @@
554 768
5552004-07-20 Richard M. Stallman <rms@gnu.org> 7692004-07-20 Richard M. Stallman <rms@gnu.org>
556 770
557 * textmodes/fill.el (fill-comment-paragraph): Handle indent-tabs-mode. 771 * textmodes/fill.el (fill-nobreak-p): If this break point is
558 (fill-delete-newlines): Call sentence-end as function. 772 at the end of the line, don't consider the newline which follows
559 (fill-nobreak-p, canonically-space-region): Likewise. 773 as a reason to return t.
560 (fill-nobreak-p): If this break point is at the end of the line,
561 don't consider the newline which follows as a reason to return t.
562 774
5632004-07-19 John Paul Wallington <jpw@gnu.org> 7752004-07-19 John Paul Wallington <jpw@gnu.org>
564 776
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index 796ebaa27c8..ecf768c5732 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -421,7 +421,8 @@ This is an internal function used by Auto-Revert Mode."
421 'no-mini t)) 421 'no-mini t))
422 (if auto-revert-tail-mode 422 (if auto-revert-tail-mode
423 (auto-revert-tail-handler) 423 (auto-revert-tail-handler)
424 (revert-buffer 'ignore-auto 'dont-ask 'preserve-modes)) 424 (let ((buffer-read-only buffer-read-only))
425 (revert-buffer 'ignore-auto 'dont-ask 'preserve-modes)))
425 (when buffer-file-name 426 (when buffer-file-name
426 (when eob (goto-char (point-max))) 427 (when eob (goto-char (point-max)))
427 (dolist (window eoblist) 428 (dolist (window eoblist)
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index df05555ae7b..e2aac327ddc 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -363,7 +363,7 @@ if that value is non-nil."
363 (when (stringp default) 363 (when (stringp default)
364 (if (string-match ":+" default) 364 (if (string-match ":+" default)
365 (substring default (match-end 0)) 365 (substring default (match-end 0))
366 default)))) 366 default))))
367 367
368;; Used in old LispM code. 368;; Used in old LispM code.
369(defalias 'common-lisp-mode 'lisp-mode) 369(defalias 'common-lisp-mode 'lisp-mode)
@@ -459,21 +459,37 @@ alternative printed representations that can be displayed."
459If CHAR is not a character, return nil." 459If CHAR is not a character, return nil."
460 (and (integerp char) 460 (and (integerp char)
461 (eventp char) 461 (eventp char)
462 (let ((c (event-basic-type char))) 462 (let ((c (event-basic-type char))
463 (concat 463 (mods (event-modifiers char))
464 "?" 464 string)
465 (mapconcat 465 ;; Prevent ?A from turning into ?\S-a.
466 (lambda (modif) 466 (if (and (memq 'shift mods)
467 (cond ((eq modif 'super) "\\s-") 467 (zerop (logand char ?\S-\^@))
468 (t (string ?\\ (upcase (aref (symbol-name modif) 0)) ?-)))) 468 (not (let ((case-fold-search nil))
469 (event-modifiers char) "") 469 (char-equal c (upcase c)))))
470 (cond 470 (setq c (upcase c) mods nil))
471 ((memq c '(?\; ?\( ?\) ?\{ ?\} ?\[ ?\] ?\" ?\' ?\\)) (string ?\\ c)) 471 ;; What string are we considering using?
472 ((eq c 127) "\\C-?") 472 (condition-case nil
473 (t 473 (setq string
474 (condition-case nil 474 (concat
475 (string c) 475 "?"
476 (error nil)))))))) 476 (mapconcat
477 (lambda (modif)
478 (cond ((eq modif 'super) "\\s-")
479 (t (string ?\\ (upcase (aref (symbol-name modif) 0)) ?-))))
480 mods "")
481 (cond
482 ((memq c '(?\; ?\( ?\) ?\{ ?\} ?\[ ?\] ?\" ?\' ?\\)) (string ?\\ c))
483 ((eq c 127) "\\C-?")
484 (t
485 (string c)))))
486 (error nil))
487 ;; Verify the string reads a CHAR, not to some other character.
488 ;; If it doesn't, return nil instead.
489 (and string
490 (= (car (read-from-string string)) char)
491 string))))
492
477 493
478(defun eval-last-sexp-1 (eval-last-sexp-arg-internal) 494(defun eval-last-sexp-1 (eval-last-sexp-arg-internal)
479 "Evaluate sexp before point; print value in minibuffer. 495 "Evaluate sexp before point; print value in minibuffer.
diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el
index 25fde86cd96..46d3d2625a1 100644
--- a/lisp/emacs-lisp/lisp.el
+++ b/lisp/emacs-lisp/lisp.el
@@ -176,7 +176,8 @@ If variable `beginning-of-defun-function' is non-nil, its value
176is called as a function to find the defun's beginning." 176is called as a function to find the defun's beginning."
177 (interactive "p") 177 (interactive "p")
178 (and (eq this-command 'beginning-of-defun) 178 (and (eq this-command 'beginning-of-defun)
179 (or (eq last-command 'beginning-of-defun) (push-mark))) 179 (or inhibit-mark-movement (eq last-command 'beginning-of-defun)
180 (push-mark)))
180 (and (beginning-of-defun-raw arg) 181 (and (beginning-of-defun-raw arg)
181 (progn (beginning-of-line) t))) 182 (progn (beginning-of-line) t)))
182 183
@@ -226,7 +227,8 @@ If variable `end-of-defun-function' is non-nil, its value
226is called as a function to find the defun's end." 227is called as a function to find the defun's end."
227 (interactive "p") 228 (interactive "p")
228 (and (eq this-command 'end-of-defun) 229 (and (eq this-command 'end-of-defun)
229 (or (eq last-command 'end-of-defun) (push-mark))) 230 (or inhibit-mark-movement (eq last-command 'end-of-defun)
231 (push-mark)))
230 (if (or (null arg) (= arg 0)) (setq arg 1)) 232 (if (or (null arg) (= arg 0)) (setq arg 1))
231 (if end-of-defun-function 233 (if end-of-defun-function
232 (if (> arg 0) 234 (if (> arg 0)
diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el
index b39945c7712..fb3c537936f 100644
--- a/lisp/emulation/cua-base.el
+++ b/lisp/emulation/cua-base.el
@@ -141,30 +141,39 @@
141;; completely separate set of "rectangle commands" [C-x r ...] on the 141;; completely separate set of "rectangle commands" [C-x r ...] on the
142;; region to copy, kill, fill a.s.o. the virtual rectangle. 142;; region to copy, kill, fill a.s.o. the virtual rectangle.
143;; 143;;
144;; cua-mode's superior rectangle support is based on using a true visual 144;; cua-mode's superior rectangle support uses a true visual
145;; representation of the selected rectangle. To start a rectangle, use 145;; representation of the selected rectangle, i.e. it highlights the
146;; [S-return] and extend it using the normal movement keys (up, down, 146;; actual part of the buffer that is currently selected as part of the
147;; left, right, home, end, C-home, C-end). Once the rectangle has the 147;; rectangle. Unlike emacs' traditional rectangle commands, the
148;; desired size, you can cut or copy it using C-x and C-c (or C-w and M-w), 148;; selected rectangle always as straight left and right edges, even
149;; and you can subsequently insert it - as a rectangle - using C-v (or 149;; when those are in the middle of a TAB character or beyond the end
150;; C-y). So the only new command you need to know to work with 150;; of the current line. And it does this without actually modifying
151;; cua-mode rectangles is S-return! 151;; the buffer contents (it uses display overlays to visualize the
152;; virtual dimensions of the rectangle).
153;;
154;; This means that cua-mode's rectangles are not limited to the actual
155;; contents of the buffer, so if the cursor is currently at the end of a
156;; short line, you can still extend the rectangle to include more columns
157;; of longer lines in the same rectangle. And you can also have the
158;; left edge of a rectangle start in the middle of a TAB character.
159;; Sounds strange? Try it!
160;;
161;; To start a rectangle, use [S-return] and extend it using the normal
162;; movement keys (up, down, left, right, home, end, C-home,
163;; C-end). Once the rectangle has the desired size, you can cut or
164;; copy it using C-x and C-c (or C-w and M-w), and you can
165;; subsequently insert it - as a rectangle - using C-v (or C-y). So
166;; the only new command you need to know to work with cua-mode
167;; rectangles is S-return!
152;; 168;;
153;; Normally, when you paste a rectangle using C-v (C-y), each line of 169;; Normally, when you paste a rectangle using C-v (C-y), each line of
154;; the rectangle is inserted into the existing lines in the buffer. 170;; the rectangle is inserted into the existing lines in the buffer.
155;; If overwrite-mode is active when you paste a rectangle, it is 171;; If overwrite-mode is active when you paste a rectangle, it is
156;; inserted as normal (multi-line) text. 172;; inserted as normal (multi-line) text.
157;; 173;;
158;; Furthermore, cua-mode's rectangles are not limited to the actual 174;; If you prefer the traditional rectangle marking (i.e. don't want
159;; contents of the buffer, so if the cursor is currently at the end of a 175;; straight edges), [M-p] toggles this for the current rectangle,
160;; short line, you can still extend the rectangle to include more columns 176;; or you can customize cua-virtual-rectangle-edges.
161;; of longer lines in the same rectangle. Sounds strange? Try it!
162;;
163;; You can enable padding for just this rectangle by pressing [M-p];
164;; this works like entering `picture-mode' where the tabs and spaces
165;; are automatically converted/inserted to make the rectangle truly
166;; rectangular. Or you can do it for all rectangles by setting the
167;; `cua-auto-expand-rectangles' variable.
168 177
169;; And there's more: If you want to extend or reduce the size of the 178;; And there's more: If you want to extend or reduce the size of the
170;; rectangle in one of the other corners of the rectangle, just use 179;; rectangle in one of the other corners of the rectangle, just use
@@ -204,8 +213,8 @@
204;; a supplied format string (prompt) 213;; a supplied format string (prompt)
205;; [M-o] opens the rectangle by moving the highlighted text to the 214;; [M-o] opens the rectangle by moving the highlighted text to the
206;; right of the rectangle and filling the rectangle with blanks. 215;; right of the rectangle and filling the rectangle with blanks.
207;; [M-p] toggles rectangle padding, i.e. insert tabs and spaces to 216;; [M-p] toggles virtual straight rectangle edges
208;; make rectangles truly rectangular 217;; [M-P] inserts tabs and spaces (padding) to make real straight edges
209;; [M-q] performs text filling on the rectangle 218;; [M-q] performs text filling on the rectangle
210;; [M-r] replaces REGEXP (prompt) by STRING (prompt) in rectangle 219;; [M-r] replaces REGEXP (prompt) by STRING (prompt) in rectangle
211;; [M-R] reverse the lines in the rectangle 220;; [M-R] reverse the lines in the rectangle
@@ -347,14 +356,27 @@ managers, so try setting this to nil, if prefix override doesn't work."
347 356
348;;; Rectangle Customization 357;;; Rectangle Customization
349 358
350(defcustom cua-auto-expand-rectangles nil 359(defcustom cua-virtual-rectangle-edges t
351 "*If non-nil, rectangles are padded with spaces to make straight edges. 360 "*If non-nil, rectangles have virtual straight edges.
352This implies modifying buffer contents by expanding tabs and inserting spaces. 361Note that although rectangles are always DISPLAYED with straight edges, the
353Consequently, this is inhibited in read-only buffers. 362buffer is NOT modified, until you execute a command that actually modifies it.
354Can be toggled by [M-p] while the rectangle is active," 363\[M-p] toggles this feature when a rectangle is active."
355 :type 'boolean 364 :type 'boolean
356 :group 'cua) 365 :group 'cua)
357 366
367(defcustom cua-auto-tabify-rectangles 1000
368 "*If non-nil, automatically tabify after rectangle commands.
369This basically means that `tabify' is applied to all lines that
370are modified by inserting or deleting a rectangle. If value is
371an integer, cua will look for existing tabs in a region around
372the rectangle, and only do the conversion if any tabs are already
373present. The number specifies then number of characters before
374and after the region marked by the rectangle to search."
375 :type '(choice (number :tag "Auto detect (limit)")
376 (const :tag "Disabled" nil)
377 (other :tag "Enabled" t))
378 :group 'cua)
379
358(defcustom cua-enable-rectangle-auto-help t 380(defcustom cua-enable-rectangle-auto-help t
359 "*If non-nil, automatically show help for region, rectangle and global mark." 381 "*If non-nil, automatically show help for region, rectangle and global mark."
360 :type 'boolean 382 :type 'boolean
@@ -412,7 +434,6 @@ Can be toggled by [M-p] while the rectangle is active,"
412 (frame-parameter nil 'cursor-color) 434 (frame-parameter nil 'cursor-color)
413 "red") 435 "red")
414 "Normal (non-overwrite) cursor color. 436 "Normal (non-overwrite) cursor color.
415Also used to indicate that rectangle padding is not in effect.
416Default is to load cursor color from initial or default frame parameters. 437Default is to load cursor color from initial or default frame parameters.
417 438
418If the value is a COLOR name, then only the `cursor-color' attribute will be 439If the value is a COLOR name, then only the `cursor-color' attribute will be
@@ -462,7 +483,6 @@ a cons (TYPE . COLOR), then both properties are affected."
462 483
463(defcustom cua-overwrite-cursor-color "yellow" 484(defcustom cua-overwrite-cursor-color "yellow"
464 "*Cursor color used when overwrite mode is set, if non-nil. 485 "*Cursor color used when overwrite mode is set, if non-nil.
465Also used to indicate that rectangle padding is in effect.
466Only used when `cua-enable-cursor-indications' is non-nil. 486Only used when `cua-enable-cursor-indications' is non-nil.
467 487
468If the value is a COLOR name, then only the `cursor-color' attribute will be 488If the value is a COLOR name, then only the `cursor-color' attribute will be
@@ -806,7 +826,8 @@ If global mark is active, copy from register or one character."
806 (interactive "P") 826 (interactive "P")
807 (setq arg (cua--prefix-arg arg)) 827 (setq arg (cua--prefix-arg arg))
808 (let ((regtxt (and cua--register (get-register cua--register))) 828 (let ((regtxt (and cua--register (get-register cua--register)))
809 (count (prefix-numeric-value arg))) 829 (count (prefix-numeric-value arg))
830 paste-column paste-lines)
810 (cond 831 (cond
811 ((and cua--register (not regtxt)) 832 ((and cua--register (not regtxt))
812 (message "Nothing in register %c" cua--register)) 833 (message "Nothing in register %c" cua--register))
@@ -825,7 +846,12 @@ If global mark is active, copy from register or one character."
825 ;; the same region that we are going to delete. 846 ;; the same region that we are going to delete.
826 ;; That would make yank a no-op. 847 ;; That would make yank a no-op.
827 (if cua--rectangle 848 (if cua--rectangle
828 (cua--delete-rectangle) 849 (progn
850 (goto-char (min (mark) (point)))
851 (setq paste-column (cua--rectangle-left))
852 (setq paste-lines (cua--delete-rectangle))
853 (if (= paste-lines 1)
854 (setq paste-lines nil))) ;; paste all
829 (if (string= (buffer-substring (point) (mark)) 855 (if (string= (buffer-substring (point) (mark))
830 (car kill-ring)) 856 (car kill-ring))
831 (current-kill 1)) 857 (current-kill 1))
@@ -843,7 +869,8 @@ If global mark is active, copy from register or one character."
843 (setq this-command 'cua--paste-rectangle) 869 (setq this-command 'cua--paste-rectangle)
844 (undo-boundary) 870 (undo-boundary)
845 (setq buffer-undo-list (cons pt buffer-undo-list))) 871 (setq buffer-undo-list (cons pt buffer-undo-list)))
846 (cua--insert-rectangle (cdr cua--last-killed-rectangle)) 872 (cua--insert-rectangle (cdr cua--last-killed-rectangle)
873 nil paste-column paste-lines)
847 (if arg (goto-char pt)))) 874 (if arg (goto-char pt))))
848 (t (yank arg))))))) 875 (t (yank arg)))))))
849 876
@@ -1033,9 +1060,7 @@ If ARG is the atom `-', scroll upward by nearly full screen."
1033 ((and buffer-read-only 1060 ((and buffer-read-only
1034 cua-read-only-cursor-color) 1061 cua-read-only-cursor-color)
1035 cua-read-only-cursor-color) 1062 cua-read-only-cursor-color)
1036 ((and cua-overwrite-cursor-color 1063 ((and cua-overwrite-cursor-color overwrite-mode)
1037 (or overwrite-mode
1038 (and cua--rectangle (cua--rectangle-padding))))
1039 cua-overwrite-cursor-color) 1064 cua-overwrite-cursor-color)
1040 (t cua-normal-cursor-color))) 1065 (t cua-normal-cursor-color)))
1041 (color (if (consp cursor) (cdr cursor) cursor)) 1066 (color (if (consp cursor) (cdr cursor) cursor))
diff --git a/lisp/emulation/cua-rect.el b/lisp/emulation/cua-rect.el
index 965fe63bced..3270b7fd62c 100644
--- a/lisp/emulation/cua-rect.el
+++ b/lisp/emulation/cua-rect.el
@@ -44,10 +44,10 @@
44(require 'rect) 44(require 'rect)
45 45
46;; If non-nil, restrict current region to this rectangle. 46;; If non-nil, restrict current region to this rectangle.
47;; Value is a vector [top bot left right corner ins pad select]. 47;; Value is a vector [top bot left right corner ins virt select].
48;; CORNER specifies currently active corner 0=t/l 1=t/r 2=b/l 3=b/r. 48;; CORNER specifies currently active corner 0=t/l 1=t/r 2=b/l 3=b/r.
49;; INS specifies whether to insert on left(nil) or right(t) side. 49;; INS specifies whether to insert on left(nil) or right(t) side.
50;; If PAD is non-nil, tabs are converted to spaces when necessary. 50;; If VIRT is non-nil, virtual straight edges are enabled.
51;; If SELECT is a regexp, only lines starting with that regexp are affected.") 51;; If SELECT is a regexp, only lines starting with that regexp are affected.")
52(defvar cua--rectangle nil) 52(defvar cua--rectangle nil)
53(make-variable-buffer-local 'cua--rectangle) 53(make-variable-buffer-local 'cua--rectangle)
@@ -65,6 +65,12 @@
65(defvar cua--rectangle-overlays nil) 65(defvar cua--rectangle-overlays nil)
66(make-variable-buffer-local 'cua--rectangle-overlays) 66(make-variable-buffer-local 'cua--rectangle-overlays)
67 67
68(defvar cua--overlay-keymap
69 (let ((map (make-sparse-keymap)))
70 (define-key map "\r" 'cua-rotate-rectangle)))
71
72(defvar cua--virtual-edges-debug nil)
73
68;; Per-buffer CUA mode undo list. 74;; Per-buffer CUA mode undo list.
69(defvar cua--undo-list nil) 75(defvar cua--undo-list nil)
70(make-variable-buffer-local 'cua--undo-list) 76(make-variable-buffer-local 'cua--undo-list)
@@ -97,7 +103,7 @@ Knows about CUA rectangle highlighting in addition to standard undo."
97(defvar cua--tidy-undo-counter 0 103(defvar cua--tidy-undo-counter 0
98 "Number of times `cua--tidy-undo-lists' have run successfully.") 104 "Number of times `cua--tidy-undo-lists' have run successfully.")
99 105
100;; Clean out danling entries from cua's undo list. 106;; Clean out dangling entries from cua's undo list.
101;; Since this list contains pointers into the standard undo list, 107;; Since this list contains pointers into the standard undo list,
102;; such references are only meningful as undo information if the 108;; such references are only meningful as undo information if the
103;; corresponding entry is still on the standard undo list. 109;; corresponding entry is still on the standard undo list.
@@ -203,11 +209,11 @@ Knows about CUA rectangle highlighting in addition to standard undo."
203 (aref cua--rectangle 5)) 209 (aref cua--rectangle 5))
204 (cua--rectangle-left)))) 210 (cua--rectangle-left))))
205 211
206(defun cua--rectangle-padding (&optional set val) 212(defun cua--rectangle-virtual-edges (&optional set val)
207 ;; Current setting of rectangle padding 213 ;; Current setting of rectangle virtual-edges
208 (if set 214 (if set
209 (aset cua--rectangle 6 val)) 215 (aset cua--rectangle 6 val))
210 (and (not buffer-read-only) 216 (and ;(not buffer-read-only)
211 (aref cua--rectangle 6))) 217 (aref cua--rectangle 6)))
212 218
213(defun cua--rectangle-restriction (&optional val bounded negated) 219(defun cua--rectangle-restriction (&optional val bounded negated)
@@ -226,7 +232,7 @@ Knows about CUA rectangle highlighting in addition to standard undo."
226 (if (< (cua--rectangle-bot) (cua--rectangle-top)) 232 (if (< (cua--rectangle-bot) (cua--rectangle-top))
227 (message "rectangle bot < top"))) 233 (message "rectangle bot < top")))
228 234
229(defun cua--rectangle-get-corners (&optional pad) 235(defun cua--rectangle-get-corners ()
230 ;; Calculate the rectangular region represented by point and mark, 236 ;; Calculate the rectangular region represented by point and mark,
231 ;; putting start in the upper left corner and end in the 237 ;; putting start in the upper left corner and end in the
232 ;; bottom right corner. 238 ;; bottom right corner.
@@ -245,12 +251,12 @@ Knows about CUA rectangle highlighting in addition to standard undo."
245 (setq r (1- r))) 251 (setq r (1- r)))
246 (setq l (prog1 r (setq r l))) 252 (setq l (prog1 r (setq r l)))
247 (goto-char top) 253 (goto-char top)
248 (move-to-column l pad) 254 (move-to-column l)
249 (setq top (point)) 255 (setq top (point))
250 (goto-char bot) 256 (goto-char bot)
251 (move-to-column r pad) 257 (move-to-column r)
252 (setq bot (point)))) 258 (setq bot (point))))
253 (vector top bot l r corner 0 pad nil))) 259 (vector top bot l r corner 0 cua-virtual-rectangle-edges nil)))
254 260
255(defun cua--rectangle-set-corners () 261(defun cua--rectangle-set-corners ()
256 ;; Set mark and point in opposite corners of current rectangle. 262 ;; Set mark and point in opposite corners of current rectangle.
@@ -269,24 +275,31 @@ Knows about CUA rectangle highlighting in addition to standard undo."
269 (setq pp (cua--rectangle-bot) pc (cua--rectangle-right) 275 (setq pp (cua--rectangle-bot) pc (cua--rectangle-right)
270 mp (cua--rectangle-top) mc (cua--rectangle-left)))) 276 mp (cua--rectangle-top) mc (cua--rectangle-left))))
271 (goto-char mp) 277 (goto-char mp)
272 (move-to-column mc (cua--rectangle-padding)) 278 (move-to-column mc)
273 (set-mark (point)) 279 (set-mark (point))
274 (goto-char pp) 280 (goto-char pp)
275 (move-to-column pc (cua--rectangle-padding)))) 281 ;; Move cursor inside rectangle, except if char at rigth edge is a tab.
282 (if (and (if (cua--rectangle-right-side)
283 (and (= (move-to-column pc) (- pc tab-width))
284 (not (eolp)))
285 (> (move-to-column pc) pc))
286 (not (bolp)))
287 (backward-char 1))
288 ))
276 289
277;;; Rectangle resizing 290;;; Rectangle resizing
278 291
279(defun cua--forward-line (n pad) 292(defun cua--forward-line (n)
280 ;; Move forward/backward one line. Returns t if movement. 293 ;; Move forward/backward one line. Returns t if movement.
281 (if (or (not pad) (< n 0)) 294 (let ((pt (point)))
282 (= (forward-line n) 0) 295 (and (= (forward-line n) 0)
283 (next-line 1) 296 ;; Deal with end of buffer
284 t)) 297 (or (not (eobp))
298 (goto-char pt)))))
285 299
286(defun cua--rectangle-resized () 300(defun cua--rectangle-resized ()
287 ;; Refresh state after resizing rectangle 301 ;; Refresh state after resizing rectangle
288 (setq cua--buffer-and-point-before-command nil) 302 (setq cua--buffer-and-point-before-command nil)
289 (cua--pad-rectangle)
290 (cua--rectangle-insert-col 0) 303 (cua--rectangle-insert-col 0)
291 (cua--rectangle-set-corners) 304 (cua--rectangle-set-corners)
292 (cua--keep-active)) 305 (cua--keep-active))
@@ -294,47 +307,35 @@ Knows about CUA rectangle highlighting in addition to standard undo."
294(defun cua-resize-rectangle-right (n) 307(defun cua-resize-rectangle-right (n)
295 "Resize rectangle to the right." 308 "Resize rectangle to the right."
296 (interactive "p") 309 (interactive "p")
297 (let ((pad (cua--rectangle-padding)) (resized (> n 0))) 310 (let ((resized (> n 0)))
298 (while (> n 0) 311 (while (> n 0)
299 (setq n (1- n)) 312 (setq n (1- n))
300 (cond 313 (cond
301 ((and (cua--rectangle-right-side) (or pad (eolp)))
302 (cua--rectangle-right (1+ (cua--rectangle-right)))
303 (move-to-column (cua--rectangle-right) pad))
304 ((cua--rectangle-right-side) 314 ((cua--rectangle-right-side)
305 (forward-char 1) 315 (cua--rectangle-right (1+ (cua--rectangle-right)))
306 (cua--rectangle-right (current-column))) 316 (move-to-column (cua--rectangle-right)))
307 ((or pad (eolp))
308 (cua--rectangle-left (1+ (cua--rectangle-left)))
309 (move-to-column (cua--rectangle-right) pad))
310 (t 317 (t
311 (forward-char 1) 318 (cua--rectangle-left (1+ (cua--rectangle-left)))
312 (cua--rectangle-left (current-column))))) 319 (move-to-column (cua--rectangle-right)))))
313 (if resized 320 (if resized
314 (cua--rectangle-resized)))) 321 (cua--rectangle-resized))))
315 322
316(defun cua-resize-rectangle-left (n) 323(defun cua-resize-rectangle-left (n)
317 "Resize rectangle to the left." 324 "Resize rectangle to the left."
318 (interactive "p") 325 (interactive "p")
319 (let ((pad (cua--rectangle-padding)) resized) 326 (let (resized)
320 (while (> n 0) 327 (while (> n 0)
321 (setq n (1- n)) 328 (setq n (1- n))
322 (if (or (= (cua--rectangle-right) 0) 329 (if (or (= (cua--rectangle-right) 0)
323 (and (not (cua--rectangle-right-side)) (= (cua--rectangle-left) 0))) 330 (and (not (cua--rectangle-right-side)) (= (cua--rectangle-left) 0)))
324 (setq n 0) 331 (setq n 0)
325 (cond 332 (cond
326 ((and (cua--rectangle-right-side) (or pad (eolp) (bolp)))
327 (cua--rectangle-right (1- (cua--rectangle-right)))
328 (move-to-column (cua--rectangle-right) pad))
329 ((cua--rectangle-right-side) 333 ((cua--rectangle-right-side)
330 (backward-char 1) 334 (cua--rectangle-right (1- (cua--rectangle-right)))
331 (cua--rectangle-right (current-column))) 335 (move-to-column (cua--rectangle-right)))
332 ((or pad (eolp) (bolp))
333 (cua--rectangle-left (1- (cua--rectangle-left)))
334 (move-to-column (cua--rectangle-right) pad))
335 (t 336 (t
336 (backward-char 1) 337 (cua--rectangle-left (1- (cua--rectangle-left)))
337 (cua--rectangle-left (current-column)))) 338 (move-to-column (cua--rectangle-right))))
338 (setq resized t))) 339 (setq resized t)))
339 (if resized 340 (if resized
340 (cua--rectangle-resized)))) 341 (cua--rectangle-resized))))
@@ -342,20 +343,20 @@ Knows about CUA rectangle highlighting in addition to standard undo."
342(defun cua-resize-rectangle-down (n) 343(defun cua-resize-rectangle-down (n)
343 "Resize rectangle downwards." 344 "Resize rectangle downwards."
344 (interactive "p") 345 (interactive "p")
345 (let ((pad (cua--rectangle-padding)) resized) 346 (let (resized)
346 (while (> n 0) 347 (while (> n 0)
347 (setq n (1- n)) 348 (setq n (1- n))
348 (cond 349 (cond
349 ((>= (cua--rectangle-corner) 2) 350 ((>= (cua--rectangle-corner) 2)
350 (goto-char (cua--rectangle-bot)) 351 (goto-char (cua--rectangle-bot))
351 (when (cua--forward-line 1 pad) 352 (when (cua--forward-line 1)
352 (move-to-column (cua--rectangle-column) pad) 353 (move-to-column (cua--rectangle-column))
353 (cua--rectangle-bot t) 354 (cua--rectangle-bot t)
354 (setq resized t))) 355 (setq resized t)))
355 (t 356 (t
356 (goto-char (cua--rectangle-top)) 357 (goto-char (cua--rectangle-top))
357 (when (cua--forward-line 1 pad) 358 (when (cua--forward-line 1)
358 (move-to-column (cua--rectangle-column) pad) 359 (move-to-column (cua--rectangle-column))
359 (cua--rectangle-top t) 360 (cua--rectangle-top t)
360 (setq resized t))))) 361 (setq resized t)))))
361 (if resized 362 (if resized
@@ -364,20 +365,20 @@ Knows about CUA rectangle highlighting in addition to standard undo."
364(defun cua-resize-rectangle-up (n) 365(defun cua-resize-rectangle-up (n)
365 "Resize rectangle upwards." 366 "Resize rectangle upwards."
366 (interactive "p") 367 (interactive "p")
367 (let ((pad (cua--rectangle-padding)) resized) 368 (let (resized)
368 (while (> n 0) 369 (while (> n 0)
369 (setq n (1- n)) 370 (setq n (1- n))
370 (cond 371 (cond
371 ((>= (cua--rectangle-corner) 2) 372 ((>= (cua--rectangle-corner) 2)
372 (goto-char (cua--rectangle-bot)) 373 (goto-char (cua--rectangle-bot))
373 (when (cua--forward-line -1 pad) 374 (when (cua--forward-line -1)
374 (move-to-column (cua--rectangle-column) pad) 375 (move-to-column (cua--rectangle-column))
375 (cua--rectangle-bot t) 376 (cua--rectangle-bot t)
376 (setq resized t))) 377 (setq resized t)))
377 (t 378 (t
378 (goto-char (cua--rectangle-top)) 379 (goto-char (cua--rectangle-top))
379 (when (cua--forward-line -1 pad) 380 (when (cua--forward-line -1)
380 (move-to-column (cua--rectangle-column) pad) 381 (move-to-column (cua--rectangle-column))
381 (cua--rectangle-top t) 382 (cua--rectangle-top t)
382 (setq resized t))))) 383 (setq resized t)))))
383 (if resized 384 (if resized
@@ -408,7 +409,7 @@ Knows about CUA rectangle highlighting in addition to standard undo."
408 "Resize rectangle to bottom of buffer." 409 "Resize rectangle to bottom of buffer."
409 (interactive) 410 (interactive)
410 (goto-char (point-max)) 411 (goto-char (point-max))
411 (move-to-column (cua--rectangle-column) (cua--rectangle-padding)) 412 (move-to-column (cua--rectangle-column))
412 (cua--rectangle-bot t) 413 (cua--rectangle-bot t)
413 (cua--rectangle-resized)) 414 (cua--rectangle-resized))
414 415
@@ -416,31 +417,29 @@ Knows about CUA rectangle highlighting in addition to standard undo."
416 "Resize rectangle to top of buffer." 417 "Resize rectangle to top of buffer."
417 (interactive) 418 (interactive)
418 (goto-char (point-min)) 419 (goto-char (point-min))
419 (move-to-column (cua--rectangle-column) (cua--rectangle-padding)) 420 (move-to-column (cua--rectangle-column))
420 (cua--rectangle-top t) 421 (cua--rectangle-top t)
421 (cua--rectangle-resized)) 422 (cua--rectangle-resized))
422 423
423(defun cua-resize-rectangle-page-up () 424(defun cua-resize-rectangle-page-up ()
424 "Resize rectangle upwards by one scroll page." 425 "Resize rectangle upwards by one scroll page."
425 (interactive) 426 (interactive)
426 (let ((pad (cua--rectangle-padding))) 427 (scroll-down)
427 (scroll-down) 428 (move-to-column (cua--rectangle-column))
428 (move-to-column (cua--rectangle-column) pad) 429 (if (>= (cua--rectangle-corner) 2)
429 (if (>= (cua--rectangle-corner) 2) 430 (cua--rectangle-bot t)
430 (cua--rectangle-bot t) 431 (cua--rectangle-top t))
431 (cua--rectangle-top t)) 432 (cua--rectangle-resized))
432 (cua--rectangle-resized)))
433 433
434(defun cua-resize-rectangle-page-down () 434(defun cua-resize-rectangle-page-down ()
435 "Resize rectangle downwards by one scroll page." 435 "Resize rectangle downwards by one scroll page."
436 (interactive) 436 (interactive)
437 (let ((pad (cua--rectangle-padding))) 437 (scroll-up)
438 (scroll-up) 438 (move-to-column (cua--rectangle-column))
439 (move-to-column (cua--rectangle-column) pad) 439 (if (>= (cua--rectangle-corner) 2)
440 (if (>= (cua--rectangle-corner) 2) 440 (cua--rectangle-bot t)
441 (cua--rectangle-bot t) 441 (cua--rectangle-top t))
442 (cua--rectangle-top t)) 442 (cua--rectangle-resized))
443 (cua--rectangle-resized)))
444 443
445;;; Mouse support 444;;; Mouse support
446 445
@@ -450,7 +449,8 @@ Knows about CUA rectangle highlighting in addition to standard undo."
450 "Set rectangle corner at mouse click position." 449 "Set rectangle corner at mouse click position."
451 (interactive "e") 450 (interactive "e")
452 (mouse-set-point event) 451 (mouse-set-point event)
453 (if (cua--rectangle-padding) 452 ;; FIX ME -- need to calculate virtual column.
453 (if (cua--rectangle-virtual-edges)
454 (move-to-column (car (posn-col-row (event-end event))) t)) 454 (move-to-column (car (posn-col-row (event-end event))) t))
455 (if (cua--rectangle-right-side) 455 (if (cua--rectangle-right-side)
456 (cua--rectangle-right (current-column)) 456 (cua--rectangle-right (current-column))
@@ -470,6 +470,7 @@ Knows about CUA rectangle highlighting in addition to standard undo."
470 (cua--deactivate t)) 470 (cua--deactivate t))
471 (setq cua--last-rectangle nil) 471 (setq cua--last-rectangle nil)
472 (mouse-set-point event) 472 (mouse-set-point event)
473 ;; FIX ME -- need to calculate virtual column.
473 (cua-set-rectangle-mark) 474 (cua-set-rectangle-mark)
474 (setq cua--buffer-and-point-before-command nil) 475 (setq cua--buffer-and-point-before-command nil)
475 (setq cua--mouse-last-pos nil)) 476 (setq cua--mouse-last-pos nil))
@@ -489,13 +490,13 @@ If command is repeated at same position, delete the rectangle."
489 (let ((cua-keep-region-after-copy t)) 490 (let ((cua-keep-region-after-copy t))
490 (cua-copy-rectangle arg) 491 (cua-copy-rectangle arg)
491 (setq cua--mouse-last-pos (cons (point) cua--last-killed-rectangle))))) 492 (setq cua--mouse-last-pos (cons (point) cua--last-killed-rectangle)))))
493
492(defun cua--mouse-ignore (event) 494(defun cua--mouse-ignore (event)
493 (interactive "e") 495 (interactive "e")
494 (setq this-command last-command)) 496 (setq this-command last-command))
495 497
496(defun cua--rectangle-move (dir) 498(defun cua--rectangle-move (dir)
497 (let ((pad (cua--rectangle-padding)) 499 (let ((moved t)
498 (moved t)
499 (top (cua--rectangle-top)) 500 (top (cua--rectangle-top))
500 (bot (cua--rectangle-bot)) 501 (bot (cua--rectangle-bot))
501 (l (cua--rectangle-left)) 502 (l (cua--rectangle-left))
@@ -503,17 +504,17 @@ If command is repeated at same position, delete the rectangle."
503 (cond 504 (cond
504 ((eq dir 'up) 505 ((eq dir 'up)
505 (goto-char top) 506 (goto-char top)
506 (when (cua--forward-line -1 pad) 507 (when (cua--forward-line -1)
507 (cua--rectangle-top t) 508 (cua--rectangle-top t)
508 (goto-char bot) 509 (goto-char bot)
509 (forward-line -1) 510 (forward-line -1)
510 (cua--rectangle-bot t))) 511 (cua--rectangle-bot t)))
511 ((eq dir 'down) 512 ((eq dir 'down)
512 (goto-char bot) 513 (goto-char bot)
513 (when (cua--forward-line 1 pad) 514 (when (cua--forward-line 1)
514 (cua--rectangle-bot t) 515 (cua--rectangle-bot t)
515 (goto-char top) 516 (goto-char top)
516 (cua--forward-line 1 pad) 517 (cua--forward-line 1)
517 (cua--rectangle-top t))) 518 (cua--rectangle-top t)))
518 ((eq dir 'left) 519 ((eq dir 'left)
519 (when (> l 0) 520 (when (> l 0)
@@ -526,19 +527,37 @@ If command is repeated at same position, delete the rectangle."
526 (setq moved nil))) 527 (setq moved nil)))
527 (when moved 528 (when moved
528 (setq cua--buffer-and-point-before-command nil) 529 (setq cua--buffer-and-point-before-command nil)
529 (cua--pad-rectangle)
530 (cua--rectangle-set-corners) 530 (cua--rectangle-set-corners)
531 (cua--keep-active)))) 531 (cua--keep-active))))
532 532
533 533
534;;; Operations on current rectangle 534;;; Operations on current rectangle
535 535
536(defun cua--rectangle-operation (keep-clear visible undo pad &optional fct post-fct) 536(defun cua--tabify-start (start end)
537 ;; Return position where auto-tabify should start (or nil if not required).
538 (save-excursion
539 (save-restriction
540 (widen)
541 (and (not buffer-read-only)
542 cua-auto-tabify-rectangles
543 (if (or (not (integerp cua-auto-tabify-rectangles))
544 (= (point-min) (point-max))
545 (progn
546 (goto-char (max (point-min)
547 (- start cua-auto-tabify-rectangles)))
548 (search-forward "\t" (min (point-max)
549 (+ end cua-auto-tabify-rectangles)) t)))
550 start)))))
551
552(defun cua--rectangle-operation (keep-clear visible undo pad tabify &optional fct post-fct)
537 ;; Call FCT for each line of region with 4 parameters: 553 ;; Call FCT for each line of region with 4 parameters:
538 ;; Region start, end, left-col, right-col 554 ;; Region start, end, left-col, right-col
539 ;; Point is at start when FCT is called 555 ;; Point is at start when FCT is called
556 ;; Call fct with (s,e) = whole lines if VISIBLE non-nil.
557 ;; Only call fct for visible lines if VISIBLE==t.
540 ;; Set undo boundary if UNDO is non-nil. 558 ;; Set undo boundary if UNDO is non-nil.
541 ;; Rectangle is padded if PAD = t or numeric and (cua--rectangle-padding) 559 ;; Rectangle is padded if PAD = t or numeric and (cua--rectangle-virtual-edges)
560 ;; Perform auto-tabify after operation if TABIFY is non-nil.
542 ;; Mark is kept if keep-clear is 'keep and cleared if keep-clear is 'clear. 561 ;; Mark is kept if keep-clear is 'keep and cleared if keep-clear is 'clear.
543 (let* ((start (cua--rectangle-top)) 562 (let* ((start (cua--rectangle-top))
544 (end (cua--rectangle-bot)) 563 (end (cua--rectangle-bot))
@@ -546,11 +565,12 @@ If command is repeated at same position, delete the rectangle."
546 (r (1+ (cua--rectangle-right))) 565 (r (1+ (cua--rectangle-right)))
547 (m (make-marker)) 566 (m (make-marker))
548 (tabpad (and (integerp pad) (= pad 2))) 567 (tabpad (and (integerp pad) (= pad 2)))
549 (sel (cua--rectangle-restriction))) 568 (sel (cua--rectangle-restriction))
569 (tabify-start (and tabify (cua--tabify-start start end))))
550 (if undo 570 (if undo
551 (cua--rectangle-undo-boundary)) 571 (cua--rectangle-undo-boundary))
552 (if (integerp pad) 572 (if (integerp pad)
553 (setq pad (cua--rectangle-padding))) 573 (setq pad (cua--rectangle-virtual-edges)))
554 (save-excursion 574 (save-excursion
555 (save-restriction 575 (save-restriction
556 (widen) 576 (widen)
@@ -558,11 +578,13 @@ If command is repeated at same position, delete the rectangle."
558 (goto-char end) 578 (goto-char end)
559 (and (bolp) (not (eolp)) (not (eobp)) 579 (and (bolp) (not (eolp)) (not (eobp))
560 (setq end (1+ end)))) 580 (setq end (1+ end))))
561 (when visible 581 (when (eq visible t)
562 (setq start (max (window-start) start)) 582 (setq start (max (window-start) start))
563 (setq end (min (window-end) end))) 583 (setq end (min (window-end) end)))
564 (goto-char end) 584 (goto-char end)
565 (setq end (line-end-position)) 585 (setq end (line-end-position))
586 (if (and visible (bolp) (not (eobp)))
587 (setq end (1+ end)))
566 (goto-char start) 588 (goto-char start)
567 (setq start (line-beginning-position)) 589 (setq start (line-beginning-position))
568 (narrow-to-region start end) 590 (narrow-to-region start end)
@@ -575,7 +597,7 @@ If command is repeated at same position, delete the rectangle."
575 (forward-char 1)) 597 (forward-char 1))
576 (set-marker m (point)) 598 (set-marker m (point))
577 (move-to-column l pad) 599 (move-to-column l pad)
578 (if (and fct (>= (current-column) l) (<= (current-column) r)) 600 (if (and fct (or visible (and (>= (current-column) l) (<= (current-column) r))))
579 (let ((v t) (p (point))) 601 (let ((v t) (p (point)))
580 (when sel 602 (when sel
581 (if (car (cdr sel)) 603 (if (car (cdr sel))
@@ -585,8 +607,7 @@ If command is repeated at same position, delete the rectangle."
585 (if (car (cdr (cdr sel))) 607 (if (car (cdr (cdr sel)))
586 (setq v (null v)))) 608 (setq v (null v))))
587 (if visible 609 (if visible
588 (unless (eolp) 610 (funcall fct p m l r v)
589 (funcall fct p m l r v))
590 (if v 611 (if v
591 (funcall fct p m l r))))) 612 (funcall fct p m l r)))))
592 (set-marker m nil) 613 (set-marker m nil)
@@ -594,7 +615,9 @@ If command is repeated at same position, delete the rectangle."
594 (if (not visible) 615 (if (not visible)
595 (cua--rectangle-bot t)) 616 (cua--rectangle-bot t))
596 (if post-fct 617 (if post-fct
597 (funcall post-fct l r)))) 618 (funcall post-fct l r))
619 (when tabify-start
620 (tabify tabify-start (point)))))
598 (cond 621 (cond
599 ((eq keep-clear 'keep) 622 ((eq keep-clear 'keep)
600 (cua--keep-active)) 623 (cua--keep-active))
@@ -607,48 +630,96 @@ If command is repeated at same position, delete the rectangle."
607 630
608(put 'cua--rectangle-operation 'lisp-indent-function 4) 631(put 'cua--rectangle-operation 'lisp-indent-function 4)
609 632
610(defun cua--pad-rectangle (&optional pad)
611 (if (or pad (cua--rectangle-padding))
612 (cua--rectangle-operation nil nil t t)))
613
614(defun cua--delete-rectangle () 633(defun cua--delete-rectangle ()
615 (cua--rectangle-operation nil nil t 2 634 (let ((lines 0))
616 '(lambda (s e l r) 635 (if (not (cua--rectangle-virtual-edges))
617 (if (and (> e s) (<= e (point-max))) 636 (cua--rectangle-operation nil nil t 2 t
618 (delete-region s e))))) 637 '(lambda (s e l r v)
638 (setq lines (1+ lines))
639 (if (and (> e s) (<= e (point-max)))
640 (delete-region s e))))
641 (cua--rectangle-operation nil 1 t nil t
642 '(lambda (s e l r v)
643 (setq lines (1+ lines))
644 (when (and (> e s) (<= e (point-max)))
645 (delete-region s e)))))
646 lines))
619 647
620(defun cua--extract-rectangle () 648(defun cua--extract-rectangle ()
621 (let (rect) 649 (let (rect)
622 (cua--rectangle-operation nil nil nil 1 650 (if (not (cua--rectangle-virtual-edges))
623 '(lambda (s e l r) 651 (cua--rectangle-operation nil nil nil nil nil ; do not tabify
624 (setq rect (cons (buffer-substring-no-properties s e) rect)))) 652 '(lambda (s e l r)
625 (nreverse rect))) 653 (setq rect (cons (buffer-substring-no-properties s e) rect))))
626 654 (cua--rectangle-operation nil 1 nil nil nil ; do not tabify
627(defun cua--insert-rectangle (rect &optional below) 655 '(lambda (s e l r v)
656 (let ((copy t) (bs 0) (as 0) row)
657 (if (= s e) (setq e (1+ e)))
658 (goto-char s)
659 (move-to-column l)
660 (if (= (point) (line-end-position))
661 (setq bs (- r l)
662 copy nil)
663 (skip-chars-forward "\s\t" e)
664 (setq bs (- (min r (current-column)) l)
665 s (point))
666 (move-to-column r)
667 (skip-chars-backward "\s\t" s)
668 (setq as (- r (max (current-column) l))
669 e (point)))
670 (setq row (if (and copy (> e s))
671 (buffer-substring-no-properties s e)
672 ""))
673 (when (> bs 0)
674 (setq row (concat (make-string bs ?\s) row)))
675 (when (> as 0)
676 (setq row (concat row (make-string as ?\s))))
677 (setq rect (cons row rect))))))
678 (nreverse rect)))
679
680(defun cua--insert-rectangle (rect &optional below paste-column line-count)
628 ;; Insert rectangle as insert-rectangle, but don't set mark and exit with 681 ;; Insert rectangle as insert-rectangle, but don't set mark and exit with
629 ;; point at either next to top right or below bottom left corner 682 ;; point at either next to top right or below bottom left corner
630 ;; Notice: In overwrite mode, the rectangle is inserted as separate text lines. 683 ;; Notice: In overwrite mode, the rectangle is inserted as separate text lines.
631 (if (and below (eq below 'auto)) 684 (if (eq below 'auto)
632 (setq below (and (bolp) 685 (setq below (and (bolp)
633 (or (eolp) (eobp) (= (1+ (point)) (point-max)))))) 686 (or (eolp) (eobp) (= (1+ (point)) (point-max))))))
687 (unless paste-column
688 (setq paste-column (current-column)))
634 (let ((lines rect) 689 (let ((lines rect)
635 (insertcolumn (current-column))
636 (first t) 690 (first t)
691 (tabify-start (cua--tabify-start (point) (point)))
692 last-column
637 p) 693 p)
638 (while (or lines below) 694 (while (or lines below)
639 (or first 695 (or first
640 (if overwrite-mode 696 (if overwrite-mode
641 (insert ?\n) 697 (insert ?\n)
642 (forward-line 1) 698 (forward-line 1)
643 (or (bolp) (insert ?\n)) 699 (or (bolp) (insert ?\n))))
644 (move-to-column insertcolumn t))) 700 (unless overwrite-mode
701 (move-to-column paste-column t))
645 (if (not lines) 702 (if (not lines)
646 (setq below nil) 703 (setq below nil)
647 (insert-for-yank (car lines)) 704 (insert-for-yank (car lines))
705 (unless last-column
706 (setq last-column (current-column)))
648 (setq lines (cdr lines)) 707 (setq lines (cdr lines))
649 (and first (not below) 708 (and first (not below)
650 (setq p (point)))) 709 (setq p (point))))
651 (setq first nil)) 710 (setq first nil)
711 (if (and line-count (= (setq line-count (1- line-count)) 0))
712 (setq lines nil)))
713 (when (and line-count last-column (not overwrite-mode))
714 (while (> line-count 0)
715 (forward-line 1)
716 (or (bolp) (insert ?\n))
717 (move-to-column paste-column t)
718 (insert-char ?\s (- last-column paste-column -1))
719 (setq line-count (1- line-count))))
720 (when (and tabify-start
721 (not overwrite-mode))
722 (tabify tabify-start (point)))
652 (and p (not overwrite-mode) 723 (and p (not overwrite-mode)
653 (goto-char p)))) 724 (goto-char p))))
654 725
@@ -662,7 +733,7 @@ If command is repeated at same position, delete the rectangle."
662 (function (lambda (row) (concat row "\n"))) 733 (function (lambda (row) (concat row "\n")))
663 killed-rectangle ""))))) 734 killed-rectangle "")))))
664 735
665(defun cua--activate-rectangle (&optional force) 736(defun cua--activate-rectangle ()
666 ;; Turn on rectangular marking mode by disabling transient mark mode 737 ;; Turn on rectangular marking mode by disabling transient mark mode
667 ;; and manually handling highlighting from a post command hook. 738 ;; and manually handling highlighting from a post command hook.
668 ;; Be careful if we are already marking a rectangle. 739 ;; Be careful if we are already marking a rectangle.
@@ -671,12 +742,8 @@ If command is repeated at same position, delete the rectangle."
671 (eq (car cua--last-rectangle) (current-buffer)) 742 (eq (car cua--last-rectangle) (current-buffer))
672 (eq (car (cdr cua--last-rectangle)) (point))) 743 (eq (car (cdr cua--last-rectangle)) (point)))
673 (cdr (cdr cua--last-rectangle)) 744 (cdr (cdr cua--last-rectangle))
674 (cua--rectangle-get-corners 745 (cua--rectangle-get-corners))
675 (and (not buffer-read-only) 746 cua--status-string (if (cua--rectangle-virtual-edges) " [R]" "")
676 (or cua-auto-expand-rectangles
677 force
678 (eq major-mode 'picture-mode)))))
679 cua--status-string (if (cua--rectangle-padding) " Pad" "")
680 cua--last-rectangle nil)) 747 cua--last-rectangle nil))
681 748
682;; (defvar cua-save-point nil) 749;; (defvar cua-save-point nil)
@@ -698,7 +765,7 @@ If command is repeated at same position, delete the rectangle."
698 ;; Each overlay extends across all the columns of the rectangle. 765 ;; Each overlay extends across all the columns of the rectangle.
699 ;; We try to reuse overlays where possible because this is more efficient 766 ;; We try to reuse overlays where possible because this is more efficient
700 ;; and results in less flicker. 767 ;; and results in less flicker.
701 ;; If cua--rectangle-padding is nil and the buffer contains tabs or short lines, 768 ;; If cua--rectangle-virtual-edges is nil and the buffer contains tabs or short lines,
702 ;; the higlighted region may not be perfectly rectangular. 769 ;; the higlighted region may not be perfectly rectangular.
703 (let ((deactivate-mark deactivate-mark) 770 (let ((deactivate-mark deactivate-mark)
704 (old cua--rectangle-overlays) 771 (old cua--rectangle-overlays)
@@ -707,12 +774,67 @@ If command is repeated at same position, delete the rectangle."
707 (right (1+ (cua--rectangle-right)))) 774 (right (1+ (cua--rectangle-right))))
708 (when (/= left right) 775 (when (/= left right)
709 (sit-for 0) ; make window top/bottom reliable 776 (sit-for 0) ; make window top/bottom reliable
710 (cua--rectangle-operation nil t nil nil 777 (cua--rectangle-operation nil t nil nil nil ; do not tabify
711 '(lambda (s e l r v) 778 '(lambda (s e l r v)
712 (let ((rface (if v 'cua-rectangle-face 'cua-rectangle-noselect-face)) 779 (let ((rface (if v 'cua-rectangle-face 'cua-rectangle-noselect-face))
713 overlay) 780 overlay bs ms as)
714 ;; Trim old leading overlays.
715 (if (= s e) (setq e (1+ e))) 781 (if (= s e) (setq e (1+ e)))
782 (when (cua--rectangle-virtual-edges)
783 (let ((lb (line-beginning-position))
784 (le (line-end-position))
785 cl cl0 pl cr cr0 pr)
786 (goto-char s)
787 (setq cl (move-to-column l)
788 pl (point))
789 (setq cr (move-to-column r)
790 pr (point))
791 (if (= lb pl)
792 (setq cl0 0)
793 (goto-char (1- pl))
794 (setq cl0 (current-column)))
795 (if (= lb le)
796 (setq cr0 0)
797 (goto-char (1- pr))
798 (setq cr0 (current-column)))
799 (unless (and (= cl l) (= cr r))
800 (when (/= cl l)
801 (setq bs (propertize
802 (make-string
803 (- l cl0 (if (and (= le pl) (/= le lb)) 1 0))
804 (if cua--virtual-edges-debug ?. ?\s))
805 'face 'default))
806 (if (/= pl le)
807 (setq s (1- s))))
808 (cond
809 ((= cr r)
810 (if (and (/= pr le)
811 (/= cr0 (1- cr))
812 (or bs (/= cr0 (- cr tab-width)))
813 (/= (mod cr tab-width) 0))
814 (setq e (1- e))))
815 ((= cr cl)
816 (setq ms (propertize
817 (make-string
818 (- r l)
819 (if cua--virtual-edges-debug ?, ?\s))
820 'face rface))
821 (if (cua--rectangle-right-side)
822 (put-text-property (1- (length ms)) (length ms) 'cursor t ms)
823 (put-text-property 0 1 'cursor t ms))
824 (setq bs (concat bs ms))
825 (setq rface nil))
826 (t
827 (setq as (propertize
828 (make-string
829 (- r cr0 (if (= le pr) 1 0))
830 (if cua--virtual-edges-debug ?~ ?\s))
831 'face rface))
832 (if (cua--rectangle-right-side)
833 (put-text-property (1- (length as)) (length as) 'cursor t as)
834 (put-text-property 0 1 'cursor t as))
835 (if (/= pr le)
836 (setq e (1- e))))))))
837 ;; Trim old leading overlays.
716 (while (and old 838 (while (and old
717 (setq overlay (car old)) 839 (setq overlay (car old))
718 (< (overlay-start overlay) s) 840 (< (overlay-start overlay) s)
@@ -728,8 +850,11 @@ If command is repeated at same position, delete the rectangle."
728 (move-overlay overlay s e) 850 (move-overlay overlay s e)
729 (setq old (cdr old))) 851 (setq old (cdr old)))
730 (setq overlay (make-overlay s e))) 852 (setq overlay (make-overlay s e)))
731 (overlay-put overlay 'face rface) 853 (overlay-put overlay 'before-string bs)
732 (setq new (cons overlay new)))))) 854 (overlay-put overlay 'after-string as)
855 (overlay-put overlay 'face rface)
856 (overlay-put overlay 'keymap cua--overlay-keymap)
857 (setq new (cons overlay new))))))
733 ;; Trim old trailing overlays. 858 ;; Trim old trailing overlays.
734 (mapcar (function delete-overlay) old) 859 (mapcar (function delete-overlay) old)
735 (setq cua--rectangle-overlays (nreverse new)))) 860 (setq cua--rectangle-overlays (nreverse new))))
@@ -737,9 +862,9 @@ If command is repeated at same position, delete the rectangle."
737(defun cua--indent-rectangle (&optional ch to-col clear) 862(defun cua--indent-rectangle (&optional ch to-col clear)
738 ;; Indent current rectangle. 863 ;; Indent current rectangle.
739 (let ((col (cua--rectangle-insert-col)) 864 (let ((col (cua--rectangle-insert-col))
740 (pad (cua--rectangle-padding)) 865 (pad (cua--rectangle-virtual-edges))
741 indent) 866 indent)
742 (cua--rectangle-operation (if clear 'clear 'corners) nil t pad 867 (cua--rectangle-operation (if clear 'clear 'corners) nil t pad nil
743 '(lambda (s e l r) 868 '(lambda (s e l r)
744 (move-to-column col pad) 869 (move-to-column col pad)
745 (if (and (eolp) 870 (if (and (eolp)
@@ -875,23 +1000,22 @@ With prefix argument, the toggle restriction."
875(defun cua-rotate-rectangle () 1000(defun cua-rotate-rectangle ()
876 (interactive) 1001 (interactive)
877 (cua--rectangle-corner (if (= (cua--rectangle-left) (cua--rectangle-right)) 0 1)) 1002 (cua--rectangle-corner (if (= (cua--rectangle-left) (cua--rectangle-right)) 0 1))
878 (cua--rectangle-set-corners)) 1003 (cua--rectangle-set-corners)
1004 (if (cua--rectangle-virtual-edges)
1005 (setq cua--buffer-and-point-before-command nil)))
879 1006
880(defun cua-toggle-rectangle-padding () 1007(defun cua-toggle-rectangle-virtual-edges ()
881 (interactive) 1008 (interactive)
882 (if buffer-read-only 1009 (cua--rectangle-virtual-edges t (not (cua--rectangle-virtual-edges)))
883 (message "Cannot do padding in read-only buffer.") 1010 (cua--rectangle-set-corners)
884 (cua--rectangle-padding t (not (cua--rectangle-padding))) 1011 (setq cua--status-string (and (cua--rectangle-virtual-edges) " [R]"))
885 (cua--pad-rectangle)
886 (cua--rectangle-set-corners))
887 (setq cua--status-string (and (cua--rectangle-padding) " Pad"))
888 (cua--keep-active)) 1012 (cua--keep-active))
889 1013
890(defun cua-do-rectangle-padding () 1014(defun cua-do-rectangle-padding ()
891 (interactive) 1015 (interactive)
892 (if buffer-read-only 1016 (if buffer-read-only
893 (message "Cannot do padding in read-only buffer.") 1017 (message "Cannot do padding in read-only buffer.")
894 (cua--pad-rectangle t) 1018 (cua--rectangle-operation nil nil t t t)
895 (cua--rectangle-set-corners)) 1019 (cua--rectangle-set-corners))
896 (cua--keep-active)) 1020 (cua--keep-active))
897 1021
@@ -900,7 +1024,7 @@ With prefix argument, the toggle restriction."
900The text previously in the region is not overwritten by the blanks, 1024The text previously in the region is not overwritten by the blanks,
901but instead winds up to the right of the rectangle." 1025but instead winds up to the right of the rectangle."
902 (interactive) 1026 (interactive)
903 (cua--rectangle-operation 'corners nil t 1 1027 (cua--rectangle-operation 'corners nil t 1 nil
904 '(lambda (s e l r) 1028 '(lambda (s e l r)
905 (skip-chars-forward " \t") 1029 (skip-chars-forward " \t")
906 (let ((ws (- (current-column) l)) 1030 (let ((ws (- (current-column) l))
@@ -915,7 +1039,7 @@ On each line in the rectangle, all continuous whitespace starting
915at that column is deleted. 1039at that column is deleted.
916With prefix arg, also delete whitespace to the left of that column." 1040With prefix arg, also delete whitespace to the left of that column."
917 (interactive "P") 1041 (interactive "P")
918 (cua--rectangle-operation 'clear nil t 1 1042 (cua--rectangle-operation 'clear nil t 1 nil
919 '(lambda (s e l r) 1043 '(lambda (s e l r)
920 (when arg 1044 (when arg
921 (skip-syntax-backward " " (line-beginning-position)) 1045 (skip-syntax-backward " " (line-beginning-position))
@@ -927,7 +1051,7 @@ With prefix arg, also delete whitespace to the left of that column."
927 "Blank out CUA rectangle. 1051 "Blank out CUA rectangle.
928The text previously in the rectangle is overwritten by the blanks." 1052The text previously in the rectangle is overwritten by the blanks."
929 (interactive) 1053 (interactive)
930 (cua--rectangle-operation 'keep nil nil 1 1054 (cua--rectangle-operation 'keep nil nil 1 nil
931 '(lambda (s e l r) 1055 '(lambda (s e l r)
932 (goto-char e) 1056 (goto-char e)
933 (skip-syntax-forward " " (line-end-position)) 1057 (skip-syntax-forward " " (line-end-position))
@@ -942,7 +1066,7 @@ The text previously in the rectangle is overwritten by the blanks."
942 "Align rectangle lines to left column." 1066 "Align rectangle lines to left column."
943 (interactive) 1067 (interactive)
944 (let (x) 1068 (let (x)
945 (cua--rectangle-operation 'clear nil t t 1069 (cua--rectangle-operation 'clear nil t t nil
946 '(lambda (s e l r) 1070 '(lambda (s e l r)
947 (let ((b (line-beginning-position))) 1071 (let ((b (line-beginning-position)))
948 (skip-syntax-backward "^ " b) 1072 (skip-syntax-backward "^ " b)
@@ -984,7 +1108,7 @@ The text previously in the rectangle is overwritten by the blanks."
984 "Replace CUA rectangle contents with STRING on each line. 1108 "Replace CUA rectangle contents with STRING on each line.
985The length of STRING need not be the same as the rectangle width." 1109The length of STRING need not be the same as the rectangle width."
986 (interactive "sString rectangle: ") 1110 (interactive "sString rectangle: ")
987 (cua--rectangle-operation 'keep nil t t 1111 (cua--rectangle-operation 'keep nil t t nil
988 '(lambda (s e l r) 1112 '(lambda (s e l r)
989 (delete-region s e) 1113 (delete-region s e)
990 (skip-chars-forward " \t") 1114 (skip-chars-forward " \t")
@@ -999,7 +1123,7 @@ The length of STRING need not be the same as the rectangle width."
999(defun cua-fill-char-rectangle (ch) 1123(defun cua-fill-char-rectangle (ch)
1000 "Replace CUA rectangle contents with CHARACTER." 1124 "Replace CUA rectangle contents with CHARACTER."
1001 (interactive "cFill rectangle with character: ") 1125 (interactive "cFill rectangle with character: ")
1002 (cua--rectangle-operation 'clear nil t 1 1126 (cua--rectangle-operation 'clear nil t 1 nil
1003 '(lambda (s e l r) 1127 '(lambda (s e l r)
1004 (delete-region s e) 1128 (delete-region s e)
1005 (move-to-column l t) 1129 (move-to-column l t)
@@ -1010,7 +1134,7 @@ The length of STRING need not be the same as the rectangle width."
1010 (interactive "sReplace regexp: \nsNew text: ") 1134 (interactive "sReplace regexp: \nsNew text: ")
1011 (if buffer-read-only 1135 (if buffer-read-only
1012 (message "Cannot replace in read-only buffer") 1136 (message "Cannot replace in read-only buffer")
1013 (cua--rectangle-operation 'keep nil t 1 1137 (cua--rectangle-operation 'keep nil t 1 nil
1014 '(lambda (s e l r) 1138 '(lambda (s e l r)
1015 (if (re-search-forward regexp e t) 1139 (if (re-search-forward regexp e t)
1016 (replace-match newtext nil nil)))))) 1140 (replace-match newtext nil nil))))))
@@ -1018,7 +1142,7 @@ The length of STRING need not be the same as the rectangle width."
1018(defun cua-incr-rectangle (increment) 1142(defun cua-incr-rectangle (increment)
1019 "Increment each line of CUA rectangle by prefix amount." 1143 "Increment each line of CUA rectangle by prefix amount."
1020 (interactive "p") 1144 (interactive "p")
1021 (cua--rectangle-operation 'keep nil t 1 1145 (cua--rectangle-operation 'keep nil t 1 nil
1022 '(lambda (s e l r) 1146 '(lambda (s e l r)
1023 (cond 1147 (cond
1024 ((re-search-forward "0x\\([0-9a-fA-F]+\\)" e t) 1148 ((re-search-forward "0x\\([0-9a-fA-F]+\\)" e t)
@@ -1051,36 +1175,36 @@ The numbers are formatted according to the FORMAT string."
1051 (if (= (length fmt) 0) 1175 (if (= (length fmt) 0)
1052 (setq fmt cua--rectangle-seq-format) 1176 (setq fmt cua--rectangle-seq-format)
1053 (setq cua--rectangle-seq-format fmt)) 1177 (setq cua--rectangle-seq-format fmt))
1054 (cua--rectangle-operation 'clear nil t 1 1178 (cua--rectangle-operation 'clear nil t 1 nil
1055 '(lambda (s e l r) 1179 '(lambda (s e l r)
1056 (delete-region s e) 1180 (delete-region s e)
1057 (insert (format fmt first)) 1181 (insert (format fmt first))
1058 (setq first (+ first incr))))) 1182 (setq first (+ first incr)))))
1059 1183
1060(defmacro cua--convert-rectangle-as (command) 1184(defmacro cua--convert-rectangle-as (command tabify)
1061 `(cua--rectangle-operation 'clear nil nil nil 1185 `(cua--rectangle-operation 'clear nil nil nil ,tabify
1062 '(lambda (s e l r) 1186 '(lambda (s e l r)
1063 (,command s e)))) 1187 (,command s e))))
1064 1188
1065(defun cua-upcase-rectangle () 1189(defun cua-upcase-rectangle ()
1066 "Convert the rectangle to upper case." 1190 "Convert the rectangle to upper case."
1067 (interactive) 1191 (interactive)
1068 (cua--convert-rectangle-as upcase-region)) 1192 (cua--convert-rectangle-as upcase-region nil))
1069 1193
1070(defun cua-downcase-rectangle () 1194(defun cua-downcase-rectangle ()
1071 "Convert the rectangle to lower case." 1195 "Convert the rectangle to lower case."
1072 (interactive) 1196 (interactive)
1073 (cua--convert-rectangle-as downcase-region)) 1197 (cua--convert-rectangle-as downcase-region nil))
1074 1198
1075(defun cua-upcase-initials-rectangle () 1199(defun cua-upcase-initials-rectangle ()
1076 "Convert the rectangle initials to upper case." 1200 "Convert the rectangle initials to upper case."
1077 (interactive) 1201 (interactive)
1078 (cua--convert-rectangle-as upcase-initials-region)) 1202 (cua--convert-rectangle-as upcase-initials-region nil))
1079 1203
1080(defun cua-capitalize-rectangle () 1204(defun cua-capitalize-rectangle ()
1081 "Convert the rectangle to proper case." 1205 "Convert the rectangle to proper case."
1082 (interactive) 1206 (interactive)
1083 (cua--convert-rectangle-as capitalize-region)) 1207 (cua--convert-rectangle-as capitalize-region nil))
1084 1208
1085 1209
1086;;; Replace/rearrange text in current rectangle 1210;;; Replace/rearrange text in current rectangle
@@ -1116,7 +1240,7 @@ The numbers are formatted according to the FORMAT string."
1116 (setq z (reverse z)) 1240 (setq z (reverse z))
1117 (if cua--debug 1241 (if cua--debug
1118 (print z auxbuf)) 1242 (print z auxbuf))
1119 (cua--rectangle-operation nil nil t pad 1243 (cua--rectangle-operation nil nil t pad nil
1120 '(lambda (s e l r) 1244 '(lambda (s e l r)
1121 (let (cc) 1245 (let (cc)
1122 (goto-char e) 1246 (goto-char e)
@@ -1232,9 +1356,9 @@ With prefix arg, indent to that column."
1232 "Delete char to left or right of rectangle." 1356 "Delete char to left or right of rectangle."
1233 (interactive) 1357 (interactive)
1234 (let ((col (cua--rectangle-insert-col)) 1358 (let ((col (cua--rectangle-insert-col))
1235 (pad (cua--rectangle-padding)) 1359 (pad (cua--rectangle-virtual-edges))
1236 indent) 1360 indent)
1237 (cua--rectangle-operation 'corners nil t pad 1361 (cua--rectangle-operation 'corners nil t pad nil
1238 '(lambda (s e l r) 1362 '(lambda (s e l r)
1239 (move-to-column 1363 (move-to-column
1240 (if (cua--rectangle-right-side t) 1364 (if (cua--rectangle-right-side t)
@@ -1282,10 +1406,7 @@ With prefix arg, indent to that column."
1282 (cua--rectangle-left (current-column))) 1406 (cua--rectangle-left (current-column)))
1283 (if (>= (cua--rectangle-corner) 2) 1407 (if (>= (cua--rectangle-corner) 2)
1284 (cua--rectangle-bot t) 1408 (cua--rectangle-bot t)
1285 (cua--rectangle-top t)) 1409 (cua--rectangle-top t))))
1286 (if (cua--rectangle-padding)
1287 (setq unread-command-events
1288 (cons (if cua-use-hyper-key ?\H-P ?\M-P) unread-command-events)))))
1289 (if cua--rectangle 1410 (if cua--rectangle
1290 (if (and mark-active 1411 (if (and mark-active
1291 (not deactivate-mark)) 1412 (not deactivate-mark))
@@ -1379,7 +1500,7 @@ With prefix arg, indent to that column."
1379 (cua--rect-M/H-key ?m 'cua-copy-rectangle-as-text) 1500 (cua--rect-M/H-key ?m 'cua-copy-rectangle-as-text)
1380 (cua--rect-M/H-key ?n 'cua-sequence-rectangle) 1501 (cua--rect-M/H-key ?n 'cua-sequence-rectangle)
1381 (cua--rect-M/H-key ?o 'cua-open-rectangle) 1502 (cua--rect-M/H-key ?o 'cua-open-rectangle)
1382 (cua--rect-M/H-key ?p 'cua-toggle-rectangle-padding) 1503 (cua--rect-M/H-key ?p 'cua-toggle-rectangle-virtual-edges)
1383 (cua--rect-M/H-key ?P 'cua-do-rectangle-padding) 1504 (cua--rect-M/H-key ?P 'cua-do-rectangle-padding)
1384 (cua--rect-M/H-key ?q 'cua-refill-rectangle) 1505 (cua--rect-M/H-key ?q 'cua-refill-rectangle)
1385 (cua--rect-M/H-key ?r 'cua-replace-in-rectangle) 1506 (cua--rect-M/H-key ?r 'cua-replace-in-rectangle)
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index e534c6998a7..d193ad344f5 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -461,18 +461,21 @@ face (according to `face-differs-from-default-p')."
461(defun variable-at-point () 461(defun variable-at-point ()
462 "Return the bound variable symbol found around point. 462 "Return the bound variable symbol found around point.
463Return 0 if there is no such symbol." 463Return 0 if there is no such symbol."
464 (condition-case () 464 (or (condition-case ()
465 (with-syntax-table emacs-lisp-mode-syntax-table 465 (with-syntax-table emacs-lisp-mode-syntax-table
466 (save-excursion 466 (save-excursion
467 (or (not (zerop (skip-syntax-backward "_w"))) 467 (or (not (zerop (skip-syntax-backward "_w")))
468 (eq (char-syntax (following-char)) ?w) 468 (eq (char-syntax (following-char)) ?w)
469 (eq (char-syntax (following-char)) ?_) 469 (eq (char-syntax (following-char)) ?_)
470 (forward-sexp -1)) 470 (forward-sexp -1))
471 (skip-chars-forward "'") 471 (skip-chars-forward "'")
472 (let ((obj (read (current-buffer)))) 472 (let ((obj (read (current-buffer))))
473 (or (and (symbolp obj) (boundp obj) obj) 473 (and (symbolp obj) (boundp obj) obj))))
474 0)))) 474 (error nil))
475 (error 0))) 475 (let* ((str (find-tag-default))
476 (obj (if str (read str))))
477 (and (symbolp obj) (boundp obj) obj))
478 0))
476 479
477;;;###autoload 480;;;###autoload
478(defun describe-variable (variable &optional buffer) 481(defun describe-variable (variable &optional buffer)
diff --git a/lisp/help.el b/lisp/help.el
index 52a772779a5..bf0df4358a7 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -237,32 +237,35 @@ C-w Display information on absence of warranty for GNU Emacs."
237(defun function-called-at-point () 237(defun function-called-at-point ()
238 "Return a function around point or else called by the list containing point. 238 "Return a function around point or else called by the list containing point.
239If that doesn't give a function, return nil." 239If that doesn't give a function, return nil."
240 (with-syntax-table emacs-lisp-mode-syntax-table 240 (or (with-syntax-table emacs-lisp-mode-syntax-table
241 (or (condition-case () 241 (or (condition-case ()
242 (save-excursion 242 (save-excursion
243 (or (not (zerop (skip-syntax-backward "_w"))) 243 (or (not (zerop (skip-syntax-backward "_w")))
244 (eq (char-syntax (following-char)) ?w) 244 (eq (char-syntax (following-char)) ?w)
245 (eq (char-syntax (following-char)) ?_) 245 (eq (char-syntax (following-char)) ?_)
246 (forward-sexp -1)) 246 (forward-sexp -1))
247 (skip-chars-forward "'") 247 (skip-chars-forward "'")
248 (let ((obj (read (current-buffer)))) 248 (let ((obj (read (current-buffer))))
249 (and (symbolp obj) (fboundp obj) obj))) 249 (and (symbolp obj) (fboundp obj) obj)))
250 (error nil)) 250 (error nil))
251 (condition-case () 251 (condition-case ()
252 (save-excursion 252 (save-excursion
253 (save-restriction 253 (save-restriction
254 (narrow-to-region (max (point-min) 254 (narrow-to-region (max (point-min)
255 (- (point) 1000)) (point-max)) 255 (- (point) 1000)) (point-max))
256 ;; Move up to surrounding paren, then after the open. 256 ;; Move up to surrounding paren, then after the open.
257 (backward-up-list 1) 257 (backward-up-list 1)
258 (forward-char 1) 258 (forward-char 1)
259 ;; If there is space here, this is probably something 259 ;; If there is space here, this is probably something
260 ;; other than a real Lisp function call, so ignore it. 260 ;; other than a real Lisp function call, so ignore it.
261 (if (looking-at "[ \t]") 261 (if (looking-at "[ \t]")
262 (error "Probably not a Lisp function call")) 262 (error "Probably not a Lisp function call"))
263 (let ((obj (read (current-buffer)))) 263 (let ((obj (read (current-buffer))))
264 (and (symbolp obj) (fboundp obj) obj)))) 264 (and (symbolp obj) (fboundp obj) obj))))
265 (error nil))))) 265 (error nil))))
266 (let* ((str (find-tag-default))
267 (obj (if str (read str))))
268 (and (symbolp obj) (fboundp obj) obj))))
266 269
267 270
268;;; `User' help functions 271;;; `User' help functions
diff --git a/lisp/indent.el b/lisp/indent.el
index e56db11b6f1..2d223b05ad6 100644
--- a/lisp/indent.el
+++ b/lisp/indent.el
@@ -442,8 +442,8 @@ This should be a list of integers, ordered from smallest to largest."
442 "Keymap used in `edit-tab-stops'.") 442 "Keymap used in `edit-tab-stops'.")
443 443
444(defvar edit-tab-stops-buffer nil 444(defvar edit-tab-stops-buffer nil
445 "Buffer whose tab stops are being edited--in case 445 "Buffer whose tab stops are being edited.
446the variable `tab-stop-list' is local in that buffer.") 446This matters if the variable `tab-stop-list' is local in that buffer.")
447 447
448(defun edit-tab-stops () 448(defun edit-tab-stops ()
449 "Edit the tab stops used by `tab-to-tab-stop'. 449 "Edit the tab stops used by `tab-to-tab-stop'.
diff --git a/lisp/info.el b/lisp/info.el
index 43e1dafcc6f..802fcf1642e 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -188,7 +188,7 @@ file, so be prepared for a few surprises if you enable this feature."
188 :type 'boolean 188 :type 'boolean
189 :group 'info) 189 :group 'info)
190 190
191(defcustom Info-search-whitespace-regexp "\\\\(?:\\\\s-+\\\\)" 191(defcustom Info-search-whitespace-regexp "\\(?:\\s-+\\)"
192 "*If non-nil, regular expression to match a sequence of whitespace chars. 192 "*If non-nil, regular expression to match a sequence of whitespace chars.
193This applies to Info search for regular expressions. 193This applies to Info search for regular expressions.
194You might want to use something like \"[ \\t\\r\\n]+\" instead. 194You might want to use something like \"[ \\t\\r\\n]+\" instead.
@@ -1442,8 +1442,9 @@ If FORK is a string, it is the name to use for the new buffer."
1442(defvar Info-search-case-fold nil 1442(defvar Info-search-case-fold nil
1443 "The value of `case-fold-search' from previous `Info-search' command.") 1443 "The value of `case-fold-search' from previous `Info-search' command.")
1444 1444
1445(defun Info-search (regexp) 1445(defun Info-search (regexp &optional bound noerror count direction)
1446 "Search for REGEXP, starting from point, and select node it's found in." 1446 "Search for REGEXP, starting from point, and select node it's found in.
1447If DIRECTION is `backward', search in the reverse direction."
1447 (interactive (list (read-string 1448 (interactive (list (read-string
1448 (if Info-search-history 1449 (if Info-search-history
1449 (format "Regexp search%s (default `%s'): " 1450 (format "Regexp search%s (default `%s'): "
@@ -1458,31 +1459,42 @@ If FORK is a string, it is the name to use for the new buffer."
1458 (setq regexp (car Info-search-history))) 1459 (setq regexp (car Info-search-history)))
1459 (when regexp 1460 (when regexp
1460 (let (found beg-found give-up 1461 (let (found beg-found give-up
1462 (backward (eq direction 'backward))
1461 (onode Info-current-node) 1463 (onode Info-current-node)
1462 (ofile Info-current-file) 1464 (ofile Info-current-file)
1463 (opoint (point)) 1465 (opoint (point))
1466 (opoint-min (point-min))
1467 (opoint-max (point-max))
1464 (ostart (window-start)) 1468 (ostart (window-start))
1465 (osubfile Info-current-subfile)) 1469 (osubfile Info-current-subfile))
1466 (when Info-search-whitespace-regexp 1470 (when Info-search-whitespace-regexp
1467 (setq regexp (replace-regexp-in-string 1471 (setq regexp
1468 "[ \t\n]+" Info-search-whitespace-regexp regexp))) 1472 (mapconcat 'identity (split-string regexp "[ \t\n]+")
1473 Info-search-whitespace-regexp)))
1469 (setq Info-search-case-fold case-fold-search) 1474 (setq Info-search-case-fold case-fold-search)
1470 (save-excursion 1475 (save-excursion
1471 (save-restriction 1476 (save-restriction
1472 (widen) 1477 (widen)
1473 (while (and (not give-up) 1478 (while (and (not give-up)
1474 (or (null found) 1479 (or (null found)
1475 (isearch-range-invisible beg-found found))) 1480 (if backward
1476 (if (re-search-forward regexp nil t) 1481 (isearch-range-invisible found beg-found)
1477 (setq found (point) beg-found (match-beginning 0)) 1482 (isearch-range-invisible beg-found found))))
1483 (if (if backward
1484 (re-search-backward regexp bound t)
1485 (re-search-forward regexp bound t))
1486 (setq found (point) beg-found (if backward (match-end 0)
1487 (match-beginning 0)))
1478 (setq give-up t))))) 1488 (setq give-up t)))))
1479 ;; If no subfiles, give error now. 1489 ;; If no subfiles, give error now.
1480 (if give-up 1490 (if give-up
1481 (if (null Info-current-subfile) 1491 (if (null Info-current-subfile)
1482 (re-search-forward regexp) 1492 (if backward
1493 (re-search-backward regexp)
1494 (re-search-forward regexp))
1483 (setq found nil))) 1495 (setq found nil)))
1484 1496
1485 (unless found 1497 (unless (or found bound)
1486 (unwind-protect 1498 (unwind-protect
1487 ;; Try other subfiles. 1499 ;; Try other subfiles.
1488 (let ((list ())) 1500 (let ((list ()))
@@ -1498,29 +1510,39 @@ If FORK is a string, it is the name to use for the new buffer."
1498 ;; Find the subfile we just searched. 1510 ;; Find the subfile we just searched.
1499 (search-forward (concat "\n" osubfile ": ")) 1511 (search-forward (concat "\n" osubfile ": "))
1500 ;; Skip that one. 1512 ;; Skip that one.
1501 (forward-line 1) 1513 (forward-line (if backward 0 1))
1502 ;; Make a list of all following subfiles. 1514 ;; Make a list of all following subfiles.
1503 ;; Each elt has the form (VIRT-POSITION . SUBFILENAME). 1515 ;; Each elt has the form (VIRT-POSITION . SUBFILENAME).
1504 (while (not (eobp)) 1516 (while (not (if backward (bobp) (eobp)))
1505 (re-search-forward "\\(^.*\\): [0-9]+$") 1517 (if backward
1518 (re-search-backward "\\(^.*\\): [0-9]+$")
1519 (re-search-forward "\\(^.*\\): [0-9]+$"))
1506 (goto-char (+ (match-end 1) 2)) 1520 (goto-char (+ (match-end 1) 2))
1507 (setq list (cons (cons (+ (point-min) 1521 (setq list (cons (cons (+ (point-min)
1508 (read (current-buffer))) 1522 (read (current-buffer)))
1509 (match-string-no-properties 1)) 1523 (match-string-no-properties 1))
1510 list)) 1524 list))
1511 (goto-char (1+ (match-end 0)))) 1525 (goto-char (if backward
1526 (1- (match-beginning 0))
1527 (1+ (match-end 0)))))
1512 ;; Put in forward order 1528 ;; Put in forward order
1513 (setq list (nreverse list)))) 1529 (setq list (nreverse list))))
1514 (while list 1530 (while list
1515 (message "Searching subfile %s..." (cdr (car list))) 1531 (message "Searching subfile %s..." (cdr (car list)))
1516 (Info-read-subfile (car (car list))) 1532 (Info-read-subfile (car (car list)))
1533 (if backward (goto-char (point-max)))
1517 (setq list (cdr list)) 1534 (setq list (cdr list))
1518 (setq give-up nil found nil) 1535 (setq give-up nil found nil)
1519 (while (and (not give-up) 1536 (while (and (not give-up)
1520 (or (null found) 1537 (or (null found)
1521 (isearch-range-invisible beg-found found))) 1538 (if backward
1522 (if (re-search-forward regexp nil t) 1539 (isearch-range-invisible found beg-found)
1523 (setq found (point) beg-found (match-beginning 0)) 1540 (isearch-range-invisible beg-found found))))
1541 (if (if backward
1542 (re-search-backward regexp nil t)
1543 (re-search-forward regexp nil t))
1544 (setq found (point) beg-found (if backward (match-end 0)
1545 (match-beginning 0)))
1524 (setq give-up t))) 1546 (setq give-up t)))
1525 (if give-up 1547 (if give-up
1526 (setq found nil)) 1548 (setq found nil))
@@ -1534,12 +1556,20 @@ If FORK is a string, it is the name to use for the new buffer."
1534 (goto-char opoint) 1556 (goto-char opoint)
1535 (Info-select-node) 1557 (Info-select-node)
1536 (set-window-start (selected-window) ostart))))) 1558 (set-window-start (selected-window) ostart)))))
1537 (widen) 1559
1538 (goto-char found) 1560 (if (and (string= osubfile Info-current-subfile)
1539 (Info-select-node) 1561 (> found opoint-min)
1562 (< found opoint-max))
1563 ;; Search landed in the same node
1564 (goto-char found)
1565 (widen)
1566 (goto-char found)
1567 (save-match-data (Info-select-node)))
1568
1540 ;; Use string-equal, not equal, to ignore text props. 1569 ;; Use string-equal, not equal, to ignore text props.
1541 (or (and (string-equal onode Info-current-node) 1570 (or (and (string-equal onode Info-current-node)
1542 (equal ofile Info-current-file)) 1571 (equal ofile Info-current-file))
1572 (and isearch-mode isearch-wrapped (eq opoint opoint-min))
1543 (setq Info-history (cons (list ofile onode opoint) 1573 (setq Info-history (cons (list ofile onode opoint)
1544 Info-history)))))) 1574 Info-history))))))
1545 1575
@@ -1556,6 +1586,48 @@ If FORK is a string, it is the name to use for the new buffer."
1556 (if Info-search-history 1586 (if Info-search-history
1557 (Info-search (car Info-search-history)) 1587 (Info-search (car Info-search-history))
1558 (call-interactively 'Info-search)))) 1588 (call-interactively 'Info-search))))
1589
1590(defun Info-search-backward (regexp &optional bound noerror count)
1591 "Search for REGEXP in the reverse direction."
1592 (interactive (list (read-string
1593 (if Info-search-history
1594 (format "Regexp search%s backward (default `%s'): "
1595 (if case-fold-search "" " case-sensitively")
1596 (car Info-search-history))
1597 (format "Regexp search%s backward: "
1598 (if case-fold-search "" " case-sensitively")))
1599 nil 'Info-search-history)))
1600 (Info-search regexp bound noerror count 'backward))
1601
1602(defun Info-isearch-search ()
1603 (cond
1604 (isearch-word
1605 (if isearch-forward 'word-search-forward 'word-search-backward))
1606 (isearch-regexp
1607 (lambda (regexp bound noerror)
1608 (condition-case nil
1609 (progn
1610 (Info-search regexp bound noerror nil
1611 (unless isearch-forward 'backward))
1612 (point))
1613 (error nil))))
1614 (t
1615 (if isearch-forward 'search-forward 'search-backward))))
1616
1617(defun Info-isearch-wrap ()
1618 (if isearch-regexp
1619 (if isearch-forward (Info-top-node) (Info-final-node))
1620 (goto-char (if isearch-forward (point-min) (point-max)))))
1621
1622(defun Info-isearch-push-state ()
1623 `(lambda (cmd)
1624 (Info-isearch-pop-state cmd ,Info-current-file ,Info-current-node)))
1625
1626(defun Info-isearch-pop-state (cmd file node)
1627 (or (and (string= Info-current-file file)
1628 (string= Info-current-node node))
1629 (progn (Info-find-node file node) (sit-for 0))))
1630
1559 1631
1560(defun Info-extract-pointer (name &optional errorname) 1632(defun Info-extract-pointer (name &optional errorname)
1561 "Extract the value of the node-pointer named NAME. 1633 "Extract the value of the node-pointer named NAME.
@@ -3064,6 +3136,14 @@ Advanced commands:
3064 (setq desktop-save-buffer 'Info-desktop-buffer-misc-data) 3136 (setq desktop-save-buffer 'Info-desktop-buffer-misc-data)
3065 (add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t) 3137 (add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t)
3066 (add-hook 'change-major-mode-hook 'font-lock-defontify nil t) 3138 (add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
3139 (set (make-local-variable 'isearch-search-fun-function)
3140 'Info-isearch-search)
3141 (set (make-local-variable 'isearch-wrap-function)
3142 'Info-isearch-wrap)
3143 (set (make-local-variable 'isearch-push-state-function)
3144 'Info-isearch-push-state)
3145 (set (make-local-variable 'search-whitespace-regexp)
3146 Info-search-whitespace-regexp)
3067 (Info-set-mode-line) 3147 (Info-set-mode-line)
3068 (run-hooks 'Info-mode-hook)) 3148 (run-hooks 'Info-mode-hook))
3069 3149
@@ -3445,23 +3525,24 @@ Preserve text properties."
3445 other-tag) 3525 other-tag)
3446 (when not-fontified-p 3526 (when not-fontified-p
3447 (when Info-hide-note-references 3527 (when Info-hide-note-references
3448 ;; *Note is often used where *note should have been 3528 (when (not (eq Info-hide-note-references 'hide))
3449 (goto-char start) 3529 ;; *Note is often used where *note should have been
3450 (skip-syntax-backward " ") 3530 (goto-char start)
3451 (setq other-tag 3531 (skip-syntax-backward " ")
3452 (cond ((memq (char-before) '(nil ?\. ?! ??)) 3532 (setq other-tag
3453 "See ") 3533 (cond ((memq (char-before) '(nil ?\. ?! ??))
3454 ((memq (char-before) '(?\, ?\; ?\: ?-)) 3534 "See ")
3455 "see ") 3535 ((memq (char-before) '(?\, ?\; ?\: ?-))
3456 ((memq (char-before) '(?\( ?\[ ?\{)) 3536 "see ")
3457 ;; Check whether the paren is preceded by 3537 ((memq (char-before) '(?\( ?\[ ?\{))
3458 ;; an end of sentence 3538 ;; Check whether the paren is preceded by
3459 (skip-syntax-backward " (") 3539 ;; an end of sentence
3460 (if (memq (char-before) '(nil ?\. ?! ??)) 3540 (skip-syntax-backward " (")
3461 "See " 3541 (if (memq (char-before) '(nil ?\. ?! ??))
3462 "see ")) 3542 "See "
3463 ((save-match-data (looking-at "\n\n")) 3543 "see "))
3464 "See "))) 3544 ((save-match-data (looking-at "\n\n"))
3545 "See "))))
3465 (goto-char next) 3546 (goto-char next)
3466 (add-text-properties 3547 (add-text-properties
3467 (match-beginning 1) 3548 (match-beginning 1)
@@ -3471,7 +3552,7 @@ Preserve text properties."
3471 (if (string-match "\n" (match-string 1)) 3552 (if (string-match "\n" (match-string 1))
3472 (+ start1 (match-beginning 0))))) 3553 (+ start1 (match-beginning 0)))))
3473 (match-end 1)) 3554 (match-end 1))
3474 (if (and other-tag (not (eq Info-hide-note-references 'hide))) 3555 (if other-tag
3475 `(display ,other-tag front-sticky nil rear-nonsticky t) 3556 `(display ,other-tag front-sticky nil rear-nonsticky t)
3476 '(invisible t front-sticky nil rear-nonsticky t)))) 3557 '(invisible t front-sticky nil rear-nonsticky t))))
3477 (add-text-properties 3558 (add-text-properties
diff --git a/lisp/isearch.el b/lisp/isearch.el
index ad6f6b21ebc..63cbb07dcf9 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -57,47 +57,6 @@
57;; keep the behavior. No point in forcing nonincremental search until 57;; keep the behavior. No point in forcing nonincremental search until
58;; the last possible moment. 58;; the last possible moment.
59 59
60;; TODO
61;; - Integrate the emacs 19 generalized command history.
62;; - Hooks and options for failed search.
63
64;;; Change Log:
65
66;; Changes before those recorded in ChangeLog:
67
68;; Revision 1.4 92/09/14 16:26:02 liberte
69;; Added prefix args to isearch-forward, etc. to switch between
70;; string and regular expression searching.
71;; Added some support for lemacs.
72;; Added general isearch-highlight option - but only for lemacs so far.
73;; Added support for frame switching in emacs 19.
74;; Added word search option to isearch-edit-string.
75;; Renamed isearch-quit to isearch-abort.
76;; Numerous changes to comments and doc strings.
77;;
78;; Revision 1.3 92/06/29 13:10:08 liberte
79;; Moved modal isearch-mode handling into isearch-mode.
80;; Got rid of buffer-local isearch variables.
81;; isearch-edit-string used by ring adjustments, completion, and
82;; nonincremental searching. C-s and C-r are additional exit commands.
83;; Renamed all regex to regexp.
84;; Got rid of found-start and found-point globals.
85;; Generalized handling of upper-case chars.
86
87;; Revision 1.2 92/05/27 11:33:57 liberte
88;; Emacs version 19 has a search ring, which is supported here.
89;; Other fixes found in the version 19 isearch are included here.
90;;
91;; Also see variables search-caps-disable-folding,
92;; search-nonincremental-instead, search-whitespace-regexp, and
93;; commands isearch-toggle-regexp, isearch-edit-string.
94;;
95;; semi-modal isearching is supported.
96
97;; Changes for 1.1
98;; 3/18/92 Fixed invalid-regexp.
99;; 3/18/92 Fixed yanking in regexps.
100
101;;; Code: 60;;; Code:
102 61
103 62
@@ -198,6 +157,15 @@ Ordinarily the text becomes invisible again at the end of the search."
198(defvar isearch-mode-end-hook nil 157(defvar isearch-mode-end-hook nil
199 "Function(s) to call after terminating an incremental search.") 158 "Function(s) to call after terminating an incremental search.")
200 159
160(defvar isearch-wrap-function nil
161 "Function to call to wrap the search when search is failed.
162If nil, move point to the beginning of the buffer for a forward search,
163or to the end of the buffer for a backward search.")
164
165(defvar isearch-push-state-function nil
166 "Function to save a function restoring the mode-specific isearch state
167to the search status stack.")
168
201;; Search ring. 169;; Search ring.
202 170
203(defvar search-ring nil 171(defvar search-ring nil
@@ -772,57 +740,62 @@ REGEXP says which ring to use."
772 740
773;; The search status structure and stack. 741;; The search status structure and stack.
774 742
775(defsubst isearch-string (frame) 743(defsubst isearch-string-state (frame)
776 "Return the search string in FRAME." 744 "Return the search string in FRAME."
777 (aref frame 0)) 745 (aref frame 0))
778(defsubst isearch-message-string (frame) 746(defsubst isearch-message-state (frame)
779 "Return the search string to display to the user in FRAME." 747 "Return the search string to display to the user in FRAME."
780 (aref frame 1)) 748 (aref frame 1))
781(defsubst isearch-point (frame) 749(defsubst isearch-point-state (frame)
782 "Return the point in FRAME." 750 "Return the point in FRAME."
783 (aref frame 2)) 751 (aref frame 2))
784(defsubst isearch-success (frame) 752(defsubst isearch-success-state (frame)
785 "Return the success flag in FRAME." 753 "Return the success flag in FRAME."
786 (aref frame 3)) 754 (aref frame 3))
787(defsubst isearch-forward-flag (frame) 755(defsubst isearch-forward-state (frame)
788 "Return the searching-forward flag in FRAME." 756 "Return the searching-forward flag in FRAME."
789 (aref frame 4)) 757 (aref frame 4))
790(defsubst isearch-other-end (frame) 758(defsubst isearch-other-end-state (frame)
791 "Return the other end of the match in FRAME." 759 "Return the other end of the match in FRAME."
792 (aref frame 5)) 760 (aref frame 5))
793(defsubst isearch-word (frame) 761(defsubst isearch-word-state (frame)
794 "Return the search-by-word flag in FRAME." 762 "Return the search-by-word flag in FRAME."
795 (aref frame 6)) 763 (aref frame 6))
796(defsubst isearch-invalid-regexp (frame) 764(defsubst isearch-invalid-regexp-state (frame)
797 "Return the regexp error message in FRAME, or nil if its regexp is valid." 765 "Return the regexp error message in FRAME, or nil if its regexp is valid."
798 (aref frame 7)) 766 (aref frame 7))
799(defsubst isearch-wrapped (frame) 767(defsubst isearch-wrapped-state (frame)
800 "Return the search-wrapped flag in FRAME." 768 "Return the search-wrapped flag in FRAME."
801 (aref frame 8)) 769 (aref frame 8))
802(defsubst isearch-barrier (frame) 770(defsubst isearch-barrier-state (frame)
803 "Return the barrier value in FRAME." 771 "Return the barrier value in FRAME."
804 (aref frame 9)) 772 (aref frame 9))
805(defsubst isearch-within-brackets (frame) 773(defsubst isearch-within-brackets-state (frame)
806 "Return the in-character-class flag in FRAME." 774 "Return the in-character-class flag in FRAME."
807 (aref frame 10)) 775 (aref frame 10))
808(defsubst isearch-case-fold-search (frame) 776(defsubst isearch-case-fold-search-state (frame)
809 "Return the case-folding flag in FRAME." 777 "Return the case-folding flag in FRAME."
810 (aref frame 11)) 778 (aref frame 11))
779(defsubst isearch-pop-fun-state (frame)
780 "Return the function restoring the mode-specific isearch state in FRAME."
781 (aref frame 12))
811 782
812(defun isearch-top-state () 783(defun isearch-top-state ()
813 (let ((cmd (car isearch-cmds))) 784 (let ((cmd (car isearch-cmds)))
814 (setq isearch-string (isearch-string cmd) 785 (setq isearch-string (isearch-string-state cmd)
815 isearch-message (isearch-message-string cmd) 786 isearch-message (isearch-message-state cmd)
816 isearch-success (isearch-success cmd) 787 isearch-success (isearch-success-state cmd)
817 isearch-forward (isearch-forward-flag cmd) 788 isearch-forward (isearch-forward-state cmd)
818 isearch-other-end (isearch-other-end cmd) 789 isearch-other-end (isearch-other-end-state cmd)
819 isearch-word (isearch-word cmd) 790 isearch-word (isearch-word-state cmd)
820 isearch-invalid-regexp (isearch-invalid-regexp cmd) 791 isearch-invalid-regexp (isearch-invalid-regexp-state cmd)
821 isearch-wrapped (isearch-wrapped cmd) 792 isearch-wrapped (isearch-wrapped-state cmd)
822 isearch-barrier (isearch-barrier cmd) 793 isearch-barrier (isearch-barrier-state cmd)
823 isearch-within-brackets (isearch-within-brackets cmd) 794 isearch-within-brackets (isearch-within-brackets-state cmd)
824 isearch-case-fold-search (isearch-case-fold-search cmd)) 795 isearch-case-fold-search (isearch-case-fold-search-state cmd))
825 (goto-char (isearch-point cmd)))) 796 (if (functionp (isearch-pop-fun-state cmd))
797 (funcall (isearch-pop-fun-state cmd) cmd))
798 (goto-char (isearch-point-state cmd))))
826 799
827(defun isearch-pop-state () 800(defun isearch-pop-state ()
828 (setq isearch-cmds (cdr isearch-cmds)) 801 (setq isearch-cmds (cdr isearch-cmds))
@@ -834,7 +807,9 @@ REGEXP says which ring to use."
834 isearch-success isearch-forward isearch-other-end 807 isearch-success isearch-forward isearch-other-end
835 isearch-word 808 isearch-word
836 isearch-invalid-regexp isearch-wrapped isearch-barrier 809 isearch-invalid-regexp isearch-wrapped isearch-barrier
837 isearch-within-brackets isearch-case-fold-search) 810 isearch-within-brackets isearch-case-fold-search
811 (if isearch-push-state-function
812 (funcall isearch-push-state-function)))
838 isearch-cmds))) 813 isearch-cmds)))
839 814
840 815
@@ -1020,10 +995,13 @@ If first char entered is \\[isearch-yank-word-or-char], then do word search inst
1020(defun isearch-cancel () 995(defun isearch-cancel ()
1021 "Terminate the search and go back to the starting point." 996 "Terminate the search and go back to the starting point."
1022 (interactive) 997 (interactive)
998 (if (functionp (isearch-pop-fun-state (car (last isearch-cmds))))
999 (funcall (isearch-pop-fun-state (car (last isearch-cmds)))
1000 (car (last isearch-cmds))))
1023 (goto-char isearch-opoint) 1001 (goto-char isearch-opoint)
1024 (isearch-done t) 1002 (isearch-done t) ; exit isearch
1025 (isearch-clean-overlays) 1003 (isearch-clean-overlays)
1026 (signal 'quit nil)) ; and pass on quit signal 1004 (signal 'quit nil)) ; and pass on quit signal
1027 1005
1028(defun isearch-abort () 1006(defun isearch-abort ()
1029 "Abort incremental search mode if searching is successful, signaling quit. 1007 "Abort incremental search mode if searching is successful, signaling quit.
@@ -1035,11 +1013,9 @@ Use `isearch-exit' to quit without signaling."
1035 (if isearch-success 1013 (if isearch-success
1036 ;; If search is successful, move back to starting point 1014 ;; If search is successful, move back to starting point
1037 ;; and really do quit. 1015 ;; and really do quit.
1038 (progn (goto-char isearch-opoint) 1016 (progn
1039 (setq isearch-success nil) 1017 (setq isearch-success nil)
1040 (isearch-done t) ; exit isearch 1018 (isearch-cancel))
1041 (isearch-clean-overlays)
1042 (signal 'quit nil)) ; and pass on quit signal
1043 ;; If search is failing, or has an incomplete regexp, 1019 ;; If search is failing, or has an incomplete regexp,
1044 ;; rub out until it is once more successful. 1020 ;; rub out until it is once more successful.
1045 (while (or (not isearch-success) isearch-invalid-regexp) 1021 (while (or (not isearch-success) isearch-invalid-regexp)
@@ -1064,7 +1040,9 @@ Use `isearch-exit' to quit without signaling."
1064 ;; If already have what to search for, repeat it. 1040 ;; If already have what to search for, repeat it.
1065 (or isearch-success 1041 (or isearch-success
1066 (progn 1042 (progn
1067 (goto-char (if isearch-forward (point-min) (point-max))) 1043 (if isearch-wrap-function
1044 (funcall isearch-wrap-function)
1045 (goto-char (if isearch-forward (point-min) (point-max))))
1068 (setq isearch-wrapped t)))) 1046 (setq isearch-wrapped t))))
1069 ;; C-s in reverse or C-r in forward, change direction. 1047 ;; C-s in reverse or C-r in forward, change direction.
1070 (setq isearch-forward (not isearch-forward))) 1048 (setq isearch-forward (not isearch-forward)))
@@ -1106,6 +1084,7 @@ Use `isearch-exit' to quit without signaling."
1106 (interactive) 1084 (interactive)
1107 (setq isearch-regexp (not isearch-regexp)) 1085 (setq isearch-regexp (not isearch-regexp))
1108 (if isearch-regexp (setq isearch-word nil)) 1086 (if isearch-regexp (setq isearch-word nil))
1087 (setq isearch-success t isearch-adjusted t)
1109 (isearch-update)) 1088 (isearch-update))
1110 1089
1111(defun isearch-toggle-case-fold () 1090(defun isearch-toggle-case-fold ()
@@ -1118,34 +1097,39 @@ Use `isearch-exit' to quit without signaling."
1118 (isearch-message-prefix nil nil isearch-nonincremental) 1097 (isearch-message-prefix nil nil isearch-nonincremental)
1119 isearch-message 1098 isearch-message
1120 (if isearch-case-fold-search "in" ""))) 1099 (if isearch-case-fold-search "in" "")))
1121 (setq isearch-adjusted t) 1100 (setq isearch-success t isearch-adjusted t)
1122 (sit-for 1) 1101 (sit-for 1)
1123 (isearch-update)) 1102 (isearch-update))
1124 1103
1125(defun isearch-query-replace () 1104(defun isearch-query-replace (&optional regexp-flag)
1126 "Start query-replace with string to replace from last search string." 1105 "Start query-replace with string to replace from last search string."
1127 (interactive) 1106 (interactive)
1128 (barf-if-buffer-read-only) 1107 (barf-if-buffer-read-only)
1108 (if regexp-flag (setq isearch-regexp t))
1129 (let ((case-fold-search isearch-case-fold-search)) 1109 (let ((case-fold-search isearch-case-fold-search))
1130 (isearch-done) 1110 (isearch-done)
1131 (isearch-clean-overlays) 1111 (isearch-clean-overlays)
1132 (and isearch-forward isearch-other-end (goto-char isearch-other-end)) 1112 (if (and (< isearch-other-end (point))
1113 (not (and transient-mark-mode mark-active
1114 (< isearch-opoint (point)))))
1115 (goto-char isearch-other-end))
1116 (set query-replace-from-history-variable
1117 (cons isearch-string
1118 (symbol-value query-replace-from-history-variable)))
1133 (perform-replace 1119 (perform-replace
1134 isearch-string 1120 isearch-string
1135 (query-replace-read-to isearch-string "Query replace" isearch-regexp) 1121 (query-replace-read-to
1136 t isearch-regexp isearch-word))) 1122 isearch-string
1123 (if isearch-regexp "Query replace regexp" "Query replace")
1124 isearch-regexp)
1125 t isearch-regexp isearch-word nil nil
1126 (if (and transient-mark-mode mark-active) (region-beginning))
1127 (if (and transient-mark-mode mark-active) (region-end)))))
1137 1128
1138(defun isearch-query-replace-regexp () 1129(defun isearch-query-replace-regexp ()
1139 "Start query-replace-regexp with string to replace from last search string." 1130 "Start query-replace-regexp with string to replace from last search string."
1140 (interactive) 1131 (interactive)
1141 (let ((query-replace-interactive t) 1132 (isearch-query-replace t))
1142 (case-fold-search isearch-case-fold-search))
1143 ;; Put search string into the right ring
1144 (setq isearch-regexp t)
1145 (isearch-done)
1146 (isearch-clean-overlays)
1147 (and isearch-forward isearch-other-end (goto-char isearch-other-end))
1148 (call-interactively 'query-replace-regexp)))
1149 1133
1150 1134
1151(defun isearch-delete-char () 1135(defun isearch-delete-char ()
@@ -1343,7 +1327,7 @@ barrier."
1343 ;; We have to check 2 stack frames because the last might be 1327 ;; We have to check 2 stack frames because the last might be
1344 ;; invalid just because of a backslash. 1328 ;; invalid just because of a backslash.
1345 (or (not isearch-invalid-regexp) 1329 (or (not isearch-invalid-regexp)
1346 (not (isearch-invalid-regexp (cadr isearch-cmds))) 1330 (not (isearch-invalid-regexp-state (cadr isearch-cmds)))
1347 allow-invalid)) 1331 allow-invalid))
1348 (if to-barrier 1332 (if to-barrier
1349 (progn (goto-char isearch-barrier) 1333 (progn (goto-char isearch-barrier)
@@ -1358,8 +1342,8 @@ barrier."
1358 ;; Also skip over postfix operators -- though horrid, 1342 ;; Also skip over postfix operators -- though horrid,
1359 ;; 'ab?\{5,6\}+\{1,2\}*' is perfectly legal. 1343 ;; 'ab?\{5,6\}+\{1,2\}*' is perfectly legal.
1360 (while (and previous 1344 (while (and previous
1361 (or (isearch-invalid-regexp frame) 1345 (or (isearch-invalid-regexp-state frame)
1362 (let* ((string (isearch-string frame)) 1346 (let* ((string (isearch-string-state frame))
1363 (lchar (aref string (1- (length string))))) 1347 (lchar (aref string (1- (length string)))))
1364 ;; The operators aren't always operators; check 1348 ;; The operators aren't always operators; check
1365 ;; backslashes. This doesn't handle the case of 1349 ;; backslashes. This doesn't handle the case of
@@ -1367,7 +1351,7 @@ barrier."
1367 ;; being special, but then we should fall back to 1351 ;; being special, but then we should fall back to
1368 ;; the barrier anyway because it's all optional. 1352 ;; the barrier anyway because it's all optional.
1369 (if (isearch-backslash 1353 (if (isearch-backslash
1370 (isearch-string (car previous))) 1354 (isearch-string-state (car previous)))
1371 (eq lchar ?\}) 1355 (eq lchar ?\})
1372 (memq lchar '(?* ?? ?+)))))) 1356 (memq lchar '(?* ?? ?+))))))
1373 (setq stack previous previous (cdr previous) frame (car stack))) 1357 (setq stack previous previous (cdr previous) frame (car stack)))
@@ -1375,7 +1359,7 @@ barrier."
1375 ;; `stack' now refers the most recent valid regexp that is not at 1359 ;; `stack' now refers the most recent valid regexp that is not at
1376 ;; all optional in its last term. Now dig one level deeper and find 1360 ;; all optional in its last term. Now dig one level deeper and find
1377 ;; what matched before that. 1361 ;; what matched before that.
1378 (let ((last-other-end (or (isearch-other-end (car previous)) 1362 (let ((last-other-end (or (isearch-other-end-state (car previous))
1379 isearch-barrier))) 1363 isearch-barrier)))
1380 (goto-char (if isearch-forward 1364 (goto-char (if isearch-forward
1381 (max last-other-end isearch-barrier) 1365 (max last-other-end isearch-barrier)
@@ -1638,8 +1622,7 @@ Isearch mode."
1638 (let ((ab-bel (isearch-string-out-of-window isearch-point))) 1622 (let ((ab-bel (isearch-string-out-of-window isearch-point)))
1639 (if ab-bel 1623 (if ab-bel
1640 (isearch-back-into-window (eq ab-bel 'above) isearch-point) 1624 (isearch-back-into-window (eq ab-bel 'above) isearch-point)
1641 (or (eq (point) isearch-point) 1625 (goto-char isearch-point)))
1642 (goto-char isearch-point))))
1643 (isearch-update)) 1626 (isearch-update))
1644 (search-exit-option 1627 (search-exit-option
1645 (let (window) 1628 (let (window)
@@ -1913,7 +1896,9 @@ If there is no completion possible, say so and continue searching."
1913 ;; If currently failing, display no ellipsis. 1896 ;; If currently failing, display no ellipsis.
1914 (or isearch-success (setq ellipsis nil)) 1897 (or isearch-success (setq ellipsis nil))
1915 (let ((m (concat (if isearch-success "" "failing ") 1898 (let ((m (concat (if isearch-success "" "failing ")
1899 (if isearch-adjusted "pending " "")
1916 (if (and isearch-wrapped 1900 (if (and isearch-wrapped
1901 (not isearch-wrap-function)
1917 (if isearch-forward 1902 (if isearch-forward
1918 (> (point) isearch-opoint) 1903 (> (point) isearch-opoint)
1919 (< (point) isearch-opoint))) 1904 (< (point) isearch-opoint)))
@@ -2008,9 +1993,11 @@ Can be changed via `isearch-search-fun-function' for special needs."
2008 (if isearch-success 1993 (if isearch-success
2009 nil 1994 nil
2010 ;; Ding if failed this time after succeeding last time. 1995 ;; Ding if failed this time after succeeding last time.
2011 (and (isearch-success (car isearch-cmds)) 1996 (and (isearch-success-state (car isearch-cmds))
2012 (ding)) 1997 (ding))
2013 (goto-char (isearch-point (car isearch-cmds))))) 1998 (if (functionp (isearch-pop-fun-state (car isearch-cmds)))
1999 (funcall (isearch-pop-fun-state (car isearch-cmds)) (car isearch-cmds)))
2000 (goto-char (isearch-point-state (car isearch-cmds)))))
2014 2001
2015 2002
2016;; Called when opening an overlay, and we are still in isearch. 2003;; Called when opening an overlay, and we are still in isearch.
diff --git a/lisp/macros.el b/lisp/macros.el
index 72ba3f11721..0de5d223ee0 100644
--- a/lisp/macros.el
+++ b/lisp/macros.el
@@ -1,6 +1,6 @@
1;;; macros.el --- non-primitive commands for keyboard macros 1;;; macros.el --- non-primitive commands for keyboard macros
2 2
3;; Copyright (C) 1985, 86, 87, 92, 94, 95 Free Software Foundation, Inc. 3;; Copyright (C) 1985, 86, 87, 92, 94, 95, 04 Free Software Foundation, Inc.
4 4
5;; Maintainer: FSF 5;; Maintainer: FSF
6;; Keywords: abbrev 6;; Keywords: abbrev
@@ -151,7 +151,7 @@ use this command, and then save the file."
151 (cond ((= char ?\\) 151 (cond ((= char ?\\)
152 (insert "\\\\")) 152 (insert "\\\\"))
153 ((= char ?\") 153 ((= char ?\")
154 (insert "\\\"")) 154 (insert "\\\""))
155 ((= char ?\;) 155 ((= char ?\;)
156 (insert "\\;")) 156 (insert "\\;"))
157 ((= char 127) 157 ((= char 127)
@@ -240,8 +240,9 @@ Possibilities: \\<query-replace-map>
240 240
241;;;###autoload 241;;;###autoload
242(defun apply-macro-to-region-lines (top bottom &optional macro) 242(defun apply-macro-to-region-lines (top bottom &optional macro)
243 "For each complete line between point and mark, move to the beginning 243 "Apply last keyboard macro to all lines in the region.
244of the line, and run the last keyboard macro. 244For each line that begins in the region, move to the beginning of
245the line, and run the last keyboard macro.
245 246
246When called from lisp, this function takes two arguments TOP and 247When called from lisp, this function takes two arguments TOP and
247BOTTOM, describing the current region. TOP must be before BOTTOM. 248BOTTOM, describing the current region. TOP must be before BOTTOM.
@@ -277,8 +278,7 @@ and write a macro to massage a word into a table entry:
277 \\C-x ) 278 \\C-x )
278 279
279and then select the region of un-tablified names and use 280and then select the region of un-tablified names and use
280`\\[apply-macro-to-region-lines]' to build the table from the names. 281`\\[apply-macro-to-region-lines]' to build the table from the names."
281"
282 (interactive "r") 282 (interactive "r")
283 (or macro 283 (or macro
284 (progn 284 (progn
@@ -286,10 +286,7 @@ and then select the region of un-tablified names and use
286 (error "No keyboard macro has been defined")) 286 (error "No keyboard macro has been defined"))
287 (setq macro last-kbd-macro))) 287 (setq macro last-kbd-macro)))
288 (save-excursion 288 (save-excursion
289 (let ((end-marker (progn 289 (let ((end-marker (copy-marker bottom))
290 (goto-char bottom)
291 (beginning-of-line)
292 (point-marker)))
293 next-line-marker) 290 next-line-marker)
294 (goto-char top) 291 (goto-char top)
295 (if (not (bolp)) 292 (if (not (bolp))
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 32fa246b9f6..ea174233289 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -458,9 +458,9 @@ starting the compilation process.")
458 :version "21.4") 458 :version "21.4")
459 459
460(defface compilation-info-face 460(defface compilation-info-face
461 '((((class color) (min-colors 16) (background light)) 461 '((((class color) (min-colors 16) (background light))
462 (:foreground "Green3" :weight bold)) 462 (:foreground "Green3" :weight bold))
463 (((class color) (min-colors 16) (background dark)) 463 (((class color) (min-colors 16) (background dark))
464 (:foreground "Green" :weight bold)) 464 (:foreground "Green" :weight bold))
465 (((class color)) (:foreground "green" :weight bold)) 465 (((class color)) (:foreground "green" :weight bold))
466 (t (:weight bold))) 466 (t (:weight bold)))
@@ -579,12 +579,17 @@ Faces `compilation-error-face', `compilation-warning-face',
579 (and end-line 579 (and end-line
580 (setq end-line (match-string-no-properties end-line)) 580 (setq end-line (match-string-no-properties end-line))
581 (setq end-line (string-to-number end-line))) 581 (setq end-line (string-to-number end-line)))
582 (and col 582 (if col
583 (setq col (match-string-no-properties col)) 583 (if (functionp col)
584 (setq col (- (string-to-number col) compilation-first-column))) 584 (setq col (funcall col))
585 (if (and end-col (setq end-col (match-string-no-properties end-col))) 585 (and
586 (setq end-col (- (string-to-number end-col) compilation-first-column -1)) 586 (setq col (match-string-no-properties col))
587 (if end-line (setq end-col -1))) 587 (setq col (- (string-to-number col) compilation-first-column)))))
588 (if (and end-col (functionp end-col))
589 (setq end-col (funcall end-col))
590 (if (and end-col (setq end-col (match-string-no-properties end-col)))
591 (setq end-col (- (string-to-number end-col) compilation-first-column -1))
592 (if end-line (setq end-col -1))))
588 (if (consp type) ; not a static type, check what it is. 593 (if (consp type) ; not a static type, check what it is.
589 (setq type (or (and (car type) (match-end (car type)) 1) 594 (setq type (or (and (car type) (match-end (car type)) 1)
590 (and (cdr type) (match-end (cdr type)) 0) 595 (and (cdr type) (match-end (cdr type)) 0)
@@ -726,9 +731,9 @@ FILE should be (ABSOLUTE-FILENAME) or (RELATIVE-FILENAME . DIRNAME) or nil."
726 ,@(when end-line 731 ,@(when end-line
727 `((,end-line compilation-line-face nil t))) 732 `((,end-line compilation-line-face nil t)))
728 733
729 ,@(when col 734 ,@(when (integerp col)
730 `((,col compilation-column-face nil t))) 735 `((,col compilation-column-face nil t)))
731 ,@(when end-col 736 ,@(when (integerp end-col)
732 `((,end-col compilation-column-face nil t))) 737 `((,end-col compilation-column-face nil t)))
733 738
734 ,@(nthcdr 6 item) 739 ,@(nthcdr 6 item)
@@ -789,7 +794,10 @@ If this is run in a Compilation mode buffer, re-use the arguments from the
789original use. Otherwise, recompile using `compile-command'." 794original use. Otherwise, recompile using `compile-command'."
790 (interactive) 795 (interactive)
791 (save-some-buffers (not compilation-ask-about-save) nil) 796 (save-some-buffers (not compilation-ask-about-save) nil)
792 (let ((default-directory (or compilation-directory default-directory))) 797 (let ((default-directory
798 (or (and (not (eq major-mode (nth 1 compilation-arguments)))
799 compilation-directory)
800 default-directory)))
793 (apply 'compilation-start (or compilation-arguments 801 (apply 'compilation-start (or compilation-arguments
794 `(,(eval compile-command)))))) 802 `(,(eval compile-command))))))
795 803
@@ -816,8 +824,7 @@ Otherwise, construct a buffer name from MODE-NAME."
816 (funcall name-function mode-name)) 824 (funcall name-function mode-name))
817 (compilation-buffer-name-function 825 (compilation-buffer-name-function
818 (funcall compilation-buffer-name-function mode-name)) 826 (funcall compilation-buffer-name-function mode-name))
819 ((and (eq major-mode 'compilation-mode) 827 ((eq major-mode (nth 1 compilation-arguments))
820 (equal mode-name (nth 2 compilation-arguments)))
821 (buffer-name)) 828 (buffer-name))
822 (t 829 (t
823 (concat "*" (downcase mode-name) "*")))) 830 (concat "*" (downcase mode-name) "*"))))
@@ -1522,7 +1529,8 @@ If nil, don't scroll the compilation output window."
1522 1529
1523(defun compilation-goto-locus (msg mk end-mk) 1530(defun compilation-goto-locus (msg mk end-mk)
1524 "Jump to an error corresponding to MSG at MK. 1531 "Jump to an error corresponding to MSG at MK.
1525All arguments are markers. If END-MK is non nil, mark is set there." 1532All arguments are markers. If END-MK is non-nil, mark is set there
1533and overlay is highlighted between MK and END-MK."
1526 (if (eq (window-buffer (selected-window)) 1534 (if (eq (window-buffer (selected-window))
1527 (marker-buffer msg)) 1535 (marker-buffer msg))
1528 ;; If the compilation buffer window is selected, 1536 ;; If the compilation buffer window is selected,
@@ -1538,7 +1546,7 @@ All arguments are markers. If END-MK is non nil, mark is set there."
1538 (widen) 1546 (widen)
1539 (goto-char mk)) 1547 (goto-char mk))
1540 (if end-mk 1548 (if end-mk
1541 (push-mark end-mk nil t) 1549 (push-mark end-mk t)
1542 (if mark-active (setq mark-active))) 1550 (if mark-active (setq mark-active)))
1543 ;; If hideshow got in the way of 1551 ;; If hideshow got in the way of
1544 ;; seeing the right place, open permanently. 1552 ;; seeing the right place, open permanently.
@@ -1559,26 +1567,32 @@ All arguments are markers. If END-MK is non nil, mark is set there."
1559 compilation-highlight-regexp))) 1567 compilation-highlight-regexp)))
1560 (compilation-set-window-height w) 1568 (compilation-set-window-height w)
1561 1569
1562 (when (and highlight-regexp 1570 (when highlight-regexp
1563 (not (and end-mk transient-mark-mode)))
1564 (unless compilation-highlight-overlay 1571 (unless compilation-highlight-overlay
1565 (setq compilation-highlight-overlay 1572 (setq compilation-highlight-overlay
1566 (make-overlay (point-min) (point-min))) 1573 (make-overlay (point-min) (point-min)))
1567 (overlay-put compilation-highlight-overlay 'face 'region)) 1574 (overlay-put compilation-highlight-overlay 'face 'next-error))
1568 (with-current-buffer (marker-buffer mk) 1575 (with-current-buffer (marker-buffer mk)
1569 (save-excursion 1576 (save-excursion
1570 (end-of-line) 1577 (if end-mk (goto-char end-mk) (end-of-line))
1571 (let ((end (point))) 1578 (let ((end (point)))
1572 (beginning-of-line) 1579 (if mk (goto-char mk) (beginning-of-line))
1573 (if (and (stringp highlight-regexp) 1580 (if (and (stringp highlight-regexp)
1574 (re-search-forward highlight-regexp end t)) 1581 (re-search-forward highlight-regexp end t))
1575 (progn 1582 (progn
1576 (goto-char (match-beginning 0)) 1583 (goto-char (match-beginning 0))
1577 (move-overlay compilation-highlight-overlay (match-beginning 0) (match-end 0))) 1584 (move-overlay compilation-highlight-overlay
1578 (move-overlay compilation-highlight-overlay (point) end)) 1585 (match-beginning 0) (match-end 0)
1579 (sit-for 0.5) 1586 (current-buffer)))
1580 (delete-overlay compilation-highlight-overlay))))))) 1587 (move-overlay compilation-highlight-overlay
1581 1588 (point) end (current-buffer)))
1589 (if (numberp next-error-highlight)
1590 (sit-for next-error-highlight))
1591 (if (not (eq next-error-highlight t))
1592 (delete-overlay compilation-highlight-overlay))))))
1593 (when (and (eq next-error-highlight 'fringe-arrow))
1594 (set (make-local-variable 'overlay-arrow-position)
1595 (copy-marker (line-beginning-position))))))
1582 1596
1583(defun compilation-find-file (marker filename dir &rest formats) 1597(defun compilation-find-file (marker filename dir &rest formats)
1584 "Find a buffer for file FILENAME. 1598 "Find a buffer for file FILENAME.
diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index 4464df3a916..ddbd2ce6f35 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -772,26 +772,6 @@ Assumes the tags table is the current buffer."
772 (all-completions string (tags-completion-table) predicate) 772 (all-completions string (tags-completion-table) predicate)
773 (try-completion string (tags-completion-table) predicate)))) 773 (try-completion string (tags-completion-table) predicate))))
774 774
775;; Return a default tag to search for, based on the text at point.
776(defun find-tag-default ()
777 (save-excursion
778 (while (looking-at "\\sw\\|\\s_")
779 (forward-char 1))
780 (if (or (re-search-backward "\\sw\\|\\s_"
781 (save-excursion (beginning-of-line) (point))
782 t)
783 (re-search-forward "\\(\\sw\\|\\s_\\)+"
784 (save-excursion (end-of-line) (point))
785 t))
786 (progn (goto-char (match-end 0))
787 (buffer-substring-no-properties
788 (point)
789 (progn (forward-sexp -1)
790 (while (looking-at "\\s'")
791 (forward-char 1))
792 (point))))
793 nil)))
794
795;; Read a tag name from the minibuffer with defaulting and completion. 775;; Read a tag name from the minibuffer with defaulting and completion.
796(defun find-tag-tag (string) 776(defun find-tag-tag (string)
797 (let* ((completion-ignore-case (if (memq tags-case-fold-search '(t nil)) 777 (let* ((completion-ignore-case (if (memq tags-case-fold-search '(t nil))
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 5b678f26171..9d48fd37569 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -64,6 +64,21 @@ will be parsed and highlighted as soon as you try to move to them."
64 :version "21.4" 64 :version "21.4"
65 :group 'grep) 65 :group 'grep)
66 66
67(defcustom grep-highlight-matches t
68 "*Non-nil to use special markers to highlight grep matches.
69
70Some grep programs are able to surround matches with special
71markers in grep output. Such markers can be used to highlight
72matches in grep mode.
73
74This option sets the environment variable GREP_COLOR to specify
75markers for highlighting and GREP_OPTIONS to add the --color
76option in front of any explicit grep options before starting
77the grep."
78 :type 'boolean
79 :version "21.4"
80 :group 'grep)
81
67(defcustom grep-scroll-output nil 82(defcustom grep-scroll-output nil
68 "*Non-nil to scroll the *grep* buffer window as output appears. 83 "*Non-nil to scroll the *grep* buffer window as output appears.
69 84
@@ -230,6 +245,23 @@ Notice that using \\[next-error] or \\[compile-goto-error] modifies
230 '(("^\\(.+?\\)[:( \t]+\ 245 '(("^\\(.+?\\)[:( \t]+\
231\\([0-9]+\\)\\([.:]?\\)\\([0-9]+\\)?\ 246\\([0-9]+\\)\\([.:]?\\)\\([0-9]+\\)?\
232\\(?:-\\(?:\\([0-9]+\\)\\3\\)?\\.?\\([0-9]+\\)?\\)?[:) \t]" 1 (2 . 5) (4 . 6)) 247\\(?:-\\(?:\\([0-9]+\\)\\3\\)?\\.?\\([0-9]+\\)?\\)?[:) \t]" 1 (2 . 5) (4 . 6))
248 ("^\\(.+?\\)[:(]+\\([0-9]+\\)\\([:)]\\).*?\\(\033\\[01;41m\\)\\(.*?\\)\\(\033\\[00m\\)"
249 1 2
250 ((lambda ()
251 (setq compilation-error-screen-columns nil)
252 (- (match-beginning 5) (match-end 3) 8))
253 .
254 (lambda () (- (match-end 5) (match-end 3) 8)))
255 nil nil
256 (4 (list 'face nil 'invisible t 'intangible t))
257 (5 (list 'face compilation-column-face))
258 (6 (list 'face nil 'invisible t 'intangible t))
259 ;; highlight other matches on the same line
260 ("\\(\033\\[01;41m\\)\\(.*?\\)\\(\033\\[00m\\)"
261 nil nil
262 (1 (list 'face nil 'invisible t 'intangible t))
263 (2 (list 'face compilation-column-face) t)
264 (3 (list 'face nil 'invisible t 'intangible t))))
233 ("^Binary file \\(.+\\) matches$" 1 nil nil 1)) 265 ("^Binary file \\(.+\\) matches$" 1 nil nil 1))
234 "Regexp used to match grep hits. See `compilation-error-regexp-alist'.") 266 "Regexp used to match grep hits. See `compilation-error-regexp-alist'.")
235 267
@@ -300,6 +332,10 @@ This variable's value takes effect when `grep-compute-defaults' is called.")
300(defun grep-process-setup () 332(defun grep-process-setup ()
301 "Setup compilation variables and buffer for `grep'. 333 "Setup compilation variables and buffer for `grep'.
302Set up `compilation-exit-message-function' and run `grep-setup-hook'." 334Set up `compilation-exit-message-function' and run `grep-setup-hook'."
335 (when grep-highlight-matches
336 ;; Modify `process-environment' locally bound in `compilation-start'
337 (setenv "GREP_OPTIONS" (concat (getenv "GREP_OPTIONS") " --color=always"))
338 (setenv "GREP_COLOR" "01;41"))
303 (set (make-local-variable 'compilation-exit-message-function) 339 (set (make-local-variable 'compilation-exit-message-function)
304 (lambda (status code msg) 340 (lambda (status code msg)
305 (if (eq status 'exit) 341 (if (eq status 'exit)
@@ -384,9 +420,7 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'."
384 (let ((tag-default 420 (let ((tag-default
385 (funcall (or find-tag-default-function 421 (funcall (or find-tag-default-function
386 (get major-mode 'find-tag-default-function) 422 (get major-mode 'find-tag-default-function)
387 ;; We use grep-tag-default instead of 423 'find-tag-default)))
388 ;; find-tag-default, to avoid loading etags.
389 'grep-tag-default)))
390 (sh-arg-re "\\(\\(?:\"\\(?:[^\"]\\|\\\\\"\\)+\"\\|'[^']+'\\|[^\"' \t\n]\\)+\\)") 424 (sh-arg-re "\\(\\(?:\"\\(?:[^\"]\\|\\\\\"\\)+\"\\|'[^']+'\\|[^\"' \t\n]\\)+\\)")
391 (grep-default (or (car grep-history) grep-command))) 425 (grep-default (or (car grep-history) grep-command)))
392 ;; Replace the thing matching for with that around cursor. 426 ;; Replace the thing matching for with that around cursor.
@@ -457,25 +491,6 @@ temporarily highlight in visited source lines."
457 (set (make-local-variable 'compilation-error-regexp-alist) 491 (set (make-local-variable 'compilation-error-regexp-alist)
458 grep-regexp-alist)) 492 grep-regexp-alist))
459 493
460;; This is a copy of find-tag-default from etags.el.
461;;;###autoload
462(defun grep-tag-default ()
463 (save-excursion
464 (while (looking-at "\\sw\\|\\s_")
465 (forward-char 1))
466 (when (or (re-search-backward "\\sw\\|\\s_"
467 (save-excursion (beginning-of-line) (point))
468 t)
469 (re-search-forward "\\(\\sw\\|\\s_\\)+"
470 (save-excursion (end-of-line) (point))
471 t))
472 (goto-char (match-end 0))
473 (buffer-substring (point)
474 (progn (forward-sexp -1)
475 (while (looking-at "\\s'")
476 (forward-char 1))
477 (point))))))
478
479;;;###autoload 494;;;###autoload
480(defun grep-find (command-args) 495(defun grep-find (command-args)
481 "Run grep via find, with user-specified args COMMAND-ARGS. 496 "Run grep via find, with user-specified args COMMAND-ARGS.
diff --git a/lisp/simple.el b/lisp/simple.el
index 325fbd8e702..be50da39474 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -65,7 +65,7 @@
65 (setq found buffer))) 65 (setq found buffer)))
66 (setq list (cdr list))) 66 (setq list (cdr list)))
67 (switch-to-buffer found))) 67 (switch-to-buffer found)))
68 68
69;;; next-error support framework 69;;; next-error support framework
70(defvar next-error-last-buffer nil 70(defvar next-error-last-buffer nil
71 "The most recent next-error buffer. 71 "The most recent next-error buffer.
@@ -91,51 +91,50 @@ to navigate in it.")
91 (or (and extra-test (funcall extra-test)) 91 (or (and extra-test (funcall extra-test))
92 next-error-function))) 92 next-error-function)))
93 93
94;; Return a next-error capable buffer according to the following rules:
95;; 1. If the current buffer is a next-error capable buffer, return it.
96;; 2. If one window on the selected frame displays such buffer, return it.
97;; 3. If next-error-last-buffer is set to a live buffer, use that.
98;; 4. Otherwise, look for a next-error capable buffer in a buffer list.
99;; 5. Signal an error if there are none.
100(defun next-error-find-buffer (&optional other-buffer extra-test) 94(defun next-error-find-buffer (&optional other-buffer extra-test)
101 (if (and (not other-buffer) 95 "Return a next-error capable buffer."
102 (next-error-buffer-p (current-buffer) extra-test)) 96 (or
103 ;; The current buffer is a next-error capable buffer. 97 ;; 1. If one window on the selected frame displays such buffer, return it.
104 (current-buffer) 98 (let ((window-buffers
105 (or 99 (delete-dups
106 (let ((window-buffers 100 (delq nil (mapcar (lambda (w)
107 (delete-dups 101 (if (next-error-buffer-p
108 (delq nil 102 (window-buffer w) extra-test)
109 (mapcar (lambda (w) 103 (window-buffer w)))
110 (and (next-error-buffer-p (window-buffer w) extra-test) 104 (window-list))))))
111 (window-buffer w))) 105 (if other-buffer
112 (window-list)))))) 106 (setq window-buffers (delq (current-buffer) window-buffers)))
113 (if other-buffer 107 (if (eq (length window-buffers) 1)
114 (setq window-buffers (delq (current-buffer) window-buffers))) 108 (car window-buffers)))
115 (if (eq (length window-buffers) 1) 109 ;; 2. If next-error-last-buffer is set to a live buffer, use that.
116 (car window-buffers))) 110 (if (and next-error-last-buffer
117 (if (and next-error-last-buffer (buffer-name next-error-last-buffer) 111 (buffer-name next-error-last-buffer)
118 (next-error-buffer-p next-error-last-buffer extra-test) 112 (next-error-buffer-p next-error-last-buffer extra-test)
119 (or (not other-buffer) (not (eq next-error-last-buffer 113 (or (not other-buffer)
120 (current-buffer))))) 114 (not (eq next-error-last-buffer (current-buffer)))))
121 next-error-last-buffer 115 next-error-last-buffer)
122 (let ((buffers (buffer-list))) 116 ;; 3. If the current buffer is a next-error capable buffer, return it.
123 (while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test)) 117 (if (and (not other-buffer)
124 (and other-buffer 118 (next-error-buffer-p (current-buffer) extra-test))
125 (eq (car buffers) (current-buffer))))) 119 (current-buffer))
126 (setq buffers (cdr buffers))) 120 ;; 4. Look for a next-error capable buffer in a buffer list.
127 (if buffers 121 (let ((buffers (buffer-list)))
128 (car buffers) 122 (while (and buffers
129 (or (and other-buffer 123 (or (not (next-error-buffer-p (car buffers) extra-test))
130 (next-error-buffer-p (current-buffer) extra-test) 124 (and other-buffer (eq (car buffers) (current-buffer)))))
131 ;; The current buffer is a next-error capable buffer. 125 (setq buffers (cdr buffers)))
132 (progn 126 (if buffers
133 (if other-buffer 127 (car buffers)
134 (message "This is the only next-error capable buffer.")) 128 (or (and other-buffer
135 (current-buffer))) 129 (next-error-buffer-p (current-buffer) extra-test)
136 (error "No next-error capable buffer found")))))))) 130 ;; The current buffer is a next-error capable buffer.
137 131 (progn
138(defun next-error (arg &optional reset) 132 (if other-buffer
133 (message "This is the only next-error capable buffer"))
134 (current-buffer)))
135 (error "No next-error capable buffer found"))))))
136
137(defun next-error (&optional arg reset)
139 "Visit next next-error message and corresponding source code. 138 "Visit next next-error message and corresponding source code.
140 139
141If all the error messages parsed so far have been processed already, 140If all the error messages parsed so far have been processed already,
@@ -153,9 +152,10 @@ compilation, grep, or occur buffer. It can also operate on any
153buffer with output from the \\[compile], \\[grep] commands, or, 152buffer with output from the \\[compile], \\[grep] commands, or,
154more generally, on any buffer in Compilation mode or with 153more generally, on any buffer in Compilation mode or with
155Compilation Minor mode enabled, or any buffer in which 154Compilation Minor mode enabled, or any buffer in which
156`next-error-function' is bound to an appropriate 155`next-error-function' is bound to an appropriate function.
157function. To specify use of a particular buffer for error 156To specify use of a particular buffer for error messages, type
158messages, type \\[next-error] in that buffer. 157\\[next-error] in that buffer when it is the only one displayed
158in the current frame.
159 159
160Once \\[next-error] has chosen the buffer for error messages, 160Once \\[next-error] has chosen the buffer for error messages,
161it stays with that buffer until you use it in some other buffer which 161it stays with that buffer until you use it in some other buffer which
@@ -175,7 +175,7 @@ See variables `compilation-parse-errors-function' and
175 175
176(define-key ctl-x-map "`" 'next-error) 176(define-key ctl-x-map "`" 'next-error)
177 177
178(defun previous-error (n) 178(defun previous-error (&optional n)
179 "Visit previous next-error message and corresponding source code. 179 "Visit previous next-error message and corresponding source code.
180 180
181Prefix arg N says how many error messages to move backwards (or 181Prefix arg N says how many error messages to move backwards (or
@@ -183,9 +183,9 @@ forwards, if negative).
183 183
184This operates on the output from the \\[compile] and \\[grep] commands." 184This operates on the output from the \\[compile] and \\[grep] commands."
185 (interactive "p") 185 (interactive "p")
186 (next-error (- n))) 186 (next-error (- (or n 1))))
187 187
188(defun first-error (n) 188(defun first-error (&optional n)
189 "Restart at the first error. 189 "Restart at the first error.
190Visit corresponding source code. 190Visit corresponding source code.
191With prefix arg N, visit the source code of the Nth error. 191With prefix arg N, visit the source code of the Nth error.
@@ -193,25 +193,63 @@ This operates on the output from the \\[compile] command, for instance."
193 (interactive "p") 193 (interactive "p")
194 (next-error n t)) 194 (next-error n t))
195 195
196(defun next-error-no-select (n) 196(defun next-error-no-select (&optional n)
197 "Move point to the next error in the next-error buffer and highlight match. 197 "Move point to the next error in the next-error buffer and highlight match.
198Prefix arg N says how many error messages to move forwards (or 198Prefix arg N says how many error messages to move forwards (or
199backwards, if negative). 199backwards, if negative).
200Finds and highlights the source line like \\[next-error], but does not 200Finds and highlights the source line like \\[next-error], but does not
201select the source buffer." 201select the source buffer."
202 (interactive "p") 202 (interactive "p")
203 (next-error n) 203 (let ((next-error-highlight next-error-highlight-no-select))
204 (next-error n))
204 (pop-to-buffer next-error-last-buffer)) 205 (pop-to-buffer next-error-last-buffer))
205 206
206(defun previous-error-no-select (n) 207(defun previous-error-no-select (&optional n)
207 "Move point to the previous error in the next-error buffer and highlight match. 208 "Move point to the previous error in the next-error buffer and highlight match.
208Prefix arg N says how many error messages to move backwards (or 209Prefix arg N says how many error messages to move backwards (or
209forwards, if negative). 210forwards, if negative).
210Finds and highlights the source line like \\[previous-error], but does not 211Finds and highlights the source line like \\[previous-error], but does not
211select the source buffer." 212select the source buffer."
212 (interactive "p") 213 (interactive "p")
213 (next-error-no-select (- n))) 214 (next-error-no-select (- (or n 1))))
215
216(defgroup next-error nil
217 "next-error support framework."
218 :group 'compilation
219 :version "21.4")
220
221(defface next-error
222 '((t (:inherit region)))
223 "Face used to highlight next error locus."
224 :group 'next-error
225 :version "21.4")
226
227(defcustom next-error-highlight 0.1
228 "*Highlighting of locations in selected source buffers.
229If number, highlight the locus in next-error face for given time in seconds.
230If t, use persistent overlays fontified in next-error face.
231If nil, don't highlight the locus in the source buffer.
232If `fringe-arrow', indicate the locus by the fringe arrow."
233 :type '(choice (number :tag "Delay")
234 (const :tag "Persistent overlay" t)
235 (const :tag "No highlighting" nil)
236 (const :tag "Fringe arrow" 'fringe-arrow))
237 :group 'next-error
238 :version "21.4")
214 239
240(defcustom next-error-highlight-no-select 0.1
241 "*Highlighting of locations in non-selected source buffers.
242If number, highlight the locus in next-error face for given time in seconds.
243If t, use persistent overlays fontified in next-error face.
244If nil, don't highlight the locus in the source buffer.
245If `fringe-arrow', indicate the locus by the fringe arrow."
246 :type '(choice (number :tag "Delay")
247 (const :tag "Persistent overlay" t)
248 (const :tag "No highlighting" nil)
249 (const :tag "Fringe arrow" 'fringe-arrow))
250 :group 'next-error
251 :version "21.4")
252
215;;; 253;;;
216 254
217(defun fundamental-mode () 255(defun fundamental-mode ()
diff --git a/lisp/startup.el b/lisp/startup.el
index 1a37a471c61..786ec31174d 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -348,9 +348,6 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
348 ;; `user-full-name' is now known; reset its standard-value here. 348 ;; `user-full-name' is now known; reset its standard-value here.
349 (put 'user-full-name 'standard-value 349 (put 'user-full-name 'standard-value
350 (list (default-value 'user-full-name))) 350 (list (default-value 'user-full-name)))
351 ;; Subprocesses of Emacs do not have direct access to the terminal,
352 ;; so unless told otherwise they should only assume a dumb terminal.
353 (setenv "TERM" "dumb")
354 ;; For root, preserve owner and group when editing files. 351 ;; For root, preserve owner and group when editing files.
355 (if (equal (user-uid) 0) 352 (if (equal (user-uid) 0)
356 (setq backup-by-copying-when-mismatch t)) 353 (setq backup-by-copying-when-mismatch t))
diff --git a/lisp/subr.el b/lisp/subr.el
index cadfa3fde34..a55de922e90 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1969,6 +1969,27 @@ Uses the `derived-mode-parent' property of the symbol to trace backwards."
1969 (setq parent (get parent 'derived-mode-parent)))) 1969 (setq parent (get parent 'derived-mode-parent))))
1970 parent)) 1970 parent))
1971 1971
1972(defun find-tag-default ()
1973 "Determine default tag to search for, based on text at point.
1974If there is no plausible default, return nil."
1975 (save-excursion
1976 (while (looking-at "\\sw\\|\\s_")
1977 (forward-char 1))
1978 (if (or (re-search-backward "\\sw\\|\\s_"
1979 (save-excursion (beginning-of-line) (point))
1980 t)
1981 (re-search-forward "\\(\\sw\\|\\s_\\)+"
1982 (save-excursion (end-of-line) (point))
1983 t))
1984 (progn (goto-char (match-end 0))
1985 (buffer-substring-no-properties
1986 (point)
1987 (progn (forward-sexp -1)
1988 (while (looking-at "\\s'")
1989 (forward-char 1))
1990 (point))))
1991 nil)))
1992
1972(defmacro with-syntax-table (table &rest body) 1993(defmacro with-syntax-table (table &rest body)
1973 "Evaluate BODY with syntax table of current buffer set to TABLE. 1994 "Evaluate BODY with syntax table of current buffer set to TABLE.
1974The syntax table of the current buffer is saved, BODY is evaluated, and the 1995The syntax table of the current buffer is saved, BODY is evaluated, and the
diff --git a/lisp/term/mac-win.el b/lisp/term/mac-win.el
index eea8e95ce83..7cb0bfe9de5 100644
--- a/lisp/term/mac-win.el
+++ b/lisp/term/mac-win.el
@@ -141,6 +141,9 @@
141 (if clipboard 141 (if clipboard
142 (decode-coding-string clipboard selection-coding-system t))))) 142 (decode-coding-string clipboard selection-coding-system t)))))
143 143
144;; Don't show the frame name; that's redundant.
145(setq-default mode-line-frame-identification " ")
146
144(defun mac-drag-n-drop (event) 147(defun mac-drag-n-drop (event)
145 "Edit the files listed in the drag-n-drop event.\n\ 148 "Edit the files listed in the drag-n-drop event.\n\
146Switch to a buffer editing the last file dropped." 149Switch to a buffer editing the last file dropped."
@@ -253,6 +256,9 @@ See the documentation of `create-fontset-from-fontset-spec for the format.")
253 256
254;; Tell read-char how to convert special chars to ASCII 257;; Tell read-char how to convert special chars to ASCII
255(put 'return 'ascii-character 13) 258(put 'return 'ascii-character 13)
259(put 'tab 'ascii-character ?\t)
260(put 'backspace 'ascii-character 127)
261(put 'escape 'ascii-character ?\e)
256 262
257;; 263;;
258;; Available colors 264;; Available colors
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 77c63379e2b..435e2e5f27a 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -1228,7 +1228,7 @@ for skipping in latex mode.")
1228 "*Lists of start and end keys to skip in HTML buffers. 1228 "*Lists of start and end keys to skip in HTML buffers.
1229Same format as `ispell-skip-region-alist' 1229Same format as `ispell-skip-region-alist'
1230Note - substrings of other matches must come last 1230Note - substrings of other matches must come last
1231 (e.g. \"<[tT][tT]/\" and \"<[^ \t\n>]\").") 1231 (e.g. \"<[tT][tT]/\" and \"<[^ \\t\\n>]\").")
1232 1232
1233 1233
1234(defvar ispell-local-pdict ispell-personal-dictionary 1234(defvar ispell-local-pdict ispell-personal-dictionary
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index 7cab20ef81f..08d25997a11 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -1145,9 +1145,10 @@ on the line for the invalidity you want to see."
1145 (if no-matches 1145 (if no-matches
1146 (insert "None!\n")) 1146 (insert "None!\n"))
1147 (if (interactive-p) 1147 (if (interactive-p)
1148 (message "%s mismatch%s found" 1148 (message (cond (no-matches "No mismatches found")
1149 (if no-matches "No" num-matches) 1149 ((= num-matches 1) "1 mismatch found")
1150 (if (> num-matches 1) "es" "")))))))) 1150 (t "%d mismatches found"))
1151 num-matches)))))))
1151 1152
1152(defun tex-validate-region (start end) 1153(defun tex-validate-region (start end)
1153 "Check for mismatched braces or $'s in region. 1154 "Check for mismatched braces or $'s in region.
diff --git a/lisp/x-dnd.el b/lisp/x-dnd.el
index 7d43a10556e..0f9237f3409 100644
--- a/lisp/x-dnd.el
+++ b/lisp/x-dnd.el
@@ -58,8 +58,8 @@ The default value for this variable is `x-dnd-default-test-function'."
58 ) 58 )
59 59
60 "The functions to call for different protocols when a drop is made. 60 "The functions to call for different protocols when a drop is made.
61This variable is used by `x-dnd-handle-uri-list' and `x-dnd-handle-moz-url'. 61This variable is used by `x-dnd-handle-uri-list', `x-dnd-handle-file-name'
62The list contains of (REGEXP . FUNCTION) pairs. 62and `x-dnd-handle-moz-url'. The list contains of (REGEXP . FUNCTION) pairs.
63The functions shall take two arguments, URL, which is the URL dropped and 63The functions shall take two arguments, URL, which is the URL dropped and
64ACTION which is the action to be performed for the drop (move, copy, link, 64ACTION which is the action to be performed for the drop (move, copy, link,
65private or ask). 65private or ask).
@@ -104,9 +104,7 @@ is successful, nil if not."
104 :type 'boolean 104 :type 'boolean
105 :group 'x) 105 :group 'x)
106 106
107;; Internal variables 107(defcustom x-dnd-known-types
108
109(defvar x-dnd-known-types
110 '("text/uri-list" 108 '("text/uri-list"
111 "text/x-moz-url" 109 "text/x-moz-url"
112 "_NETSCAPE_URL" 110 "_NETSCAPE_URL"
@@ -121,7 +119,12 @@ is successful, nil if not."
121 "TEXT" 119 "TEXT"
122 ) 120 )
123 "The types accepted by default for dropped data. 121 "The types accepted by default for dropped data.
124The types are chosen in the order they appear in the list.") 122The types are chosen in the order they appear in the list."
123 :type '(repeat string)
124 :group 'x
125)
126
127;; Internal variables
125 128
126(defvar x-dnd-current-state nil 129(defvar x-dnd-current-state nil
127 "The current state for a drop. 130 "The current state for a drop.
@@ -865,7 +868,7 @@ FORMAT is 32 (not used). MESSAGE is the data part of an XClientMessageEvent."
865 timestamp) 868 timestamp)
866 (x-dnd-forget-drop frame))) 869 (x-dnd-forget-drop frame)))
867 870
868 (t (error "Unknown Motif DND message %s %s" message data))))) 871 (t (error "Unknown Motif DND message %s %s" message-atom data)))))
869 872
870 873
871;;; 874;;;
diff --git a/lispref/ChangeLog b/lispref/ChangeLog
index 894d78646d1..234cc779019 100644
--- a/lispref/ChangeLog
+++ b/lispref/ChangeLog
@@ -1,3 +1,9 @@
12004-08-27 Luc Teirlinck <teirllm@auburn.edu>
2
3 * abbrevs.texi (Abbrev Expansion): `abbrev-start-location' can be
4 an integer or a marker.
5 (Abbrev Expansion): Replace example for `pre-abbrev-expand-hook'.
6
12004-08-22 Richard M. Stallman <rms@gnu.org> 72004-08-22 Richard M. Stallman <rms@gnu.org>
2 8
3 * modes.texi (Major Mode Conventions): Discuss rebinding of 9 * modes.texi (Major Mode Conventions): Discuss rebinding of
diff --git a/lispref/abbrevs.texi b/lispref/abbrevs.texi
index d586d0bbc13..1f873312222 100644
--- a/lispref/abbrevs.texi
+++ b/lispref/abbrevs.texi
@@ -1,6 +1,6 @@
1@c -*-texinfo-*- 1@c -*-texinfo-*-
2@c This is part of the GNU Emacs Lisp Reference Manual. 2@c This is part of the GNU Emacs Lisp Reference Manual.
3@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1999 3@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1999, 2004
4@c Free Software Foundation, Inc. 4@c Free Software Foundation, Inc.
5@c See the file elisp.texi for copying conditions. 5@c See the file elisp.texi for copying conditions.
6@setfilename ../info/abbrevs 6@setfilename ../info/abbrevs
@@ -288,7 +288,7 @@ expansion.
288@end defopt 288@end defopt
289 289
290@defvar abbrev-start-location 290@defvar abbrev-start-location
291The value of this variable is a marker pointing to the buffer position 291The value of this variable is a buffer position (an integer or a marker)
292for @code{expand-abbrev} to use as the start of the next abbrev to be 292for @code{expand-abbrev} to use as the start of the next abbrev to be
293expanded. The value can also be @code{nil}, which means to use the 293expanded. The value can also be @code{nil}, which means to use the
294word before point instead. @code{abbrev-start-location} is set to 294word before point instead. @code{abbrev-start-location} is set to
@@ -331,32 +331,43 @@ hook, the hook functions receive no arguments. However, they can find
331the abbrev to be expanded by looking in the buffer before point. 331the abbrev to be expanded by looking in the buffer before point.
332Running the hook is the first thing that @code{expand-abbrev} does, and 332Running the hook is the first thing that @code{expand-abbrev} does, and
333so a hook function can be used to change the current abbrev table before 333so a hook function can be used to change the current abbrev table before
334abbrev lookup happens. 334abbrev lookup happens. (Although you have to do this carefully. See
335the example below.)
335@end defvar 336@end defvar
336 337
337 The following sample code shows a simple use of 338 The following sample code shows a simple use of
338@code{pre-abbrev-expand-hook}. If the user terminates an abbrev with 339@code{pre-abbrev-expand-hook}. It assumes that @code{foo-mode} is a
339a punctuation character, the hook function asks for confirmation. It 340mode for editing certain files in which lines that start with @samp{#}
340aborts expansion if the user does not confirm. 341are comments. You want to use Text mode abbrevs for those lines. The
342regular local abbrev table, @code{foo-mode-abbrev-table} is
343appropriate for all other lines. Then you can put the following code
344in your @file{.emacs} file. @xref{Standard Abbrev Tables}, for the
345definitions of @code{local-abbrev-table} and @code{text-mode-abbrev-table}.
341 346
342@smallexample 347@smallexample
343(add-hook 'pre-abbrev-expand-hook 'query-if-not-space) 348(defun foo-mode-pre-abbrev-expand ()
344 349 (when (save-excursion (forward-line 0) (eq (char-after) ?#))
345;; @r{This is the function invoked by @code{pre-abbrev-expand-hook}.} 350 (let ((local-abbrev-table text-mode-abbrev-table)
346 351 ;; Avoid infinite loop.
347;; @r{If the user terminated the abbrev with a space, the function does} 352 (pre-abbrev-expand-hook nil))
348;; @r{nothing (that is, it returns so that the abbrev can expand). If the} 353 (expand-abbrev))
349;; @r{user entered some other character, this function asks whether} 354 ;; We have already called `expand-abbrev' in this hook.
350;; @r{expansion should continue.} 355 ;; Hence we want the "actual" call following this hook to be a no-op.
351 356 (setq abbrev-start-location (point-max)
352;; @r{The function's return value makes no difference.} 357 abbrev-start-location-buffer (current-buffer))))
353 358
354(defun query-if-not-space () 359(add-hook 'foo-mode-hook
355 (if (/= ?\s last-command-char) 360 #'(lambda ()
356 (if (not (y-or-n-p "Do you want to expand this abbrev? ")) 361 (add-hook 'pre-abbrev-expand-hook
357 (error "Not expanding this abbrev")))) 362 'foo-mode-pre-abbrev-expand
363 nil t)))
358@end smallexample 364@end smallexample
359 365
366Note that @code{foo-mode-pre-abbrex-expand} just returns @code{nil}
367without doing anything for lines not starting with @samp{#}. Hence
368abbrevs expand normally using @code{foo-mode-abbrev-table} as local
369abbrev table for such lines.
370
360@node Standard Abbrev Tables, , Abbrev Expansion, Abbrevs 371@node Standard Abbrev Tables, , Abbrev Expansion, Abbrevs
361@comment node-name, next, previous, up 372@comment node-name, next, previous, up
362@section Standard Abbrev Tables 373@section Standard Abbrev Tables
diff --git a/lwlib/ChangeLog b/lwlib/ChangeLog
index 3b69d955392..923f52debdd 100644
--- a/lwlib/ChangeLog
+++ b/lwlib/ChangeLog
@@ -1,3 +1,7 @@
12004-08-30 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
2
3 * lwlib.h (_widget_value): Added lname and lkey.
4
12004-01-12 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> 52004-01-12 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
2 6
3 * xlwmenuP.h (_XlwMenu_part): Added top_depth. 7 * xlwmenuP.h (_XlwMenu_part): Added top_depth.
diff --git a/lwlib/lwlib.h b/lwlib/lwlib.h
index 02560e47545..a141c600526 100644
--- a/lwlib/lwlib.h
+++ b/lwlib/lwlib.h
@@ -64,10 +64,12 @@ enum menu_separator
64typedef struct _widget_value 64typedef struct _widget_value
65{ 65{
66 /* name of widget */ 66 /* name of widget */
67 Lisp_Object lname;
67 char* name; 68 char* name;
68 /* value (meaning depend on widget type) */ 69 /* value (meaning depend on widget type) */
69 char* value; 70 char* value;
70 /* keyboard equivalent. no implications for XtTranslations */ 71 /* keyboard equivalent. no implications for XtTranslations */
72 Lisp_Object lkey;
71 char* key; 73 char* key;
72 /* Help string or nil if none. 74 /* Help string or nil if none.
73 GC finds this string through the frame's menu_bar_vector 75 GC finds this string through the frame's menu_bar_vector
diff --git a/man/ChangeLog b/man/ChangeLog
index f3ff703a0a4..62d985b022f 100644
--- a/man/ChangeLog
+++ b/man/ChangeLog
@@ -1,3 +1,93 @@
12004-09-03 Juri Linkov <juri@jurta.org>
2
3 * search.texi (Incremental Search): Update wording for M-%.
4
52004-09-02 Luc Teirlinck <teirllm@auburn.edu>
6
7 * killing.texi (Killing): Correct description of kill commands in
8 read-only buffer.
9
102004-09-02 Teodor Zlatanov <tzz@lifelogs.com>
11
12 * building.texi (Compilation Mode): Add a paragraph about rules
13 for finding the compilation buffer for `next-error'.
14
15 * search.texi (Other Repeating Search): Mention that Occur mode
16 supports the next-error functionality.
17
182004-09-02 Juri Linkov <juri@jurta.org>
19
20 * search.texi (Regexp Replace): Add missing backslash to \footnote.
21
222004-08-31 Luc Teirlinck <teirllm@auburn.edu>
23
24 * kmacro.texi (Basic Keyboard Macro):
25 `apply-macro-to-region-lines' now operates on all lines that begin
26 in the region, rather than on all complete lines in the region.
27
282004-08-31 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
29
30 * frames.texi (Drag and drop): Add documentation about
31 x-dnd-test-function and x-dnd-known-types.
32
332004-08-30 Luc Teirlinck <teirllm@auburn.edu>
34
35 * indent.texi: Various minor changes in addition to:
36 (Indentation Commands): Correct description of `indent-relative'.
37 (Tab Stops): <TAB> is no longer bound to `tab-to-tab-stop' in Text
38 mode. The *Tab Stops* buffer uses Overwrite Mode.
39 (Just Spaces): `untabify' converts sequences of at least two
40 spaces to tabs.
41
422004-08-28 Eli Zaretskii <eliz@gnu.org>
43
44 * faq.texi (Emacs for MS-DOS): Update URLs for the MS-DOS port of
45 Emacs and related programs.
46
472004-08-27 Luc Teirlinck <teirllm@auburn.edu>
48
49 * frames.texi (Secondary Selection): Setting the secondary
50 selection with M-Drag-Mouse-1 does not alter the kill ring,
51 setting it with M-Mouse-1 and M-Mouse-3 does.
52 (Mode Line Mouse): C-Mouse-2 on scroll bar now also works for
53 toolkit scroll bars.
54 (Scroll Bars): Ditto.
55
56 * windows.texi (Basic Window): When using a window system, the value
57 of point in a non-selected window is indicated by a hollow box.
58 (Split Window): Side by side windows are separated by a scroll bar,
59 if scroll bars are used.
60 C-Mouse-2 on scroll bar now also works for toolkit scroll bars.
61 (Change Window): Correct Mouse-2 vs Mouse-3 mess-up.
62 (Window Convenience): Update bindings for `winner-undo' and
63 `winner-redo'.
64
65 * ack.texi (Acknowledgments): Use `@unnumbered'.
66 * misc.texi : Adapt sectioning in Info to the node structure.
67 (Invoking emacsclient): Make "Invoking emacsclient" a subsection
68 of "Using Emacs as a Server".
69 * building.texi (Building): Interchange nodes (for correct numbering).
70 * programs.texi (Programs): Interchange nodes (for correct numbering).
71 * killing.texi, entering.texi, commands.texi: Adapt sectioning in
72 Info to the node structure.
73 * emacs.texi: Make "GNU GENERAL PUBLIC LICENSE" an appendix.
74 Rearrange order of nodes and sections such that both "GNU GENERAL
75 PUBLIC LICENSE" and "GNU Free Documentation License" appear at the
76 end, as appropriate for appendices.
77 (Acknowledgments): Put inside @iftex instead of @ifnotinfo.
78 Use `@unnumberedsec'.
79 * trouble.texi: Adapt sectioning in Info to the node structure.
80 Adapt node pointers to change in emacs.texi.
81 * cmdargs.texi, doclicense.texi: Adapt node pointers.
82
832004-08-27 Richard M. Stallman <rms@gnu.org>
84
85 * faq.texi: Fix texinfo usage, esp. doublequotes.
86 (Difference between Emacs and XEmacs): Some clarification.
87
88 * faq.texi (Difference between Emacs and XEmacs):
89 Explain not to contrast XEmacs with GNU Emacs.
90
12004-08-26 Richard M. Stallman <rms@gnu.org> 912004-08-26 Richard M. Stallman <rms@gnu.org>
2 92
3 * faq.texi (Difference between Emacs and XEmacs): Rewrite. 93 * faq.texi (Difference between Emacs and XEmacs): Rewrite.
diff --git a/man/ack.texi b/man/ack.texi
index 5d64b38cdf7..0d957dcef86 100644
--- a/man/ack.texi
+++ b/man/ack.texi
@@ -4,7 +4,7 @@
4@c See file emacs.texi for copying conditions. 4@c See file emacs.texi for copying conditions.
5@c 5@c
6@node Acknowledgments, Screen, Concept Index, Top 6@node Acknowledgments, Screen, Concept Index, Top
7@chapter Acknowledgments 7@unnumbered Acknowledgments
8 8
9Many people have contributed code included in the Free Software 9Many people have contributed code included in the Free Software
10Foundation's distribution of GNU Emacs. To show our appreciation for 10Foundation's distribution of GNU Emacs. To show our appreciation for
diff --git a/man/building.texi b/man/building.texi
index f7c1883e0d3..b3d4659a402 100644
--- a/man/building.texi
+++ b/man/building.texi
@@ -23,8 +23,8 @@ in the larger process of developing and maintaining programs.
23 with different facilities for running 23 with different facilities for running
24 the Lisp programs. 24 the Lisp programs.
25* Libraries: Lisp Libraries. Creating Lisp programs to run in Emacs. 25* Libraries: Lisp Libraries. Creating Lisp programs to run in Emacs.
26* Interaction: Lisp Interaction. Executing Lisp in an Emacs buffer.
27* Eval: Lisp Eval. Executing a single Lisp expression in Emacs. 26* Eval: Lisp Eval. Executing a single Lisp expression in Emacs.
27* Interaction: Lisp Interaction. Executing Lisp in an Emacs buffer.
28* External Lisp:: Communicating through Emacs with a separate Lisp. 28* External Lisp:: Communicating through Emacs with a separate Lisp.
29@end menu 29@end menu
30 30
@@ -204,6 +204,14 @@ commands advance from there. When @kbd{C-x `} gets to the end of the
204buffer and finds no more error messages to visit, it fails and signals 204buffer and finds no more error messages to visit, it fails and signals
205an Emacs error. 205an Emacs error.
206 206
207 You don't have to be in the compilation buffer in order to use
208@code{next-error}. If one window on the selected frame can be the
209target of the @code{next-error} call, it is used. Else, if a buffer
210previously had @code{next-error} called on it, it is used. Else,
211if the current buffer can be the target of @code{next-error}, it is
212used. Else, all the buffers Emacs manages are tried for
213@code{next-error} support.
214
207 @kbd{C-u C-x `} starts scanning from the beginning of the compilation 215 @kbd{C-u C-x `} starts scanning from the beginning of the compilation
208buffer. This is one way to process the same set of errors again. 216buffer. This is one way to process the same set of errors again.
209 217
@@ -644,7 +652,7 @@ to know GDB commands.
644@menu 652@menu
645* Layout:: Control the number of displayed buffers. 653* Layout:: Control the number of displayed buffers.
646* Breakpoints Buffer:: A breakpoint control panel. 654* Breakpoints Buffer:: A breakpoint control panel.
647* Stack Buffer:: Select a frame from the call stack. 655* Stack Buffer:: Select a frame from the call stack.
648* Watch Expressions:: Monitor variable values in the speedbar. 656* Watch Expressions:: Monitor variable values in the speedbar.
649* Other Buffers:: Input/output, locals, registers and assembler buffers. 657* Other Buffers:: Input/output, locals, registers and assembler buffers.
650@end menu 658@end menu
@@ -698,12 +706,12 @@ is the relevant buffer type e.g breakpoints.
698@node Breakpoints Buffer 706@node Breakpoints Buffer
699@subsubsection Breakpoints Buffer 707@subsubsection Breakpoints Buffer
700 708
701The breakpoints buffer shows the existing breakpoints and watchpoints 709The breakpoints buffer shows the existing breakpoints and watchpoints
702(@pxref{Breakpoints,,, gdb, The GNU debugger}). It has three special 710(@pxref{Breakpoints,,, gdb, The GNU debugger}). It has three special
703commands: 711commands:
704 712
705@table @kbd 713@table @kbd
706@item @key{SPC} 714@item @key{SPC}
707@kindex SPC @r{(GDB breakpoints buffer)} 715@kindex SPC @r{(GDB breakpoints buffer)}
708@findex gdb-toggle-breakpoint 716@findex gdb-toggle-breakpoint
709Enable/disable the breakpoint at the current line 717Enable/disable the breakpoint at the current line
diff --git a/man/cmdargs.texi b/man/cmdargs.texi
index f528b804c72..7548431aa4c 100644
--- a/man/cmdargs.texi
+++ b/man/cmdargs.texi
@@ -1,7 +1,7 @@
1@c This is part of the Emacs manual. 1@c This is part of the Emacs manual.
2@c Copyright (C) 1985,86,87,93,94,95,97,2001,03,2004 Free Software Foundation, Inc. 2@c Copyright (C) 1985,86,87,93,94,95,97,2001,03,2004 Free Software Foundation, Inc.
3@c See file emacs.texi for copying conditions. 3@c See file emacs.texi for copying conditions.
4@node Command Arguments, X Resources, Service, Top 4@node Command Arguments, X Resources, GNU Free Documentation License, Top
5@appendix Command Line Arguments 5@appendix Command Line Arguments
6@cindex command line arguments 6@cindex command line arguments
7@cindex arguments (command line) 7@cindex arguments (command line)
diff --git a/man/commands.texi b/man/commands.texi
index ea14e36128a..54ec50acfe8 100644
--- a/man/commands.texi
+++ b/man/commands.texi
@@ -10,6 +10,10 @@ of @dfn{keys} and @dfn{commands}, which are fundamental for understanding
10how Emacs interprets your keyboard and mouse input. 10how Emacs interprets your keyboard and mouse input.
11@end iftex 11@end iftex
12 12
13@ifnottex
14@raisesections
15@end ifnottex
16
13@node User Input, Keys, Screen, Top 17@node User Input, Keys, Screen, Top
14@section Kinds of User Input 18@section Kinds of User Input
15@cindex input with the keyboard 19@cindex input with the keyboard
@@ -266,6 +270,10 @@ with codes 128 through 255 can also appear in multibyte buffers.
266alphabet of non-@acronym{ASCII} characters, but they all fit in one byte. They 270alphabet of non-@acronym{ASCII} characters, but they all fit in one byte. They
267use codes 0200 through 0377. @xref{Single-Byte Character Support}. 271use codes 0200 through 0377. @xref{Single-Byte Character Support}.
268 272
273@ifnottex
274@lowersections
275@end ifnottex
276
269@ignore 277@ignore
270 arch-tag: 9be43eef-d1f4-4d03-a916-c741ea713a45 278 arch-tag: 9be43eef-d1f4-4d03-a916-c741ea713a45
271@end ignore 279@end ignore
diff --git a/man/doclicense.texi b/man/doclicense.texi
index 23ec98c202f..78ec35f5aab 100644
--- a/man/doclicense.texi
+++ b/man/doclicense.texi
@@ -1,6 +1,5 @@
1@c -*-texinfo-*- 1@c -*-texinfo-*-
2@node GNU Free Documentation License, Intro, Copying, Top 2@node GNU Free Documentation License, Command Arguments, Copying, Top
3
4@appendix GNU Free Documentation License 3@appendix GNU Free Documentation License
5@center Version 1.1, March 2000 4@center Version 1.1, March 2000
6 5
diff --git a/man/emacs.texi b/man/emacs.texi
index ad9658ab368..82d87f693aa 100644
--- a/man/emacs.texi
+++ b/man/emacs.texi
@@ -901,7 +901,7 @@ all GNU Emacs features. We don't try to describe VMS usage in this
901manual. @xref{MS-DOS}, for information about using Emacs on MS-DOS. 901manual. @xref{MS-DOS}, for information about using Emacs on MS-DOS.
902@end iftex 902@end iftex
903 903
904@node Distrib, Copying, Top, Top 904@node Distrib, Intro, Top, Top
905@unnumbered Distribution 905@unnumbered Distribution
906 906
907GNU Emacs is @dfn{free software}; this means that everyone is free to 907GNU Emacs is @dfn{free software}; this means that everyone is free to
@@ -955,9 +955,9 @@ company policy is unsympathetic to the idea of donating to charity, you
955might instead suggest ordering a CD-ROM from the Foundation 955might instead suggest ordering a CD-ROM from the Foundation
956occasionally, or subscribing to periodic updates. 956occasionally, or subscribing to periodic updates.
957 957
958@ifnotinfo 958@iftex
959@node Acknowledgments, Copying, Distrib, Top 959@node Acknowledgments, Intro, Distrib, Top
960@section Acknowledgments 960@unnumberedsec Acknowledgments
961 961
962Contributors to GNU Emacs include Per Abrahamsen, Jay K. Adams, Joe 962Contributors to GNU Emacs include Per Abrahamsen, Jay K. Adams, Joe
963Arceneaux, Boaz Ben-Zvi, Jim Blandy, Terrence Brannon, Frank Bresz, 963Arceneaux, Boaz Ben-Zvi, Jim Blandy, Terrence Brannon, Frank Bresz,
@@ -1000,10 +1000,102 @@ Warsaw, Morten Welinder, Joseph Brian Wells, Rodney Whitby, Ed
1000Wilkinson, Mike Williams, Steven A. Wood, Dale R. Worley, Felix 1000Wilkinson, Mike Williams, Steven A. Wood, Dale R. Worley, Felix
1001S. T. Wu, Tom Wurgler, Eli Zaretskii, Jamie Zawinski, Ian T. Zimmermann, 1001S. T. Wu, Tom Wurgler, Eli Zaretskii, Jamie Zawinski, Ian T. Zimmermann,
1002Reto Zimmermann, and Neal Ziring. 1002Reto Zimmermann, and Neal Ziring.
1003@end ifnotinfo 1003@end iftex
1004
1005@node Intro, Glossary, Distrib, Top
1006@unnumbered Introduction
1007
1008 You are reading about GNU Emacs, the GNU incarnation of the advanced,
1009self-documenting, customizable, extensible real-time display editor Emacs.
1010(The `G' in `GNU' is not silent.)
1011
1012 We say that Emacs is a @dfn{display} editor because normally the text
1013being edited is visible on the screen and is updated automatically as you
1014type your commands. @xref{Screen,Display}.
1015
1016 We call it a @dfn{real-time} editor because the display is updated very
1017frequently, usually after each character or pair of characters you
1018type. This minimizes the amount of information you must keep in your
1019head as you edit. @xref{Basic,Real-time,Basic Editing}.
1020
1021 We call Emacs advanced because it provides facilities that go beyond
1022simple insertion and deletion: controlling subprocesses; automatic
1023indentation of programs; viewing two or more files at once; editing
1024formatted text; and dealing in terms of characters, words, lines,
1025sentences, paragraphs, and pages, as well as expressions and comments in
1026several different programming languages.
1027
1028 @dfn{Self-documenting} means that at any time you can type a special
1029character, @kbd{Control-h}, to find out what your options are. You can
1030also use it to find out what any command does, or to find all the commands
1031that pertain to a topic. @xref{Help}.
1032
1033 @dfn{Customizable} means that you can change the definitions of Emacs
1034commands in little ways. For example, if you use a programming language in
1035which comments start with @samp{<**} and end with @samp{**>}, you can tell
1036the Emacs comment manipulation commands to use those strings
1037(@pxref{Comments}). Another sort of customization is rearrangement of the
1038command set. For example, if you prefer the four basic cursor motion
1039commands (up, down, left and right) on keys in a diamond pattern on the
1040keyboard, you can rebind the keys that way. @xref{Customization}.
1041
1042 @dfn{Extensible} means that you can go beyond simple customization and
1043write entirely new commands, programs in the Lisp language to be run by
1044Emacs's own Lisp interpreter. Emacs is an ``on-line extensible''
1045system, which means that it is divided into many functions that call
1046each other, any of which can be redefined in the middle of an editing
1047session. Almost any part of Emacs can be replaced without making a
1048separate copy of all of Emacs. Most of the editing commands of Emacs
1049are written in Lisp; the few exceptions could have been written
1050in Lisp but are written in C for efficiency. Although only a programmer
1051can write an extension, anybody can use it afterward. If you want to
1052learn Emacs Lisp programming, we recommend the @cite{Introduction to
1053Emacs Lisp} by Robert J. Chassell, also published by the Free Software
1054Foundation.
1055
1056 When run under the X Window System, Emacs provides its own menus and
1057convenient bindings to mouse buttons. But Emacs can provide many of the
1058benefits of a window system on a text-only terminal. For instance, you
1059can look at or edit several files at once, move text between files, and
1060edit files while running shell commands.
1061
1062@include screen.texi
1063@include commands.texi
1064@include entering.texi
1065@include basic.texi
1066@include mini.texi
1067@include m-x.texi
1068@include help.texi
1069@include mark.texi
1070@include killing.texi
1071@include regs.texi
1072@include display.texi
1073@include search.texi
1074@include fixit.texi
1075@include kmacro.texi
1076@include files.texi
1077@include buffers.texi
1078@include windows.texi
1079@include frames.texi
1080@include mule.texi
1081@include major.texi
1082@include indent.texi
1083@include text.texi
1084@include programs.texi
1085@include building.texi
1086@include maintaining.texi
1087@include abbrevs.texi
1088@include picture.texi
1089@include sending.texi
1090@include rmail.texi
1091@include dired.texi
1092@include calendar.texi
1093@include misc.texi
1094@include custom.texi
1095@include trouble.texi
1004 1096
1005@node Copying, GNU Free Documentation License, Distrib, Top 1097@node Copying, GNU Free Documentation License, Service, Top
1006@unnumbered GNU GENERAL PUBLIC LICENSE 1098@appendix GNU GENERAL PUBLIC LICENSE
1007@center Version 2, June 1991 1099@center Version 2, June 1991
1008 1100
1009@display 1101@display
@@ -1399,98 +1491,6 @@ library. If this is what you want to do, use the GNU Library General
1399Public License instead of this License. 1491Public License instead of this License.
1400 1492
1401@include doclicense.texi 1493@include doclicense.texi
1402
1403@node Intro, Glossary, GNU Free Documentation License, Top
1404@unnumbered Introduction
1405
1406 You are reading about GNU Emacs, the GNU incarnation of the advanced,
1407self-documenting, customizable, extensible real-time display editor Emacs.
1408(The `G' in `GNU' is not silent.)
1409
1410 We say that Emacs is a @dfn{display} editor because normally the text
1411being edited is visible on the screen and is updated automatically as you
1412type your commands. @xref{Screen,Display}.
1413
1414 We call it a @dfn{real-time} editor because the display is updated very
1415frequently, usually after each character or pair of characters you
1416type. This minimizes the amount of information you must keep in your
1417head as you edit. @xref{Basic,Real-time,Basic Editing}.
1418
1419 We call Emacs advanced because it provides facilities that go beyond
1420simple insertion and deletion: controlling subprocesses; automatic
1421indentation of programs; viewing two or more files at once; editing
1422formatted text; and dealing in terms of characters, words, lines,
1423sentences, paragraphs, and pages, as well as expressions and comments in
1424several different programming languages.
1425
1426 @dfn{Self-documenting} means that at any time you can type a special
1427character, @kbd{Control-h}, to find out what your options are. You can
1428also use it to find out what any command does, or to find all the commands
1429that pertain to a topic. @xref{Help}.
1430
1431 @dfn{Customizable} means that you can change the definitions of Emacs
1432commands in little ways. For example, if you use a programming language in
1433which comments start with @samp{<**} and end with @samp{**>}, you can tell
1434the Emacs comment manipulation commands to use those strings
1435(@pxref{Comments}). Another sort of customization is rearrangement of the
1436command set. For example, if you prefer the four basic cursor motion
1437commands (up, down, left and right) on keys in a diamond pattern on the
1438keyboard, you can rebind the keys that way. @xref{Customization}.
1439
1440 @dfn{Extensible} means that you can go beyond simple customization and
1441write entirely new commands, programs in the Lisp language to be run by
1442Emacs's own Lisp interpreter. Emacs is an ``on-line extensible''
1443system, which means that it is divided into many functions that call
1444each other, any of which can be redefined in the middle of an editing
1445session. Almost any part of Emacs can be replaced without making a
1446separate copy of all of Emacs. Most of the editing commands of Emacs
1447are written in Lisp; the few exceptions could have been written
1448in Lisp but are written in C for efficiency. Although only a programmer
1449can write an extension, anybody can use it afterward. If you want to
1450learn Emacs Lisp programming, we recommend the @cite{Introduction to
1451Emacs Lisp} by Robert J. Chassell, also published by the Free Software
1452Foundation.
1453
1454 When run under the X Window System, Emacs provides its own menus and
1455convenient bindings to mouse buttons. But Emacs can provide many of the
1456benefits of a window system on a text-only terminal. For instance, you
1457can look at or edit several files at once, move text between files, and
1458edit files while running shell commands.
1459
1460@include screen.texi
1461@include commands.texi
1462@include entering.texi
1463@include basic.texi
1464@include mini.texi
1465@include m-x.texi
1466@include help.texi
1467@include mark.texi
1468@include killing.texi
1469@include regs.texi
1470@include display.texi
1471@include search.texi
1472@include fixit.texi
1473@include kmacro.texi
1474@include files.texi
1475@include buffers.texi
1476@include windows.texi
1477@include frames.texi
1478@include mule.texi
1479@include major.texi
1480@include indent.texi
1481@include text.texi
1482@include programs.texi
1483@include building.texi
1484@include maintaining.texi
1485@include abbrevs.texi
1486@include picture.texi
1487@include sending.texi
1488@include rmail.texi
1489@include dired.texi
1490@include calendar.texi
1491@include misc.texi
1492@include custom.texi
1493@include trouble.texi
1494@include cmdargs.texi 1494@include cmdargs.texi
1495@include xresources.texi 1495@include xresources.texi
1496 1496
diff --git a/man/entering.texi b/man/entering.texi
index 9200082328a..31ac47b3c62 100644
--- a/man/entering.texi
+++ b/man/entering.texi
@@ -59,6 +59,10 @@ Emacs running, you can use the @command{emacsclient} program to open a
59file in the already running Emacs. @xref{Emacs Server}, for more 59file in the already running Emacs. @xref{Emacs Server}, for more
60information on editing files with Emacs from other programs. 60information on editing files with Emacs from other programs.
61 61
62@ifnottex
63@raisesections
64@end ifnottex
65
62@node Exiting, Basic, Entering Emacs, Top 66@node Exiting, Basic, Entering Emacs, Top
63@section Exiting Emacs 67@section Exiting Emacs
64@cindex exiting 68@cindex exiting
@@ -150,6 +154,10 @@ systems as the characters for stopping or killing a program, but that is
150their only relationship with the operating system. You can customize 154their only relationship with the operating system. You can customize
151these keys to run any commands of your choice (@pxref{Keymaps}). 155these keys to run any commands of your choice (@pxref{Keymaps}).
152 156
157@ifnottex
158@lowersections
159@end ifnottex
160
153@ignore 161@ignore
154 arch-tag: df798d8b-f253-4113-b585-f528f078a944 162 arch-tag: df798d8b-f253-4113-b585-f528f078a944
155@end ignore 163@end ignore
diff --git a/man/faq.texi b/man/faq.texi
index 2e99ec730e1..6ca849d7b1e 100644
--- a/man/faq.texi
+++ b/man/faq.texi
@@ -17,7 +17,7 @@ Copyright 1990,1991,1992 Joseph Brian Wells@*
17 17
18@quotation 18@quotation
19This list of frequently asked questions about GNU Emacs with answers 19This list of frequently asked questions about GNU Emacs with answers
20("FAQ") may be translated into other languages, transformed into other 20(``FAQ'') may be translated into other languages, transformed into other
21formats (e.g. Texinfo, Info, WWW, WAIS), and updated with new information. 21formats (e.g. Texinfo, Info, WWW, WAIS), and updated with new information.
22 22
23The same conditions apply to any derivative of the FAQ as apply to the FAQ 23The same conditions apply to any derivative of the FAQ as apply to the FAQ
@@ -906,8 +906,8 @@ where that is).
906Emacs General Public License 906Emacs General Public License
907 907
908@item DISTRIB 908@item DISTRIB
909Emacs Availability Information, including the popular "Free Software 909Emacs Availability Information, including the popular Free Software
910Foundation Order Form" 910Foundation Order Form
911 911
912@item FTP 912@item FTP
913How to get GNU Software by Internet FTP or by UUCP 913How to get GNU Software by Internet FTP or by UUCP
@@ -935,7 +935,7 @@ Emacs news, a history of recent user-visible changes
935GNU Service Directory 935GNU Service Directory
936 936
937@item SUN-SUPPORT 937@item SUN-SUPPORT
938including "Using Emacstool with GNU Emacs" 938including ``Using Emacstool with GNU Emacs''
939 939
940@end table 940@end table
941 941
@@ -1045,7 +1045,7 @@ send usenet/news.answers/GNU-Emacs-FAQ/part5
1045@end example 1045@end example
1046 1046
1047For more information, send email to @email{mail-server@@rtfm.mit.edu} 1047For more information, send email to @email{mail-server@@rtfm.mit.edu}
1048with "help" and "index" in the body on separate lines. 1048with @samp{help} and @samp{index} in the body on separate lines.
1049 1049
1050@item 1050@item
1051As the very last resort, you can e-mail a request to 1051As the very last resort, you can e-mail a request to
@@ -1864,7 +1864,7 @@ edge of the window.
1864@end itemize 1864@end itemize
1865 1865
1866@node Overwrite mode, Turning off beeping, Horizontal scrolling, Common requests 1866@node Overwrite mode, Turning off beeping, Horizontal scrolling, Common requests
1867@section How do I make Emacs "typeover" or "overwrite" instead of inserting? 1867@section How do I make Emacs ``typeover'' or ``overwrite'' instead of inserting?
1868@cindex @key{Insert} 1868@cindex @key{Insert}
1869@cindex @code{overwrite-mode} 1869@cindex @code{overwrite-mode}
1870@cindex Overwriting existing text 1870@cindex Overwriting existing text
@@ -2075,7 +2075,7 @@ onwards), to look at the resource names for the menu bar, assuming Emacs
2075was compiled with the X toolkit. 2075was compiled with the X toolkit.
2076 2076
2077@node Evaluating Emacs Lisp code, Changing the length of a Tab, Valid X resources, Common requests 2077@node Evaluating Emacs Lisp code, Changing the length of a Tab, Valid X resources, Common requests
2078@section How do I execute ("evaluate") a piece of Emacs Lisp code? 2078@section How do I execute (``evaluate'') a piece of Emacs Lisp code?
2079@cindex Evaluating Lisp code 2079@cindex Evaluating Lisp code
2080@cindex Lisp forms, evaluating 2080@cindex Lisp forms, evaluating
2081 2081
@@ -2162,7 +2162,7 @@ since version 19.20. @xref{Changing the included text prefix}, for
2162additional information. 2162additional information.
2163 2163
2164@node Underlining paragraphs, Repeating a command as many times as possible, Inserting > at the beginning of each line, Common requests 2164@node Underlining paragraphs, Repeating a command as many times as possible, Inserting > at the beginning of each line, Common requests
2165@section How do I insert "_^H" before each character in a region to get an underlined paragraph? 2165@section How do I insert @samp{_^H} before each character in a region to get an underlined paragraph?
2166@cindex Underlining a region of text 2166@cindex Underlining a region of text
2167@cindex @code{underline-region} 2167@cindex @code{underline-region}
2168 2168
@@ -2264,7 +2264,7 @@ Quick command-line switch descriptions are also available. For example,
2264You probably don't want to do this, since backups are useful, especially 2264You probably don't want to do this, since backups are useful, especially
2265when something goes wrong. 2265when something goes wrong.
2266 2266
2267To avoid seeing backup files (and other "uninteresting" files) in Dired, 2267To avoid seeing backup files (and other ``uninteresting'' files) in Dired,
2268load @code{dired-x} by adding the following to your @file{.emacs} file: 2268load @code{dired-x} by adding the following to your @file{.emacs} file:
2269 2269
2270@lisp 2270@lisp
@@ -2733,7 +2733,7 @@ sizes of up to 33,554,431 bytes):
2733@end example 2733@end example
2734 2734
2735@noindent 2735@noindent
2736This method may result in "ILLEGAL DATATYPE" and other random errors on 2736This method may result in ``ILLEGAL DATATYPE'' and other random errors on
2737some machines. 2737some machines.
2738 2738
2739@email{daveg@@csvax.cs.caltech.edu, David Gillespie} explains how this 2739@email{daveg@@csvax.cs.caltech.edu, David Gillespie} explains how this
@@ -2824,7 +2824,7 @@ stty -icrnl -onlcr -echo susp ^Z
2824@end example 2824@end example
2825 2825
2826@node Shell process exits abnormally, Problems with Shell Mode on MS-Windows, ^M in the shell buffer, Bugs and problems 2826@node Shell process exits abnormally, Problems with Shell Mode on MS-Windows, ^M in the shell buffer, Bugs and problems
2827@section Why do I get "Process shell exited abnormally with code 1"? 2827@section Why do I get ``Process shell exited abnormally with code 1''?
2828@cindex Abnormal exits from @code{shell-mode} 2828@cindex Abnormal exits from @code{shell-mode}
2829@cindex @code{shell-mode} exits 2829@cindex @code{shell-mode} exits
2830@cindex Process shell exited 2830@cindex Process shell exited
@@ -2881,7 +2881,7 @@ antivirus software; disabling the resident antivirus program solves
2881the problems in those cases. 2881the problems in those cases.
2882 2882
2883@node Termcap/Terminfo entries for Emacs, Spontaneous entry into isearch-mode, Problems with Shell Mode on MS-Windows, Bugs and problems 2883@node Termcap/Terminfo entries for Emacs, Spontaneous entry into isearch-mode, Problems with Shell Mode on MS-Windows, Bugs and problems
2884@section Where is the termcap/terminfo entry for terminal type "emacs"? 2884@section Where is the termcap/terminfo entry for terminal type @samp{emacs}?
2885@cindex Termcap 2885@cindex Termcap
2886@cindex Terminfo 2886@cindex Terminfo
2887@cindex Emacs entries for termcap/terminfo 2887@cindex Emacs entries for termcap/terminfo
@@ -2915,7 +2915,7 @@ if ("$term" == emacs) set term=dumb
2915@end example 2915@end example
2916 2916
2917@node Spontaneous entry into isearch-mode, Problems talking to certain hosts, Termcap/Terminfo entries for Emacs, Bugs and problems 2917@node Spontaneous entry into isearch-mode, Problems talking to certain hosts, Termcap/Terminfo entries for Emacs, Bugs and problems
2918@section Why does Emacs spontaneously start displaying "I-search:" and beeping? 2918@section Why does Emacs spontaneously start displaying @samp{I-search:} and beeping?
2919@cindex Spontaneous entry into isearch-mode 2919@cindex Spontaneous entry into isearch-mode
2920@cindex isearch-mode, spontaneous entry into 2920@cindex isearch-mode, spontaneous entry into
2921@cindex Beeping without obvious reason 2921@cindex Beeping without obvious reason
@@ -2972,7 +2972,7 @@ properly told to do DNS lookups with the correct command line switch.
2972@end itemize 2972@end itemize
2973 2973
2974@node Errors with init files, Emacs ignores X resources, Problems talking to certain hosts, Bugs and problems 2974@node Errors with init files, Emacs ignores X resources, Problems talking to certain hosts, Bugs and problems
2975@section Why does Emacs say "Error in init file"? 2975@section Why does Emacs say @samp{Error in init file}?
2976@cindex Error in @file{.emacs} 2976@cindex Error in @file{.emacs}
2977@cindex Error in init file 2977@cindex Error in init file
2978@cindex Init file, errors in 2978@cindex Init file, errors in
@@ -3238,7 +3238,7 @@ access control enabled, only authorized clients can connect
3238@end itemize 3238@end itemize
3239 3239
3240@node Dired claims that no file is on this line, , Security risks with Emacs, Bugs and problems 3240@node Dired claims that no file is on this line, , Security risks with Emacs, Bugs and problems
3241@section Dired says, "no file on this line" when I try to do something. 3241@section Dired says, @samp{no file on this line} when I try to do something.
3242@cindex Dired does not see a file 3242@cindex Dired does not see a file
3243 3243
3244@c FIXME: I think this is fixed in Emacs 21, but I didn't have time to 3244@c FIXME: I think this is fixed in Emacs 21, but I didn't have time to
@@ -3441,7 +3441,7 @@ Emacs needs to be linked with the static version of the X11 library,
3441@file{libX11.a}. This may be missing. 3441@file{libX11.a}. This may be missing.
3442 3442
3443On OpenWindows, you may need to use @code{add_services} to add the 3443On OpenWindows, you may need to use @code{add_services} to add the
3444"OpenWindows Programmers" optional software category from the CD-ROM. 3444``OpenWindows Programmers'' optional software category from the CD-ROM.
3445 3445
3446On HP-UX 8.0, you may need to run @code{update} again to load the 3446On HP-UX 8.0, you may need to run @code{update} again to load the
3447X11-PRG ``fileset''. This may be missing even if you specified ``all 3447X11-PRG ``fileset''. This may be missing even if you specified ``all
@@ -3580,31 +3580,37 @@ A list of sites mirroring @samp{ftp.gnu.org} can be found at
3580@uref{http://www.gnu.org/order/ftp.html} 3580@uref{http://www.gnu.org/order/ftp.html}
3581 3581
3582@node Difference between Emacs and XEmacs, Emacs for MS-DOS, Current GNU distributions, Finding Emacs and related packages 3582@node Difference between Emacs and XEmacs, Emacs for MS-DOS, Current GNU distributions, Finding Emacs and related packages
3583@section What is the difference between Emacs and XEmacs (formerly "Lucid Emacs")? 3583@section What is the difference between Emacs and XEmacs (formerly Lucid Emacs)?
3584@cindex XEmacs 3584@cindex XEmacs
3585@cindex Difference Emacs and XEmacs 3585@cindex Difference Emacs and XEmacs
3586@cindex Lucid Emacs 3586@cindex Lucid Emacs
3587@cindex Epoch 3587@cindex Epoch
3588 3588
3589XEmacs is a branch version of Emacs. It was earlier called as Lucid 3589XEmacs is a branch version of Emacs. It was first called Lucid Emacs,
3590Emacs, and it was based on a prerelease version of Emacs 19. In this 3590and was initially derived from a prerelease version of Emacs 19. In
3591FAQ, we use the name ``Emacs'' only for the official version. 3591this FAQ, we use the name ``Emacs'' only for the official version.
3592 3592
3593Emacs and XEmacs each come with Lisp packages that are lacking in the 3593Emacs and XEmacs each come with Lisp packages that are lacking in the
3594other. The two versions have some significant differences at the Lisp 3594other. The two versions have some significant differences at the Lisp
3595programming level. 3595programming level. Their current features are roughly comparable,
3596 3596though the support for some operating systems, character sets and
3597Many XEmacs features have found their way into recent versions of Emacs, 3597specific packages might be quite different.
3598and more features can be expected in the future, but there are still many 3598
3599differences between the two. 3599Some XEmacs code has been contributed to Emacs, and we would like to
3600 3600use other parts, but the earlier XEmacs maintainers did not always
3601The FSF has used some of the code in XEmacs, and would like to use 3601keep track of the authors of contributed code, which makes it
3602other parts, but the earlier XEmacs maintainers did not always keep 3602impossible for the FSF to get copyright papers signed for that code.
3603track of the authors of contributed code, which makes it impossible 3603(The FSF requires these papers for all the code included in the Emacs
3604for the FSF to get copyright papers signed for that code. (The FSF 3604release, aside from generic C support packages that retain their
3605requires these papers for all the code included in Emacs, aside from 3605separate identity and are not integrated into the code of Emacs
3606generic C support packages that are not integrated into the code of 3606proper.)
3607Emacs proper.) 3607
3608If you want to talk about these two versions and distinguish them,
3609please call them ``Emacs'' and ``XEmacs.'' To contrast ``XEmacs''
3610with ``GNU Emacs'' would be misleading, since XEmacs too has its
3611origin in the work of the GNU Project. Terms such as ``Emacsen'' and
3612``(X)Emacs'' are not wrong, but they are not very clear, so it
3613is better to write ``Emacs and XEmacs.''
3608 3614
3609@node Emacs for MS-DOS, Emacs for Windows, Difference between Emacs and XEmacs, Finding Emacs and related packages 3615@node Emacs for MS-DOS, Emacs for Windows, Difference between Emacs and XEmacs, Finding Emacs and related packages
3610@section Where can I get Emacs for my PC running MS-DOS? 3616@section Where can I get Emacs for my PC running MS-DOS?
@@ -3620,17 +3626,17 @@ Windows (3.X, 9X, ME, NT, and 2000) and supports long file names under
3620Windows 9X, Windows ME, and Windows 2000. More information is available 3626Windows 9X, Windows ME, and Windows 2000. More information is available
3621from 3627from
3622 3628
3623@uref{http://www.simtel.net/pub/djgpp/v2gnu/emacs.README} 3629@uref{ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/emacs.README}
3624 3630
3625The binary itself is available in the files @file{em*.zip} in the 3631The binary itself is available in the files @file{em*.zip} in the
3626directory 3632directory
3627 3633
3628@uref{http://www.simtel.net/pub/djgpp/v2gnu/} 3634@uref{ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/}
3629 3635
3630If you prefer to compile Emacs for yourself, you can do so with the 3636If you prefer to compile Emacs for yourself, you can do so with the
3631current distribution directly. You will need a 386 (or 3637current distribution directly. You will need a 386 (or
3632better) processor, and to be running MS-DOS 3.0 or later. According to 3638better) processor, and to be running MS-DOS 3.0 or later. According to
3633@email{eliz@@is.elta.co.il, Eli Zaretskii} and 3639@email{eliz@@gnu.org, Eli Zaretskii} and
3634@email{hankedr@@dms.auburn.edu, Darrel Hankerson}, you will need the 3640@email{hankedr@@dms.auburn.edu, Darrel Hankerson}, you will need the
3635following: 3641following:
3636 3642
@@ -3644,7 +3650,7 @@ long file names on Windows 9X/ME/2K.
3644You can get the latest release of DJGPP by retrieving all of 3650You can get the latest release of DJGPP by retrieving all of
3645the files in 3651the files in
3646 3652
3647@uref{http://www.simtel.net/pub/gnu/djgpp/v2*} 3653@uref{ftp://ftp.delorie.com/pub/djgpp/current/v2*}
3648 3654
3649@item Unpacking program 3655@item Unpacking program
3650The easiest way is to use @code{djtar} which comes with DJGPP v2.x, 3656The easiest way is to use @code{djtar} which comes with DJGPP v2.x,
@@ -3663,7 +3669,7 @@ actually prevent Emacs from building successfully!
3663@item make, mv, sed, and rm 3669@item make, mv, sed, and rm
3664All of these utilities are available at 3670All of these utilities are available at
3665 3671
3666@uref{http://www.simtel.net/pub/gnu/djgpp/v2gnu} 3672@uref{ftp://ftp.delorie.com/pub/djgpp/current/v2gnu}
3667 3673
366816-bit utilities can be found in GNUish, at 367416-bit utilities can be found in GNUish, at
3669 3675
@@ -3680,7 +3686,7 @@ directory of the Emacs sources contains some additional information
3680regarding Emacs under MS-DOS. 3686regarding Emacs under MS-DOS.
3681 3687
3682For a list of other MS-DOS implementations of Emacs (and Emacs 3688For a list of other MS-DOS implementations of Emacs (and Emacs
3683look-alikes), consult the list of "Emacs implementations and literature," 3689look-alikes), consult the list of ``Emacs implementations and literature,''
3684available at 3690available at
3685 3691
3686@uref{ftp://rtfm.mit.edu/pub/usenet/comp.emacs/} 3692@uref{ftp://rtfm.mit.edu/pub/usenet/comp.emacs/}
@@ -3765,18 +3771,11 @@ menus, and multiple frames. You can get it from
3765@cindex Apple computers, Emacs for 3771@cindex Apple computers, Emacs for
3766@cindex Macintosh, Emacs for 3772@cindex Macintosh, Emacs for
3767 3773
3768An unofficial port of GNU Emacs 18.59 to the Macintosh is available at a
3769number of ftp sites, the home being
3770@uref{ftp://ftp.cs.cornell.edu/pub/parmet/Emacs-1.17.sit.bin}.
3771
3772A port of Emacs 20.4 is available at
3773@uref{http://www.cs.hku.hk/~choi/emacs/index.html}.
3774
3775Beginning with version 21.1, the Macintosh is supported in the official 3774Beginning with version 21.1, the Macintosh is supported in the official
3776Emacs distribution; see the files @file{mac/README} and 3775Emacs distribution; see the files @file{mac/README} and
3777@file{mac/INSTALL} in the Emacs distribution for build instructions. 3776@file{mac/INSTALL} in the Emacs distribution for build instructions.
3778 3777
3779Apple's forthcoming "OS X" is based largely on NeXTSTEP and OpenStep. 3778Apple's ``OS X'' is based largely on NeXTSTEP and OpenStep.
3780@xref{Emacs for NeXTSTEP}, for more details about that version. 3779@xref{Emacs for NeXTSTEP}, for more details about that version.
3781 3780
3782@node Emacs for VMS and DECwindows, Modes for various languages, Emacs for Apple computers, Finding Emacs and related packages 3781@node Emacs for VMS and DECwindows, Modes for various languages, Emacs for Apple computers, Finding Emacs and related packages
@@ -4171,7 +4170,7 @@ jde-subscribe@@sunsite.auc.dk
4171@end table 4170@end table
4172 4171
4173@node Patch, , JDE, Major packages and programs 4172@node Patch, , JDE, Major packages and programs
4174@section Patch --- program to apply "diffs" for updating files 4173@section Patch --- program to apply ``diffs'' for updating files
4175@cindex Updating files with diffs 4174@cindex Updating files with diffs
4176@cindex Patching source files with diffs 4175@cindex Patching source files with diffs
4177@cindex Diffs and patching 4176@cindex Diffs and patching
@@ -4244,8 +4243,8 @@ command are required. For example,
4244 4243
4245@noindent 4244@noindent
4246can be placed directly into the @file{.emacs} file. If the key binding is 4245can be placed directly into the @file{.emacs} file. If the key binding is
4247local, the command is used in conjunction with the "add-hook" command. 4246local, the command is used in conjunction with the @samp{add-hook} function.
4248For example, in tex-mode, a local binding might be 4247For example, in TeX mode, a local binding might be
4249 4248
4250@lisp 4249@lisp
4251(add-hook 'tex-mode-hook 4250(add-hook 'tex-mode-hook
@@ -4284,7 +4283,7 @@ can be bound to a key and thus treated as a macro. For example:
4284@end itemize 4283@end itemize
4285 4284
4286@node Invalid prefix characters, Terminal setup code works after Emacs has begun, Binding keys to commands, Key bindings 4285@node Invalid prefix characters, Terminal setup code works after Emacs has begun, Binding keys to commands, Key bindings
4287@section Why does Emacs say "Key sequence XXX uses invalid prefix characters"? 4286@section Why does Emacs say @samp{Key sequence XXX uses invalid prefix characters}?
4288@cindex Prefix characters, invalid 4287@cindex Prefix characters, invalid
4289@cindex Invalid prefix characters 4288@cindex Invalid prefix characters
4290@cindex Misspecified key sequences 4289@cindex Misspecified key sequences
@@ -4679,7 +4678,7 @@ translation.
4679@cindex Generating control characters 4678@cindex Generating control characters
4680@cindex Control characters, generating 4679@cindex Control characters, generating
4681 4680
4682On terminals (but not under X), some common "aliases" are: 4681On terminals (but not under X), some common ``aliases'' are:
4683 4682
4684@table @asis 4683@table @asis
4685 4684
diff --git a/man/frames.texi b/man/frames.texi
index 7896adc41f6..dee050922e6 100644
--- a/man/frames.texi
+++ b/man/frames.texi
@@ -1,5 +1,5 @@
1@c This is part of the Emacs manual. 1@c This is part of the Emacs manual.
2@c Copyright (C) 1985, 86, 87, 93, 94, 95, 97, 99, 2000, 2001 2@c Copyright (C) 1985, 86, 87, 93, 94, 95, 97, 99, 2000, 2001, 2004
3@c Free Software Foundation, Inc. 3@c Free Software Foundation, Inc.
4@c See file emacs.texi for copying conditions. 4@c See file emacs.texi for copying conditions.
5@node Frames, International, Windows, Top 5@node Frames, International, Windows, Top
@@ -230,6 +230,8 @@ dragging, the window scrolls at a steady rate until you move the mouse
230back into the window. This way, you can mark regions that don't fit 230back into the window. This way, you can mark regions that don't fit
231entirely on the screen. 231entirely on the screen.
232 232
233This way of setting the secondary selection does not alter the kill ring.
234
233@findex mouse-start-secondary 235@findex mouse-start-secondary
234@kindex M-Mouse-1 236@kindex M-Mouse-1
235@item M-Mouse-1 237@item M-Mouse-1
@@ -240,8 +242,9 @@ Set one endpoint for the @dfn{secondary selection}
240@kindex M-Mouse-3 242@kindex M-Mouse-3
241@item M-Mouse-3 243@item M-Mouse-3
242Make a secondary selection, using the place specified with @kbd{M-Mouse-1} 244Make a secondary selection, using the place specified with @kbd{M-Mouse-1}
243as the other end (@code{mouse-secondary-save-then-kill}). A second click 245as the other end (@code{mouse-secondary-save-then-kill}). This also
244at the same place kills the secondary selection just made. 246puts the selected text in the kill ring. A second click at the same
247place kills the secondary selection just made.
245 248
246@findex mouse-yank-secondary 249@findex mouse-yank-secondary
247@kindex M-Mouse-2 250@kindex M-Mouse-2
@@ -376,8 +379,7 @@ horizontally, above the place in the mode line where you click.
376 379
377@kindex C-Mouse-2 @r{(scroll bar)} 380@kindex C-Mouse-2 @r{(scroll bar)}
378 @kbd{C-Mouse-2} on a scroll bar splits the corresponding window 381 @kbd{C-Mouse-2} on a scroll bar splits the corresponding window
379vertically, unless you are using an X toolkit's implementation of 382vertically. @xref{Split Window}.
380scroll bars. @xref{Split Window}.
381 383
382 The commands above apply to areas of the mode line which do not have 384 The commands above apply to areas of the mode line which do not have
383special mouse bindings of their own. Some areas, such as the buffer 385special mouse bindings of their own. Some areas, such as the buffer
@@ -747,10 +749,8 @@ the level where you click up to the top of the window. @kbd{Mouse-3}
747down to the level where you click. By clicking repeatedly in the same 749down to the level where you click. By clicking repeatedly in the same
748place, you can scroll by the same distance over and over. 750place, you can scroll by the same distance over and over.
749 751
750 If you are using Emacs's own implementation of scroll bars, as opposed 752 You can also click @kbd{C-Mouse-2} in the scroll bar to split a
751to scroll bars from an X toolkit, you can also click @kbd{C-Mouse-2} in 753window vertically. The split occurs on the line where you click.
752the scroll bar to split a window vertically. The split occurs on the
753line where you click.
754 754
755@findex scroll-bar-mode 755@findex scroll-bar-mode
756@vindex scroll-bar-mode 756@vindex scroll-bar-mode
@@ -800,15 +800,26 @@ buffers are scrolled.
800@section Drag and drop in Emacs. 800@section Drag and drop in Emacs.
801 801
802@cindex drag and drop 802@cindex drag and drop
803 Emacs supports drag and drop so that dropping of files and text is handeled. 803 Emacs supports drag and drop so that dropping of files and text is handled.
804Currently supported drag and drop protocols are XDND, Motif and the old 804Currently supported drag and drop protocols are XDND, Motif and the old
805KDE 1.x protocol. There is no drag support yet. 805KDE 1.x protocol. There is no drag support yet.
806When text is dropped on Emacs, Emacs inserts the text where it is dropped. 806When text is dropped on Emacs, Emacs inserts the text where it is dropped.
807When a file is dragged from a file manager to Emacs, Emacs opens that file. 807When a file is dragged from a file manager to Emacs, Emacs opens that file.
808As a special case, if a file is dropped on a dired buffer the file is 808As a special case, if a file is dropped on a dired buffer the file is
809copied or moved (depends on exactly how it is dragged and the application 809copied or moved (depends on exactly how it is dragged and the application
810it was dragged from) to the directory the dired buffer is displaying. 810it was dragged from) to the directory the dired buffer is displaying.
811 811
812@vindex x-dnd-test-function
813@vindex x-dnd-known-types
814 When a user drags something from another application over Emacs, that other
815application expects Emacs to tell it if Emacs can handle the data that is
816dragged. The variable @code{x-dnd-test-function} is used by Emacs to determine
817what to reply. The default value is @code{x-dnd-default-test-function}
818which accepts drops if the type of the data to be dropped is present in
819@code{x-dnd-known-types}. You can customize @code{x-dnd-test-function} and/or
820@code{x-dnd-known-types} if you want Emacs to accept or reject drops based
821on some other criteria.
822
812@vindex x-dnd-open-file-other-window 823@vindex x-dnd-open-file-other-window
813 A file is normally opened in the window it is dropped on, but if you 824 A file is normally opened in the window it is dropped on, but if you
814prefer the file to be opened in a new window you can customize the variable 825prefer the file to be opened in a new window you can customize the variable
@@ -896,7 +907,7 @@ file names.
896 907
897 You can customize the option @code{use-file-dialog} to suppress the 908 You can customize the option @code{use-file-dialog} to suppress the
898use of file selection windows even if you still want other kinds 909use of file selection windows even if you still want other kinds
899of dialogs. This option has no effect if you have supressed all dialog 910of dialogs. This option has no effect if you have suppressed all dialog
900boxes with the option @code{use-dialog-box}. 911boxes with the option @code{use-dialog-box}.
901 912
902 913
diff --git a/man/indent.texi b/man/indent.texi
index d2134103240..ab640e76462 100644
--- a/man/indent.texi
+++ b/man/indent.texi
@@ -1,5 +1,5 @@
1@c This is part of the Emacs manual. 1@c This is part of the Emacs manual.
2@c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997 Free Software Foundation, Inc. 2@c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997, 2004 Free Software Foundation, Inc.
3@c See file emacs.texi for copying conditions. 3@c See file emacs.texi for copying conditions.
4@node Indentation, Text, Major Modes, Top 4@node Indentation, Text, Major Modes, Top
5@chapter Indentation 5@chapter Indentation
@@ -75,7 +75,7 @@ type @key{TAB}, it aligns the line as a whole.
75 Normally, all of the above methods insert an optimal mix of tabs and 75 Normally, all of the above methods insert an optimal mix of tabs and
76spaces to align to the desired column. @xref{Just Spaces}, for how to 76spaces to align to the desired column. @xref{Just Spaces}, for how to
77disable use of tabs. However, @kbd{C-q @key{TAB}} always inserts a 77disable use of tabs. However, @kbd{C-q @key{TAB}} always inserts a
78tab, even they are disabled for the indentation commands. 78tab, even when tabs are disabled for the indentation commands.
79 79
80@c In Text mode, @key{TAB} runs the command @code{tab-to-tab-stop}, which 80@c In Text mode, @key{TAB} runs the command @code{tab-to-tab-stop}, which
81@c indents to the next tab stop column. You can set the tab stops with 81@c indents to the next tab stop column. You can set the tab stops with
@@ -95,7 +95,8 @@ tab, even they are disabled for the indentation commands.
95@findex back-to-indentation 95@findex back-to-indentation
96 To move over the indentation on a line, do @kbd{M-m} 96 To move over the indentation on a line, do @kbd{M-m}
97(@code{back-to-indentation}). This command, given anywhere on a line, 97(@code{back-to-indentation}). This command, given anywhere on a line,
98positions point at the first nonblank character on the line. 98positions point at the first nonblank character on the line, if any,
99or else at the end of the line.
99 100
100 To insert an indented line before the current line, do @kbd{C-a C-o 101 To insert an indented line before the current line, do @kbd{C-a C-o
101@key{TAB}}. To make an indented line after the current line, use 102@key{TAB}}. To make an indented line after the current line, use
@@ -134,13 +135,13 @@ appears after the newline that is deleted. @xref{Fill Prefix}.
134@findex indent-region 135@findex indent-region
135@findex indent-rigidly 136@findex indent-rigidly
136 There are also commands for changing the indentation of several lines 137 There are also commands for changing the indentation of several lines
137at once. @kbd{C-M-\} (@code{indent-region}) applies to all the lines 138at once. They apply to all the lines that begin in the region.
138that begin in the region; it indents each line in the ``usual'' way, as 139@kbd{C-M-\} (@code{indent-region}) indents each line in the ``usual''
139if you had typed @key{TAB} at the beginning of the line. A numeric 140way, as if you had typed @key{TAB} at the beginning of the line. A
140argument specifies the column to indent to, and each line is shifted 141numeric argument specifies the column to indent to, and each line is
141left or right so that its first nonblank character appears in that 142shifted left or right so that its first nonblank character appears in
142column. @kbd{C-x @key{TAB}} (@code{indent-rigidly}) moves all of the 143that column. @kbd{C-x @key{TAB}} (@code{indent-rigidly}) moves all of
143lines in the region right by its argument (left, for negative 144the lines in the region right by its argument (left, for negative
144arguments). The whole group of lines moves rigidly sideways, which is 145arguments). The whole group of lines moves rigidly sideways, which is
145how the command gets its name.@refill 146how the command gets its name.@refill
146 147
@@ -152,12 +153,10 @@ such as -1000.
152@findex indent-relative 153@findex indent-relative
153 @kbd{M-x indent-relative} indents at point based on the previous line 154 @kbd{M-x indent-relative} indents at point based on the previous line
154(actually, the last nonempty line). It inserts whitespace at point, moving 155(actually, the last nonempty line). It inserts whitespace at point, moving
155point, until it is underneath an indentation point in the previous line. 156point, until it is underneath the next indentation point in the previous line.
156An indentation point is the end of a sequence of whitespace or the end of 157An indentation point is the end of a sequence of whitespace or the end of
157the line. If point is farther right than any indentation point in the 158the line. If point is farther right than any indentation point in the
158previous line, the whitespace before point is deleted and the first 159previous line, @code{indent-relative} runs @code{tab-to-tab-stop}
159indentation point then applicable is used. If no indentation point is
160applicable even then, @code{indent-relative} runs @code{tab-to-tab-stop}
161@ifinfo 160@ifinfo
162(@pxref{Tab Stops}), 161(@pxref{Tab Stops}),
163@end ifinfo 162@end ifinfo
@@ -167,9 +166,6 @@ applicable even then, @code{indent-relative} runs @code{tab-to-tab-stop}
167unless it is called with a numeric argument, in which case it does 166unless it is called with a numeric argument, in which case it does
168nothing. 167nothing.
169 168
170 @code{indent-relative} is the definition of @key{TAB} in Indented Text
171mode. @xref{Text}.
172
173 @xref{Format Indentation}, for another way of specifying the 169 @xref{Format Indentation}, for another way of specifying the
174indentation for part of your text. 170indentation for part of your text.
175 171
@@ -181,10 +177,9 @@ indentation for part of your text.
181@cindex tables, indentation for 177@cindex tables, indentation for
182@kindex M-i 178@kindex M-i
183@findex tab-to-tab-stop 179@findex tab-to-tab-stop
184 For typing in tables, you can use Text mode's definition of @key{TAB}, 180 For typing in tables, you can use @kbd{M-i} (@code{tab-to-tab-stop}).
185@code{tab-to-tab-stop}. This command inserts indentation before point, 181This command inserts indentation before point, enough to reach the
186enough to reach the next tab stop column. If you are not in Text mode, 182next tab stop column.
187this command can be found on the key @kbd{M-i}.
188 183
189@findex edit-tab-stops 184@findex edit-tab-stops
190@findex edit-tab-stops-note-changes 185@findex edit-tab-stops-note-changes
@@ -198,10 +193,11 @@ increasing order.
198edit-tab-stops}, which creates and selects a buffer containing a 193edit-tab-stops}, which creates and selects a buffer containing a
199description of the tab stop settings. You can edit this buffer to 194description of the tab stop settings. You can edit this buffer to
200specify different tab stops, and then type @kbd{C-c C-c} to make those 195specify different tab stops, and then type @kbd{C-c C-c} to make those
201new tab stops take effect. @code{edit-tab-stops} records which buffer 196new tab stops take effect. The buffer uses Overwrite mode
202was current when you invoked it, and stores the tab stops back in that 197(@pxref{Minor Modes}). @code{edit-tab-stops} records which buffer was
203buffer; normally all buffers share the same tab stops and changing them 198current when you invoked it, and stores the tab stops back in that
204in one buffer affects all, but if you happen to make 199buffer; normally all buffers share the same tab stops and changing
200them in one buffer affects all, but if you happen to make
205@code{tab-stop-list} local in one buffer then @code{edit-tab-stops} in 201@code{tab-stop-list} local in one buffer then @code{edit-tab-stops} in
206that buffer will edit the local settings. 202that buffer will edit the local settings.
207 203
@@ -242,7 +238,7 @@ that your file looks the same regardless of the tab width setting.
242@findex untabify 238@findex untabify
243 There are also commands to convert tabs to spaces or vice versa, always 239 There are also commands to convert tabs to spaces or vice versa, always
244preserving the columns of all nonblank text. @kbd{M-x tabify} scans the 240preserving the columns of all nonblank text. @kbd{M-x tabify} scans the
245region for sequences of spaces, and converts sequences of at least three 241region for sequences of spaces, and converts sequences of at least two
246spaces to tabs if that can be done without changing indentation. @kbd{M-x 242spaces to tabs if that can be done without changing indentation. @kbd{M-x
247untabify} changes all tabs in the region to appropriate numbers of spaces. 243untabify} changes all tabs in the region to appropriate numbers of spaces.
248 244
diff --git a/man/killing.texi b/man/killing.texi
index b5f1ce30772..23ffd2b709a 100644
--- a/man/killing.texi
+++ b/man/killing.texi
@@ -1,5 +1,6 @@
1@c This is part of the Emacs manual. 1@c This is part of the Emacs manual.
2@c Copyright (C) 1985,86,87,93,94,95,97,00,2001 Free Software Foundation, Inc. 2@c Copyright (C) 1985,86,87,93,94,95,97,2000,2001,2004
3@c Free Software Foundation, Inc.
3@c See file emacs.texi for copying conditions. 4@c See file emacs.texi for copying conditions.
4@iftex 5@iftex
5@chapter Killing and Moving Text 6@chapter Killing and Moving Text
@@ -25,6 +26,10 @@ one buffer and yank it in another buffer.
25 26
26@end iftex 27@end iftex
27 28
29@ifnottex
30@raisesections
31@end ifnottex
32
28@node Killing, Yanking, Mark, Top 33@node Killing, Yanking, Mark, Top
29@section Deletion and Killing 34@section Deletion and Killing
30 35
@@ -45,11 +50,12 @@ can use the @kbd{C-x u} (@code{undo}) command to undo it
45 You cannot kill read-only text, since such text does not allow any 50 You cannot kill read-only text, since such text does not allow any
46kind of modification. But some users like to use the kill commands to 51kind of modification. But some users like to use the kill commands to
47copy read-only text into the kill ring, without actually changing it. 52copy read-only text into the kill ring, without actually changing it.
48If you set the variable @code{kill-read-only-ok} to a non-@code{nil} 53Therefore, the kill commands work specially in a read-only buffer:
49value, the kill commands work specially in a read-only buffer: they 54they move over text, and copy it to the kill ring, without actually
50move over text, and copy it to the kill ring, without actually 55deleting it from the buffer. Normally, Emacs beeps and prints an
51deleting it from the buffer. When this happens, a message in the echo 56error message when this happens. But if you set the variable
52area tells you what is happening. 57@code{kill-read-only-ok} to a non-@code{nil} value, it just prints a
58message in the echo area, telling you what is happening.
53 59
54 The delete commands include @kbd{C-d} (@code{delete-char}) and 60 The delete commands include @kbd{C-d} (@code{delete-char}) and
55@key{DEL} (@code{delete-backward-char}), which delete only one 61@key{DEL} (@code{delete-backward-char}), which delete only one
@@ -646,6 +652,10 @@ rectangle shifts right.
646@code{string-rectangle}, but inserts the string on each line, 652@code{string-rectangle}, but inserts the string on each line,
647shifting the original text to the right. 653shifting the original text to the right.
648 654
655@ifnottex
656@lowersections
657@end ifnottex
658
649@ignore 659@ignore
650 arch-tag: d8da8f96-0928-449a-816e-ff2d3497866c 660 arch-tag: d8da8f96-0928-449a-816e-ff2d3497866c
651@end ignore 661@end ignore
diff --git a/man/kmacro.texi b/man/kmacro.texi
index d3c24873cd0..bad186f88b2 100644
--- a/man/kmacro.texi
+++ b/man/kmacro.texi
@@ -71,7 +71,7 @@ Insert in the buffer a keyboard macro's definition, as Lisp code.
71@item C-x C-k e 71@item C-x C-k e
72Edit a previously defined keyboard macro (@code{edit-kbd-macro}). 72Edit a previously defined keyboard macro (@code{edit-kbd-macro}).
73@item C-x C-k r 73@item C-x C-k r
74Run the last keyboard macro on each complete line in the region 74Run the last keyboard macro on each line that begins in the region
75(@code{apply-macro-to-region-lines}). 75(@code{apply-macro-to-region-lines}).
76@end table 76@end table
77 77
@@ -174,8 +174,8 @@ before appending to it.
174@findex apply-macro-to-region-lines 174@findex apply-macro-to-region-lines
175@kindex C-x C-k r 175@kindex C-x C-k r
176 The command @kbd{C-x C-k r} (@code{apply-macro-to-region-lines}) 176 The command @kbd{C-x C-k r} (@code{apply-macro-to-region-lines})
177repeats the last defined keyboard macro on each complete line within 177repeats the last defined keyboard macro on each line that begins in
178the current region. It does this line by line, by moving point to the 178the region. It does this line by line, by moving point to the
179beginning of the line and then executing the macro. 179beginning of the line and then executing the macro.
180 180
181@node Keyboard Macro Ring 181@node Keyboard Macro Ring
diff --git a/man/misc.texi b/man/misc.texi
index 3c5909a9f56..d3aa352d091 100644
--- a/man/misc.texi
+++ b/man/misc.texi
@@ -1,5 +1,5 @@
1@c This is part of the Emacs manual. 1@c This is part of the Emacs manual.
2@c Copyright (C) 1985, 86, 87, 93, 94, 95, 97, 2000, 2001 2@c Copyright (C) 1985, 86, 87, 93, 94, 95, 97, 2000, 2001, 2004
3@c Free Software Foundation, Inc. 3@c Free Software Foundation, Inc.
4@c See file emacs.texi for copying conditions. 4@c See file emacs.texi for copying conditions.
5@iftex 5@iftex
@@ -14,6 +14,11 @@ an Emacs session for later resumption, emulating other editors, and
14various diversions and amusements. 14various diversions and amusements.
15 15
16@end iftex 16@end iftex
17
18@ifnottex
19@raisesections
20@end ifnottex
21
17@node Gnus, Shell, Calendar/Diary, Top 22@node Gnus, Shell, Calendar/Diary, Top
18@section Gnus 23@section Gnus
19@cindex Gnus 24@cindex Gnus
@@ -1264,7 +1269,7 @@ automatically when you finish with them.
1264@end menu 1269@end menu
1265 1270
1266@node Invoking emacsclient,, Emacs Server, Emacs Server 1271@node Invoking emacsclient,, Emacs Server, Emacs Server
1267@section Invoking @code{emacsclient} 1272@subsection Invoking @code{emacsclient}
1268 1273
1269 To run the @code{emacsclient} program, specify file names as arguments, 1274 To run the @code{emacsclient} program, specify file names as arguments,
1270and optionally line numbers as well. Do it like this: 1275and optionally line numbers as well. Do it like this:
@@ -2448,6 +2453,10 @@ Likewise, @kbd{M-x snake} provides an implementation of Snake.
2448The command @kbd{M-x zone} plays games with the display when Emacs is 2453The command @kbd{M-x zone} plays games with the display when Emacs is
2449idle. 2454idle.
2450 2455
2456@ifnottex
2457@lowersections
2458@end ifnottex
2459
2451@ignore 2460@ignore
2452 arch-tag: 8f094220-c0d5-4e9e-af7d-3e0da8187474 2461 arch-tag: 8f094220-c0d5-4e9e-af7d-3e0da8187474
2453@end ignore 2462@end ignore
diff --git a/man/programs.texi b/man/programs.texi
index e19c8364f2b..abe0083b39e 100644
--- a/man/programs.texi
+++ b/man/programs.texi
@@ -31,8 +31,8 @@ Highlight program syntax (@pxref{Font Lock}).
31* Defuns:: Commands to operate on major top-level parts 31* Defuns:: Commands to operate on major top-level parts
32 of a program. 32 of a program.
33* Program Indent:: Adjusting indentation to show the nesting. 33* Program Indent:: Adjusting indentation to show the nesting.
34* Comments:: Inserting, killing, and aligning comments.
35* Parentheses:: Commands that operate on parentheses. 34* Parentheses:: Commands that operate on parentheses.
35* Comments:: Inserting, killing, and aligning comments.
36* Documentation:: Getting documentation of functions you plan to call. 36* Documentation:: Getting documentation of functions you plan to call.
37* Hideshow:: Displaying blocks selectively. 37* Hideshow:: Displaying blocks selectively.
38* Symbol Completion:: Completion on symbol names of your program or language. 38* Symbol Completion:: Completion on symbol names of your program or language.
diff --git a/man/search.texi b/man/search.texi
index a0c64275de0..58265341c29 100644
--- a/man/search.texi
+++ b/man/search.texi
@@ -215,10 +215,9 @@ string. It uses the same text that @kbd{C-y} as a command would yank.
215there. In Transient Mark mode, incremental search sets the mark without 215there. In Transient Mark mode, incremental search sets the mark without
216activating it, and does so only if the mark is not already active. 216activating it, and does so only if the mark is not already active.
217 217
218 @kbd{M-%} or @kbd{C-M-%} exits the incremental search and starts an 218 @kbd{M-%} typed in incremental search invokes @code{query-replace}
219interactive command @code{query-replace} or @code{query-replace-regexp} 219or @code{query-replace-regexp} (depending on search mode) with the
220with the last search string inserted in the minibuffer as initial input 220current search string used as the string to replace.
221for the string to replace.
222 221
223@cindex lazy search highlighting 222@cindex lazy search highlighting
224@vindex isearch-lazy-highlight 223@vindex isearch-lazy-highlight
@@ -1080,7 +1079,7 @@ ask you to edit the replacement string in the minibuffer, putting
1080point where the @samp{\?} was. For example, 1079point where the @samp{\?} was. For example,
1081 1080
1082@example 1081@example
1083M-x replace-regexp @key{RET} \footnote@{ @key{RET} 1082M-x replace-regexp @key{RET} \\footnote@{ @key{RET}
1084\&\\label@{fn:\#\?@} @key{RET} 1083\&\\label@{fn:\#\?@} @key{RET}
1085@end example 1084@end example
1086 1085
@@ -1286,6 +1285,9 @@ searched and moves point to the original of the chosen occurrence.
1286@kbd{o} and @kbd{C-o} display the match in another window; @kbd{C-o} 1285@kbd{o} and @kbd{C-o} display the match in another window; @kbd{C-o}
1287does not select it. 1286does not select it.
1288 1287
1288Occur mode supports the @code{next-error} functionality described in
1289in @ref{Compilation Mode}.
1290
1289@item M-x list-matching-lines 1291@item M-x list-matching-lines
1290Synonym for @kbd{M-x occur}. 1292Synonym for @kbd{M-x occur}.
1291 1293
diff --git a/man/trouble.texi b/man/trouble.texi
index e7f6ae7608b..142560c1fe8 100644
--- a/man/trouble.texi
+++ b/man/trouble.texi
@@ -1,5 +1,5 @@
1@c This is part of the Emacs manual. 1@c This is part of the Emacs manual.
2@c Copyright (C) 1985,86,87,93,94,95,1997,2001 Free Software Foundation, Inc. 2@c Copyright (C) 1985,86,87,93,94,95,1997,2001,2004 Free Software Foundation, Inc.
3@c See file emacs.texi for copying conditions. 3@c See file emacs.texi for copying conditions.
4@iftex 4@iftex
5@chapter Dealing with Common Problems 5@chapter Dealing with Common Problems
@@ -10,6 +10,10 @@ recover from a mysterious situation. Emacs bugs and system crashes are
10also considered. 10also considered.
11@end iftex 11@end iftex
12 12
13@ifnottex
14@raisesections
15@end ifnottex
16
13@node Quitting, Lossage, Customization, Top 17@node Quitting, Lossage, Customization, Top
14@section Quitting and Aborting 18@section Quitting and Aborting
15@cindex quitting 19@cindex quitting
@@ -1044,7 +1048,7 @@ you have not yet started work, it is useful to contact
1044possible to suggest ways to make your extension fit in better with the 1048possible to suggest ways to make your extension fit in better with the
1045rest of Emacs. 1049rest of Emacs.
1046 1050
1047@node Service, Command Arguments, Contributing, Top 1051@node Service, Copying, Contributing, Top
1048@section How To Get Help with GNU Emacs 1052@section How To Get Help with GNU Emacs
1049 1053
1050If you need help installing, using or changing GNU Emacs, there are two 1054If you need help installing, using or changing GNU Emacs, there are two
@@ -1063,6 +1067,10 @@ The service directory is found in the file named @file{etc/SERVICE} in the
1063Emacs distribution. 1067Emacs distribution.
1064@end itemize 1068@end itemize
1065 1069
1070@ifnottex
1071@lowersections
1072@end ifnottex
1073
1066@ignore 1074@ignore
1067 arch-tag: c9cba76d-b2cb-4e0c-ae3f-19d5ef35817c 1075 arch-tag: c9cba76d-b2cb-4e0c-ae3f-19d5ef35817c
1068@end ignore 1076@end ignore
diff --git a/man/windows.texi b/man/windows.texi
index f9b4003f038..8416c4be076 100644
--- a/man/windows.texi
+++ b/man/windows.texi
@@ -1,5 +1,5 @@
1@c This is part of the Emacs manual. 1@c This is part of the Emacs manual.
2@c Copyright (C) 1985,86,87,93,94,95,97,2000,2001 Free Software Foundation, Inc. 2@c Copyright (C) 1985,86,87,93,94,95,97,2000,2001,2004 Free Software Foundation, Inc.
3@c See file emacs.texi for copying conditions. 3@c See file emacs.texi for copying conditions.
4@node Windows, Frames, Buffers, Top 4@node Windows, Frames, Buffers, Top
5@chapter Multiple Windows 5@chapter Multiple Windows
@@ -36,11 +36,11 @@ each window has its own value of point.
36 At any time, one of the windows is the @dfn{selected window}; the 36 At any time, one of the windows is the @dfn{selected window}; the
37buffer this window is displaying is the current buffer. The terminal's 37buffer this window is displaying is the current buffer. The terminal's
38cursor shows the location of point in this window. Each other window 38cursor shows the location of point in this window. Each other window
39has a location of point as well, but since the terminal has only one 39has a location of point as well. On text-only terminals, there is no
40cursor there is no way to show where those locations are. When multiple 40way to show where those locations are, since the terminal has only one
41frames are visible in X, each frame has a cursor which appears in the 41cursor. If you are using a window system, the location of point in a
42frame's selected window. The cursor in the selected frame is solid; the 42non-selected window is indicated by a hollow box. The cursor in the
43cursor in other frames is a hollow box. 43selected window is blinking or solid.
44 44
45 Commands to move point affect the value of point for the selected Emacs 45 Commands to move point affect the value of point for the selected Emacs
46window only. They do not change the value of point in any other Emacs 46window only. They do not change the value of point in any other Emacs
@@ -93,20 +93,20 @@ numeric argument specifies how many lines to give to the top window.
93@findex split-window-horizontally 93@findex split-window-horizontally
94 @kbd{C-x 3} (@code{split-window-horizontally}) breaks the selected 94 @kbd{C-x 3} (@code{split-window-horizontally}) breaks the selected
95window into two side-by-side windows. A numeric argument specifies how 95window into two side-by-side windows. A numeric argument specifies how
96many columns to give the one on the left. A line of vertical bars 96many columns to give the one on the left. If you are not using
97separates the two windows. Windows that are not the full width of the 97scrollbars, a line of vertical bars separates the two windows.
98screen have mode lines, but they are truncated. On terminals where 98Windows that are not the full width of the screen have mode lines, but
99Emacs does not support highlighting, truncated mode lines sometimes do 99they are truncated. On terminals where Emacs does not support
100not appear in inverse video. 100highlighting, truncated mode lines sometimes do not appear in inverse
101video.
101 102
102@kindex C-Mouse-2 @r{(scroll bar)} 103@kindex C-Mouse-2 @r{(scroll bar)}
103 You can split a window horizontally or vertically by clicking 104 You can split a window horizontally or vertically by clicking
104@kbd{C-Mouse-2} in the mode line or the scroll bar. (This does not 105@kbd{C-Mouse-2} in the mode line or the scroll bar. The line of
105work in scroll bars implemented by X toolkits.) The line of splitting 106splitting goes through the place where you click: if you click on the
106goes through the place where you click: if you click on the mode line, 107mode line, the new scroll bar goes above the spot; if you click in the
107the new scroll bar goes above the spot; if you click in the scroll 108scroll bar, the mode line of the split window is side by side with
108bar, the mode line of the split window is side by side with your 109your click.
109click.
110 110
111@vindex truncate-partial-width-windows 111@vindex truncate-partial-width-windows
112 When a window is less than the full width, text lines too long to fit are 112 When a window is less than the full width, text lines too long to fit are
@@ -319,8 +319,8 @@ the minibuffer); the selected window expands to use the whole frame
319except for the echo area. 319except for the echo area.
320 320
321 You can also delete a window by clicking on its mode line with 321 You can also delete a window by clicking on its mode line with
322@kbd{Mouse-2}, and delete all the windows in a frame except one window 322@kbd{Mouse-3}, and delete all the windows in a frame except one window
323by clicking on that window's mode line with @kbd{Mouse-3}. 323by clicking on that window's mode line with @kbd{Mouse-2}.
324 324
325 The easiest way to adjust window heights is with a mouse. If you 325 The easiest way to adjust window heights is with a mouse. If you
326press @kbd{Mouse-1} on a mode line, you can drag that mode line up or 326press @kbd{Mouse-1} on a mode line, you can drag that mode line up or
@@ -370,8 +370,8 @@ heights of all the windows in the selected frame.
370 @kbd{M-x winner-mode} is a global minor mode that records the 370 @kbd{M-x winner-mode} is a global minor mode that records the
371changes in the window configuration (i.e. how the frames are 371changes in the window configuration (i.e. how the frames are
372partitioned into windows), so that you can ``undo'' them. To undo, 372partitioned into windows), so that you can ``undo'' them. To undo,
373use @kbd{C-x left} (@code{winner-undo}). If you change your mind 373use @kbd{C-c left} (@code{winner-undo}). If you change your mind
374while undoing, you can redo the changes you had undone using @kbd{C-x 374while undoing, you can redo the changes you had undone using @kbd{C-c
375right} (@code{M-x winner-redo}). Another way to enable Winner mode is 375right} (@code{M-x winner-redo}). Another way to enable Winner mode is
376by customizing the variable @code{winner-mode}. 376by customizing the variable @code{winner-mode}.
377 377
diff --git a/src/ChangeLog b/src/ChangeLog
index aa3721d9106..8fd72a29c29 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,89 @@
12004-09-03 Jason Rumney <jasonr@gnu.org>
2
3 * w32menu.c (_widget_value): Added lname and lkey.
4 (digest_single_submenu): Set lname and lkey in widget_value
5 instead of name and key.
6 (update_submenu_strings): New function.
7 (set_frame_menubar): Remove call to inhibit_garbage_collection,
8 call update_submenu_strings.
9
10 * w32menu.c (globals_of_w32menu): Check for Unicode API.
11 (digest_single_submenu, w32_menu_show): Encode menu strings as
12 UTF-8 if Unicode API is available.
13 (utf8to16): New function.
14 (add_menu_item): Use it when calling Unicode API.
15
162004-09-03 Kim F. Storm <storm@cua.dk>
17
18 * xdisp.c (set_cursor_from_row): Look for non-nil `cursor' property
19 in overlay or text-property strings; set cursor on corresponding
20 glyph rather than at end of the string.
21
222004-09-02 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
23
24 * macfns.c (x_real_positions): Save the current window port and
25 set a new one before obtaining the global coordinate. Use
26 FRAME_MAC_WINDOW.
27 (x_set_name, x_set_title): Encode title to UTF8. Use
28 SetWindowTitleWithCFString.
29 (Fx_server_version): Get correct OS version.
30
31 * macmenu.c (add_menu_item): Remove unused variable `i'. Don't
32 let separator items destroy refence constants of other menu items.
33
34 * macterm.c (x_update_end): Move SetPortWindowPort to inside
35 BLOCK_INPUT.
36 (x_set_offset): Use FRAME_MAC_WINDOW.
37
38 * xdisp.c (note_mouse_highlight): Set the mouse pointer shape to
39 nontext_cursor if it is on a scroll bar.
40
41 * s/darwin.h (LIBS_CARBON): New define to specify libraries for
42 Carbon support.
43 (LD_SWITCH_SYSTEM_TEMACS): Don't link with unused libstdc++. Use
44 LIBS_CARBON.
45
462004-09-02 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
47
48 * xfns.c (x_set_name_internal): New function. Check if we shall call
49 xfree before ENCODE_UTF_8.
50 (x_set_name, x_set_title): Call x_set_name_internal.
51
522004-08-31 NAKAMURA Toshikazu <nr-tkz@nifty.com> (tiny change)
53
54 * w32fns.c (w32_load_font): If a BDF font is already loaded, do not
55 reload it.
56
572004-08-30 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
58
59 * macmenu.c (_widget_value): Added lname and lkey.
60 (single_submenu): Set lname and lkey in widget_value
61 instead of name and key.
62 (update_submenu_strings): New function.
63 (set_frame_menubar): Remove call to inhibit_garbage_collection,
64 call update_submenu_strings.
65
66 * xmenu.c (digest_single_submenu): Set lname and lkey in widget_value
67 instead of name and key.
68 (update_submenu_strings): New function.
69 (set_frame_menubar): Remove call to inhibit_garbage_collection,
70 call update_submenu_strings.
71
72 * gtkutil.h (_widget_value): Added lname and lkey.
73
742004-08-30 Steven Tamm <steventamm@mac.com>
75
76 * macmenu.c (mac_menu_show): Remove shadowing of menu variable
77 by using different names for inner loop variables.
78
792004-08-27 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
80
81 * xmenu.c (set_frame_menubar): Reintroduce inhibit_garbage_collection
82 from 2002-07-15T00:01:34Z!raeburn@raeburn.org so that strings from ENCODE_UTF_8 isn't GC:ed before used.
83
84 * gtkutil.c (xg_create_frame_widgets): Compensate for tool bar when
85 tool bar items is 0.
86
12004-08-26 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> 872004-08-26 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2 88
3 * macmenu.c (ENCODE_MENU_STRING): Added to handle multibyte 89 * macmenu.c (ENCODE_MENU_STRING): Added to handle multibyte
diff --git a/src/fileio.c b/src/fileio.c
index 66b7d8b83fc..8290f01b58e 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -6217,7 +6217,7 @@ and `read-file-name-function'. */)
6217 6217
6218 GCPRO2 (insdef, default_filename); 6218 GCPRO2 (insdef, default_filename);
6219 6219
6220#if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK) || defined(TARGET_API_MAC_CARBON) 6220#if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK) || defined (TARGET_API_MAC_CARBON)
6221 if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event)) 6221 if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
6222 && use_dialog_box 6222 && use_dialog_box
6223 && use_file_dialog 6223 && use_file_dialog
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 3ffba0ba745..fabdae74dc6 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -793,7 +793,7 @@ xg_create_frame_widgets (f)
793 up in the wrong place as tool bar height has not been taken into account. 793 up in the wrong place as tool bar height has not been taken into account.
794 So we cheat a bit by setting a height that is what it will have 794 So we cheat a bit by setting a height that is what it will have
795 later on when tool bar items are added. */ 795 later on when tool bar items are added. */
796 if (FRAME_EXTERNAL_TOOL_BAR (f) && FRAME_TOOLBAR_HEIGHT (f) == 0) 796 if (FRAME_EXTERNAL_TOOL_BAR (f) && f->n_tool_bar_items == 0)
797 FRAME_TOOLBAR_HEIGHT (f) = 34; 797 FRAME_TOOLBAR_HEIGHT (f) = 34;
798 798
799 799
diff --git a/src/gtkutil.h b/src/gtkutil.h
index b31ec8c2a1f..b35ab94b2cb 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -96,10 +96,12 @@ typedef struct xg_menu_item_cb_data_
96typedef struct _widget_value 96typedef struct _widget_value
97{ 97{
98 /* name of widget */ 98 /* name of widget */
99 Lisp_Object lname;
99 char *name; 100 char *name;
100 /* value (meaning depend on widget type) */ 101 /* value (meaning depend on widget type) */
101 char *value; 102 char *value;
102 /* keyboard equivalent. no implications for XtTranslations */ 103 /* keyboard equivalent. no implications for XtTranslations */
104 Lisp_Object lkey;
103 char *key; 105 char *key;
104 /* Help string or nil if none. 106 /* Help string or nil if none.
105 GC finds this string through the frame's menu_bar_vector 107 GC finds this string through the frame's menu_bar_vector
diff --git a/src/macfns.c b/src/macfns.c
index fbade05ea17..3b09b344a55 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -324,19 +324,21 @@ x_real_positions (f, xptr, yptr)
324 Point pt; 324 Point pt;
325 GrafPtr oldport; 325 GrafPtr oldport;
326 326
327#ifdef TARGET_API_MAC_CARBON 327 GetPort (&oldport);
328 SetPortWindowPort (FRAME_MAC_WINDOW (f));
329
330#if TARGET_API_MAC_CARBON
328 { 331 {
329 Rect r; 332 Rect r;
330 333
331 GetWindowPortBounds (f->output_data.mac->mWP, &r); 334 GetWindowPortBounds (FRAME_MAC_WINDOW (f), &r);
332 SetPt (&pt, r.left, r.top); 335 SetPt (&pt, r.left, r.top);
333 } 336 }
334#else /* not TARGET_API_MAC_CARBON */ 337#else /* not TARGET_API_MAC_CARBON */
335 SetPt (&pt, 338 SetPt (&pt,
336 f->output_data.mac->mWP->portRect.left, 339 FRAME_MAC_WINDOW (f)->portRect.left,
337 f->output_data.mac->mWP->portRect.top); 340 FRAME_MAC_WINDOW (f)->portRect.top);
338#endif /* not TARGET_API_MAC_CARBON */ 341#endif /* not TARGET_API_MAC_CARBON */
339 GetPort (&oldport);
340 LocalToGlobal (&pt); 342 LocalToGlobal (&pt);
341 SetPort (oldport); 343 SetPort (oldport);
342 344
@@ -1934,8 +1936,8 @@ x_set_name (f, name, explicit)
1934 if (FRAME_MAC_WINDOW (f)) 1936 if (FRAME_MAC_WINDOW (f))
1935 { 1937 {
1936 if (STRING_MULTIBYTE (name)) 1938 if (STRING_MULTIBYTE (name))
1937#if 0 /* MAC_TODO: encoding title string */ 1939#if TARGET_API_MAC_CARBON
1938 name = ENCODE_SYSTEM (name); 1940 name = ENCODE_UTF_8 (name);
1939#else 1941#else
1940 return; 1942 return;
1941#endif 1943#endif
@@ -1943,6 +1945,14 @@ x_set_name (f, name, explicit)
1943 BLOCK_INPUT; 1945 BLOCK_INPUT;
1944 1946
1945 { 1947 {
1948#if TARGET_API_MAC_CARBON
1949 CFStringRef windowTitle =
1950 CFStringCreateWithCString (NULL, SDATA (name),
1951 kCFStringEncodingUTF8);
1952
1953 SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle);
1954 CFRelease (windowTitle);
1955#else
1946 Str255 windowTitle; 1956 Str255 windowTitle;
1947 if (strlen (SDATA (name)) < 255) 1957 if (strlen (SDATA (name)) < 255)
1948 { 1958 {
@@ -1950,6 +1960,7 @@ x_set_name (f, name, explicit)
1950 c2pstr (windowTitle); 1960 c2pstr (windowTitle);
1951 SetWTitle (FRAME_MAC_WINDOW (f), windowTitle); 1961 SetWTitle (FRAME_MAC_WINDOW (f), windowTitle);
1952 } 1962 }
1963#endif
1953 } 1964 }
1954 1965
1955 UNBLOCK_INPUT; 1966 UNBLOCK_INPUT;
@@ -2008,8 +2019,8 @@ x_set_title (f, name, old_name)
2008 if (FRAME_MAC_WINDOW (f)) 2019 if (FRAME_MAC_WINDOW (f))
2009 { 2020 {
2010 if (STRING_MULTIBYTE (name)) 2021 if (STRING_MULTIBYTE (name))
2011#if 0 /* MAC_TODO: encoding title string */ 2022#if TARGET_API_MAC_CARBON
2012 name = ENCODE_SYSTEM (name); 2023 name = ENCODE_UTF_8 (name);
2013#else 2024#else
2014 return; 2025 return;
2015#endif 2026#endif
@@ -2017,6 +2028,14 @@ x_set_title (f, name, old_name)
2017 BLOCK_INPUT; 2028 BLOCK_INPUT;
2018 2029
2019 { 2030 {
2031#if TARGET_API_MAC_CARBON
2032 CFStringRef windowTitle =
2033 CFStringCreateWithCString (NULL, SDATA (name),
2034 kCFStringEncodingUTF8);
2035
2036 SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle);
2037 CFRelease (windowTitle);
2038#else
2020 Str255 windowTitle; 2039 Str255 windowTitle;
2021 if (strlen (SDATA (name)) < 255) 2040 if (strlen (SDATA (name)) < 255)
2022 { 2041 {
@@ -2024,6 +2043,7 @@ x_set_title (f, name, old_name)
2024 c2pstr (windowTitle); 2043 c2pstr (windowTitle);
2025 SetWTitle (FRAME_MAC_WINDOW (f), windowTitle); 2044 SetWTitle (FRAME_MAC_WINDOW (f), windowTitle);
2026 } 2045 }
2046#endif
2027 } 2047 }
2028 2048
2029 UNBLOCK_INPUT; 2049 UNBLOCK_INPUT;
@@ -2981,17 +3001,20 @@ If omitted or nil, that stands for the selected frame's display. */)
2981 (display) 3001 (display)
2982 Lisp_Object display; 3002 Lisp_Object display;
2983{ 3003{
2984 int mac_major_version, mac_minor_version; 3004 int mac_major_version;
2985 SInt32 response; 3005 SInt32 response;
2986 3006
2987 if (Gestalt (gestaltSystemVersion, &response) != noErr) 3007 if (Gestalt (gestaltSystemVersion, &response) != noErr)
2988 error ("Cannot get Mac OS version"); 3008 error ("Cannot get Mac OS version");
2989 3009
2990 mac_major_version = (response >> 8) & 0xf; 3010 mac_major_version = (response >> 8) & 0xff;
2991 mac_minor_version = (response >> 4) & 0xf; 3011 /* convert BCD to int */
3012 mac_major_version -= (mac_major_version >> 4) * 6;
2992 3013
2993 return Fcons (make_number (mac_major_version), 3014 return Fcons (make_number (mac_major_version),
2994 Fcons (make_number (mac_minor_version), Qnil)); 3015 Fcons (make_number ((response >> 4) & 0xf),
3016 Fcons (make_number (response & 0xf),
3017 Qnil)));
2995} 3018}
2996 3019
2997DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0, 3020DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0,
diff --git a/src/macmenu.c b/src/macmenu.c
index 67e18481a1b..740bda261d8 100644
--- a/src/macmenu.c
+++ b/src/macmenu.c
@@ -90,10 +90,12 @@ enum button_type
90typedef struct _widget_value 90typedef struct _widget_value
91{ 91{
92 /* name of widget */ 92 /* name of widget */
93 Lisp_Object lname;
93 char* name; 94 char* name;
94 /* value (meaning depend on widget type) */ 95 /* value (meaning depend on widget type) */
95 char* value; 96 char* value;
96 /* keyboard equivalent. no implications for XtTranslations */ 97 /* keyboard equivalent. no implications for XtTranslations */
98 Lisp_Object lkey;
97 char* key; 99 char* key;
98 /* Help string or nil if none. 100 /* Help string or nil if none.
99 GC finds this string through the frame's menu_bar_vector 101 GC finds this string through the frame's menu_bar_vector
@@ -1221,12 +1223,9 @@ single_submenu (item_key, item_name, maps)
1221 save_wv->next = wv; 1223 save_wv->next = wv;
1222 else 1224 else
1223 first_wv->contents = wv; 1225 first_wv->contents = wv;
1224 wv->name = pane_string; 1226 wv->lname = pane_name;
1225 /* Ignore the @ that means "separate pane". 1227 /* Set value to 1 so update_submenu_strings can handle '@' */
1226 This is a kludge, but this isn't worth more time. */ 1228 wv->value = (char *)1;
1227 if (!NILP (prefix) && wv->name[0] == '@')
1228 wv->name++;
1229 wv->value = 0;
1230 wv->enabled = 1; 1229 wv->enabled = 1;
1231 wv->button_type = BUTTON_TYPE_NONE; 1230 wv->button_type = BUTTON_TYPE_NONE;
1232 wv->help = Qnil; 1231 wv->help = Qnil;
@@ -1269,9 +1268,9 @@ single_submenu (item_key, item_name, maps)
1269 else 1268 else
1270 save_wv->contents = wv; 1269 save_wv->contents = wv;
1271 1270
1272 wv->name = (char *) SDATA (item_name); 1271 wv->lname = item_name;
1273 if (!NILP (descrip)) 1272 if (!NILP (descrip))
1274 wv->key = (char *) SDATA (descrip); 1273 wv->lkey = descrip;
1275 wv->value = 0; 1274 wv->value = 0;
1276 /* The EMACS_INT cast avoids a warning. There's no problem 1275 /* The EMACS_INT cast avoids a warning. There's no problem
1277 as long as pointers have enough bits to hold small integers. */ 1276 as long as pointers have enough bits to hold small integers. */
@@ -1310,6 +1309,41 @@ single_submenu (item_key, item_name, maps)
1310 1309
1311 return first_wv; 1310 return first_wv;
1312} 1311}
1312/* Walk through the widget_value tree starting at FIRST_WV and update
1313 the char * pointers from the corresponding lisp values.
1314 We do this after building the whole tree, since GC may happen while the
1315 tree is constructed, and small strings are relocated. So we must wait
1316 until no GC can happen before storing pointers into lisp values. */
1317static void
1318update_submenu_strings (first_wv)
1319 widget_value *first_wv;
1320{
1321 widget_value *wv;
1322
1323 for (wv = first_wv; wv; wv = wv->next)
1324 {
1325 if (wv->lname && ! NILP (wv->lname))
1326 {
1327 wv->name = SDATA (wv->lname);
1328
1329 /* Ignore the @ that means "separate pane".
1330 This is a kludge, but this isn't worth more time. */
1331 if (wv->value == (char *)1)
1332 {
1333 if (wv->name[0] == '@')
1334 wv->name++;
1335 wv->value = 0;
1336 }
1337 }
1338
1339 if (wv->lkey && ! NILP (wv->lkey))
1340 wv->key = SDATA (wv->lkey);
1341
1342 if (wv->contents)
1343 update_submenu_strings (wv->contents);
1344 }
1345}
1346
1313 1347
1314/* Set the contents of the menubar widgets of frame F. 1348/* Set the contents of the menubar widgets of frame F.
1315 The argument FIRST_TIME is currently ignored; 1349 The argument FIRST_TIME is currently ignored;
@@ -1388,8 +1422,6 @@ set_frame_menubar (f, first_time, deep_p)
1388 1422
1389 items = FRAME_MENU_BAR_ITEMS (f); 1423 items = FRAME_MENU_BAR_ITEMS (f);
1390 1424
1391 inhibit_garbage_collection ();
1392
1393 /* Save the frame's previous menu bar contents data. */ 1425 /* Save the frame's previous menu bar contents data. */
1394 if (previous_menu_items_used) 1426 if (previous_menu_items_used)
1395 bcopy (XVECTOR (f->menu_bar_vector)->contents, previous_items, 1427 bcopy (XVECTOR (f->menu_bar_vector)->contents, previous_items,
@@ -1454,6 +1486,7 @@ set_frame_menubar (f, first_time, deep_p)
1454 if (NILP (string)) 1486 if (NILP (string))
1455 break; 1487 break;
1456 wv->name = (char *) SDATA (string); 1488 wv->name = (char *) SDATA (string);
1489 update_submenu_strings (wv->contents);
1457 wv = wv->next; 1490 wv = wv->next;
1458 } 1491 }
1459 1492
@@ -1807,9 +1840,9 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
1807 /* Get the refcon to find the correct item*/ 1840 /* Get the refcon to find the correct item*/
1808 if (menu_item_selection) 1841 if (menu_item_selection)
1809 { 1842 {
1810 menu = GetMenuHandle (HiWord (menu_item_choice)); 1843 MenuHandle sel_menu = GetMenuHandle (HiWord (menu_item_choice));
1811 if (menu) { 1844 if (sel_menu) {
1812 GetMenuItemRefCon (menu, menu_item_selection, &refcon); 1845 GetMenuItemRefCon (sel_menu, menu_item_selection, &refcon);
1813 } 1846 }
1814 } 1847 }
1815 1848
@@ -1831,11 +1864,11 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
1831 { 1864 {
1832 int i = MIN_POPUP_SUBMENU_ID; 1865 int i = MIN_POPUP_SUBMENU_ID;
1833 MenuHandle submenu = GetMenuHandle (i); 1866 MenuHandle submenu = GetMenuHandle (i);
1834 while (menu != NULL) 1867 while (submenu != NULL)
1835 { 1868 {
1836 DeleteMenu (i); 1869 DeleteMenu (i);
1837 DisposeMenu (menu); 1870 DisposeMenu (submenu);
1838 menu = GetMenuHandle (++i); 1871 submenu = GetMenuHandle (++i);
1839 } 1872 }
1840 } 1873 }
1841 1874
@@ -2207,7 +2240,7 @@ add_menu_item (MenuHandle menu, widget_value *wv, int submenu,
2207 int force_disable) 2240 int force_disable)
2208{ 2241{
2209 Str255 item_name; 2242 Str255 item_name;
2210 int pos, i; 2243 int pos;
2211 2244
2212 if (name_is_separator (wv->name)) 2245 if (name_is_separator (wv->name))
2213 AppendMenu (menu, "\p-"); 2246 AppendMenu (menu, "\p-");
@@ -2263,9 +2296,9 @@ add_menu_item (MenuHandle menu, widget_value *wv, int submenu,
2263 else 2296 else
2264 SetItemMark (menu, pos, noMark); 2297 SetItemMark (menu, pos, noMark);
2265 } 2298 }
2266 }
2267 2299
2268 SetMenuItemRefCon (menu, pos, (UInt32) wv->call_data); 2300 SetMenuItemRefCon (menu, pos, (UInt32) wv->call_data);
2301 }
2269 2302
2270 if (submenu != NULL) 2303 if (submenu != NULL)
2271 SetMenuItemHierarchicalID (menu, pos, submenu); 2304 SetMenuItemHierarchicalID (menu, pos, submenu);
diff --git a/src/macterm.c b/src/macterm.c
index 297683f6d9b..e1b8d49ddfa 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -1327,6 +1327,10 @@ static void
1327x_update_end (f) 1327x_update_end (f)
1328 struct frame *f; 1328 struct frame *f;
1329{ 1329{
1330 /* Mouse highlight may be displayed again. */
1331 FRAME_MAC_DISPLAY_INFO (f)->mouse_face_defer = 0;
1332
1333 BLOCK_INPUT;
1330 /* Reset the background color of Mac OS Window to that of the frame after 1334 /* Reset the background color of Mac OS Window to that of the frame after
1331 update so that it is used by Mac Toolbox to clear the update region before 1335 update so that it is used by Mac Toolbox to clear the update region before
1332 an update event is generated. */ 1336 an update event is generated. */
@@ -1334,10 +1338,6 @@ x_update_end (f)
1334 1338
1335 mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f)); 1339 mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));
1336 1340
1337 /* Mouse highlight may be displayed again. */
1338 FRAME_MAC_DISPLAY_INFO (f)->mouse_face_defer = 0;
1339
1340 BLOCK_INPUT;
1341 XFlush (FRAME_MAC_DISPLAY (f)); 1341 XFlush (FRAME_MAC_DISPLAY (f));
1342 UNBLOCK_INPUT; 1342 UNBLOCK_INPUT;
1343} 1343}
@@ -5140,7 +5140,7 @@ x_set_offset (f, xoff, yoff, change_gravity)
5140 modified_left = f->left_pos; 5140 modified_left = f->left_pos;
5141 modified_top = f->top_pos; 5141 modified_top = f->top_pos;
5142 5142
5143 MoveWindow (f->output_data.mac->mWP, modified_left + 6, 5143 MoveWindow (FRAME_MAC_WINDOW (f), modified_left + 6,
5144 modified_top + 42, false); 5144 modified_top + 42, false);
5145 5145
5146 UNBLOCK_INPUT; 5146 UNBLOCK_INPUT;
diff --git a/src/s/darwin.h b/src/s/darwin.h
index 814de2c2c51..f854ed9380b 100644
--- a/src/s/darwin.h
+++ b/src/s/darwin.h
@@ -243,11 +243,18 @@ Boston, MA 02111-1307, USA. */
243 specific headers. */ 243 specific headers. */
244#define C_SWITCH_SYSTEM -fpascal-strings -fno-common -DMAC_OSX -I../mac/src 244#define C_SWITCH_SYSTEM -fpascal-strings -fno-common -DMAC_OSX -I../mac/src
245 245
246/* Link in the Carbon lib. The -headerpad option tells ld (see man 246/* Link in the Carbon lib. */
247 page) to leave room at the end of the header for adding load 247#ifdef HAVE_CARBON
248 commands. Needed for dumping. 0x690 is the total size of 30 248#define LIBS_CARBON -framework Carbon -framework QuickTime
249 segment load commands (at 56 each). */ 249#else
250#define LD_SWITCH_SYSTEM_TEMACS -prebind -framework Carbon -framework QuickTime -lstdc++ -Xlinker -headerpad -Xlinker 690 250#define LIBS_CARBON -framework Carbon
251#endif
252
253/* The -headerpad option tells ld (see man page) to leave room at the
254 end of the header for adding load commands. Needed for dumping.
255 0x690 is the total size of 30 segment load commands (at 56
256 each). */
257#define LD_SWITCH_SYSTEM_TEMACS -prebind LIBS_CARBON -Xlinker -headerpad -Xlinker 690
251 258
252#define C_SWITCH_SYSTEM_TEMACS -Dtemacs 259#define C_SWITCH_SYSTEM_TEMACS -Dtemacs
253 260
diff --git a/src/w32fns.c b/src/w32fns.c
index 3599078b3a3..d2231772bf4 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -4644,6 +4644,7 @@ int size;
4644{ 4644{
4645 Lisp_Object bdf_fonts; 4645 Lisp_Object bdf_fonts;
4646 struct font_info *retval = NULL; 4646 struct font_info *retval = NULL;
4647 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);
4647 4648
4648 bdf_fonts = w32_list_bdf_fonts (build_string (fontname), 1); 4649 bdf_fonts = w32_list_bdf_fonts (build_string (fontname), 1);
4649 4650
@@ -4651,11 +4652,22 @@ int size;
4651 { 4652 {
4652 char *bdf_name, *bdf_file; 4653 char *bdf_name, *bdf_file;
4653 Lisp_Object bdf_pair; 4654 Lisp_Object bdf_pair;
4655 int i;
4654 4656
4655 bdf_name = SDATA (XCAR (bdf_fonts)); 4657 bdf_name = SDATA (XCAR (bdf_fonts));
4656 bdf_pair = Fassoc (XCAR (bdf_fonts), Vw32_bdf_filename_alist); 4658 bdf_pair = Fassoc (XCAR (bdf_fonts), Vw32_bdf_filename_alist);
4657 bdf_file = SDATA (XCDR (bdf_pair)); 4659 bdf_file = SDATA (XCDR (bdf_pair));
4658 4660
4661 // If the font is already loaded, do not load it again.
4662 for (i = 0; i < dpyinfo->n_fonts; i++)
4663 {
4664 if ((dpyinfo->font_table[i].name
4665 && !strcmp (dpyinfo->font_table[i].name, bdf_name))
4666 || (dpyinfo->font_table[i].full_name
4667 && !strcmp (dpyinfo->font_table[i].full_name, bdf_name)))
4668 return dpyinfo->font_table + i;
4669 }
4670
4659 retval = w32_load_bdf_font (f, bdf_name, size, bdf_file); 4671 retval = w32_load_bdf_font (f, bdf_name, size, bdf_file);
4660 4672
4661 bdf_fonts = XCDR (bdf_fonts); 4673 bdf_fonts = XCDR (bdf_fonts);
diff --git a/src/w32menu.c b/src/w32menu.c
index cc0932d7bf5..f3f3eb785b0 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -45,7 +45,6 @@ Boston, MA 02111-1307, USA. */
45 45
46#include "dispextern.h" 46#include "dispextern.h"
47 47
48#undef HAVE_MULTILINGUAL_MENU
49#undef HAVE_DIALOGS /* TODO: Implement native dialogs. */ 48#undef HAVE_DIALOGS /* TODO: Implement native dialogs. */
50 49
51/******************************************************************/ 50/******************************************************************/
@@ -66,10 +65,12 @@ enum button_type
66typedef struct _widget_value 65typedef struct _widget_value
67{ 66{
68 /* name of widget */ 67 /* name of widget */
68 Lisp_Object lname;
69 char* name; 69 char* name;
70 /* value (meaning depend on widget type) */ 70 /* value (meaning depend on widget type) */
71 char* value; 71 char* value;
72 /* keyboard equivalent. no implications for XtTranslations */ 72 /* keyboard equivalent. no implications for XtTranslations */
73 Lisp_Object lkey;
73 char* key; 74 char* key;
74 /* Help string or nil if none. 75 /* Help string or nil if none.
75 GC finds this string through the frame's menu_bar_vector 76 GC finds this string through the frame's menu_bar_vector
@@ -136,17 +137,21 @@ typedef BOOL (WINAPI * GetMenuItemInfoA_Proc) (
136 IN HMENU, 137 IN HMENU,
137 IN UINT, 138 IN UINT,
138 IN BOOL, 139 IN BOOL,
139 IN OUT LPMENUITEMINFOA 140 IN OUT LPMENUITEMINFOA);
140 );
141typedef BOOL (WINAPI * SetMenuItemInfoA_Proc) ( 141typedef BOOL (WINAPI * SetMenuItemInfoA_Proc) (
142 IN HMENU, 142 IN HMENU,
143 IN UINT, 143 IN UINT,
144 IN BOOL, 144 IN BOOL,
145 IN LPCMENUITEMINFOA 145 IN LPCMENUITEMINFOA);
146 ); 146typedef BOOL (WINAPI * AppendMenuW_Proc) (
147 IN HMENU,
148 IN UINT,
149 IN UINT_PTR,
150 IN LPCWSTR);
147 151
148GetMenuItemInfoA_Proc get_menu_item_info=NULL; 152GetMenuItemInfoA_Proc get_menu_item_info = NULL;
149SetMenuItemInfoA_Proc set_menu_item_info=NULL; 153SetMenuItemInfoA_Proc set_menu_item_info = NULL;
154AppendMenuW_Proc unicode_append_menu = NULL;
150 155
151Lisp_Object Vmenu_updating_frame; 156Lisp_Object Vmenu_updating_frame;
152 157
@@ -1235,13 +1240,17 @@ digest_single_submenu (start, end, top_level_items)
1235 pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME); 1240 pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME);
1236 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX); 1241 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
1237 1242
1238#ifndef HAVE_MULTILINGUAL_MENU 1243 if (STRINGP (pane_name))
1239 if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name))
1240 { 1244 {
1241 pane_name = ENCODE_SYSTEM (pane_name); 1245 if (unicode_append_menu)
1246 /* Encode as UTF-8 for now. */
1247 pane_name = ENCODE_UTF_8 (pane_name);
1248 else if (STRING_MULTIBYTE (pane_name))
1249 pane_name = ENCODE_SYSTEM (pane_name);
1250
1242 ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name); 1251 ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
1243 } 1252 }
1244#endif 1253
1245 pane_string = (NILP (pane_name) 1254 pane_string = (NILP (pane_name)
1246 ? "" : (char *) SDATA (pane_name)); 1255 ? "" : (char *) SDATA (pane_name));
1247 /* If there is just one top-level pane, put all its items directly 1256 /* If there is just one top-level pane, put all its items directly
@@ -1259,12 +1268,9 @@ digest_single_submenu (start, end, top_level_items)
1259 save_wv->next = wv; 1268 save_wv->next = wv;
1260 else 1269 else
1261 first_wv->contents = wv; 1270 first_wv->contents = wv;
1262 wv->name = pane_string; 1271 wv->lname = pane_name;
1263 /* Ignore the @ that means "separate pane". 1272 /* Set value to 1 so update_submenu_strings can handle '@' */
1264 This is a kludge, but this isn't worth more time. */ 1273 wv->value = (char *) 1;
1265 if (!NILP (prefix) && wv->name[0] == '@')
1266 wv->name++;
1267 wv->value = 0;
1268 wv->enabled = 1; 1274 wv->enabled = 1;
1269 wv->button_type = BUTTON_TYPE_NONE; 1275 wv->button_type = BUTTON_TYPE_NONE;
1270 wv->help = Qnil; 1276 wv->help = Qnil;
@@ -1287,10 +1293,13 @@ digest_single_submenu (start, end, top_level_items)
1287 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED); 1293 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
1288 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP); 1294 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
1289 1295
1290#ifndef HAVE_MULTILINGUAL_MENU 1296 if (STRINGP (item_name))
1291 if (STRING_MULTIBYTE (item_name))
1292 { 1297 {
1293 item_name = ENCODE_SYSTEM (item_name); 1298 if (unicode_append_menu)
1299 item_name = ENCODE_UTF_8 (item_name);
1300 else if (STRING_MULTIBYTE (item_name))
1301 item_name = ENCODE_SYSTEM (item_name);
1302
1294 ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name); 1303 ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name);
1295 } 1304 }
1296 1305
@@ -1299,7 +1308,6 @@ digest_single_submenu (start, end, top_level_items)
1299 descrip = ENCODE_SYSTEM (descrip); 1308 descrip = ENCODE_SYSTEM (descrip);
1300 ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip); 1309 ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
1301 } 1310 }
1302#endif /* not HAVE_MULTILINGUAL_MENU */
1303 1311
1304 wv = xmalloc_widget_value (); 1312 wv = xmalloc_widget_value ();
1305 if (prev_wv) 1313 if (prev_wv)
@@ -1307,9 +1315,9 @@ digest_single_submenu (start, end, top_level_items)
1307 else 1315 else
1308 save_wv->contents = wv; 1316 save_wv->contents = wv;
1309 1317
1310 wv->name = (char *) SDATA (item_name); 1318 wv->lname = item_name;
1311 if (!NILP (descrip)) 1319 if (!NILP (descrip))
1312 wv->key = (char *) SDATA (descrip); 1320 wv->lkey = descrip;
1313 wv->value = 0; 1321 wv->value = 0;
1314 /* The EMACS_INT cast avoids a warning. There's no problem 1322 /* The EMACS_INT cast avoids a warning. There's no problem
1315 as long as pointers have enough bits to hold small integers. */ 1323 as long as pointers have enough bits to hold small integers. */
@@ -1348,6 +1356,43 @@ digest_single_submenu (start, end, top_level_items)
1348 1356
1349 return first_wv; 1357 return first_wv;
1350} 1358}
1359
1360
1361/* Walk through the widget_value tree starting at FIRST_WV and update
1362 the char * pointers from the corresponding lisp values.
1363 We do this after building the whole tree, since GC may happen while the
1364 tree is constructed, and small strings are relocated. So we must wait
1365 until no GC can happen before storing pointers into lisp values. */
1366static void
1367update_submenu_strings (first_wv)
1368 widget_value *first_wv;
1369{
1370 widget_value *wv;
1371
1372 for (wv = first_wv; wv; wv = wv->next)
1373 {
1374 if (wv->lname && ! NILP (wv->lname))
1375 {
1376 wv->name = SDATA (wv->lname);
1377
1378 /* Ignore the @ that means "separate pane".
1379 This is a kludge, but this isn't worth more time. */
1380 if (wv->value == (char *)1)
1381 {
1382 if (wv->name[0] == '@')
1383 wv->name++;
1384 wv->value = 0;
1385 }
1386 }
1387
1388 if (wv->lkey && ! NILP (wv->lkey))
1389 wv->key = SDATA (wv->lkey);
1390
1391 if (wv->contents)
1392 update_submenu_strings (wv->contents);
1393 }
1394}
1395
1351 1396
1352/* Set the contents of the menubar widgets of frame F. 1397/* Set the contents of the menubar widgets of frame F.
1353 The argument FIRST_TIME is currently ignored; 1398 The argument FIRST_TIME is currently ignored;
@@ -1516,6 +1561,7 @@ set_frame_menubar (f, first_time, deep_p)
1516 if (NILP (string)) 1561 if (NILP (string))
1517 break; 1562 break;
1518 wv->name = (char *) SDATA (string); 1563 wv->name = (char *) SDATA (string);
1564 update_submenu_strings (wv->contents);
1519 wv = wv->next; 1565 wv = wv->next;
1520 } 1566 }
1521 1567
@@ -1729,13 +1775,17 @@ w32_menu_show (f, x, y, for_click, keymaps, title, error)
1729 char *pane_string; 1775 char *pane_string;
1730 pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME); 1776 pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME);
1731 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX); 1777 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
1732#ifndef HAVE_MULTILINGUAL_MENU 1778
1733 if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name)) 1779 if (STRINGP (pane_name))
1734 { 1780 {
1735 pane_name = ENCODE_SYSTEM (pane_name); 1781 if (unicode_append_menu)
1782 pane_name = ENCODE_UTF_8 (pane_name);
1783 else if (STRING_MULTIBYTE (pane_name))
1784 pane_name = ENCODE_SYSTEM (pane_name);
1785
1736 ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name); 1786 ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
1737 } 1787 }
1738#endif 1788
1739 pane_string = (NILP (pane_name) 1789 pane_string = (NILP (pane_name)
1740 ? "" : (char *) SDATA (pane_name)); 1790 ? "" : (char *) SDATA (pane_name));
1741 /* If there is just one top-level pane, put all its items directly 1791 /* If there is just one top-level pane, put all its items directly
@@ -1784,18 +1834,21 @@ w32_menu_show (f, x, y, for_click, keymaps, title, error)
1784 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED); 1834 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
1785 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP); 1835 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
1786 1836
1787#ifndef HAVE_MULTILINGUAL_MENU 1837 if (STRINGP (item_name))
1788 if (STRINGP (item_name) && STRING_MULTIBYTE (item_name))
1789 { 1838 {
1790 item_name = ENCODE_SYSTEM (item_name); 1839 if (unicode_append_menu)
1840 item_name = ENCODE_UTF_8 (item_name);
1841 else if (STRING_MULTIBYTE (item_name))
1842 item_name = ENCODE_SYSTEM (item_name);
1843
1791 ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name); 1844 ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name);
1792 } 1845 }
1793 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) 1846
1847 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
1794 { 1848 {
1795 descrip = ENCODE_SYSTEM (descrip); 1849 descrip = ENCODE_SYSTEM (descrip);
1796 ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip); 1850 ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
1797 } 1851 }
1798#endif /* not HAVE_MULTILINGUAL_MENU */
1799 1852
1800 wv = xmalloc_widget_value (); 1853 wv = xmalloc_widget_value ();
1801 if (prev_wv) 1854 if (prev_wv)
@@ -1844,10 +1897,11 @@ w32_menu_show (f, x, y, for_click, keymaps, title, error)
1844 wv_sep->next = first_wv->contents; 1897 wv_sep->next = first_wv->contents;
1845 wv_sep->help = Qnil; 1898 wv_sep->help = Qnil;
1846 1899
1847#ifndef HAVE_MULTILINGUAL_MENU 1900 if (unicode_append_menu)
1848 if (STRING_MULTIBYTE (title)) 1901 title = ENCODE_UTF_8 (title);
1902 else if (STRING_MULTIBYTE (title))
1849 title = ENCODE_SYSTEM (title); 1903 title = ENCODE_SYSTEM (title);
1850#endif 1904
1851 wv_title->name = (char *) SDATA (title); 1905 wv_title->name = (char *) SDATA (title);
1852 wv_title->enabled = TRUE; 1906 wv_title->enabled = TRUE;
1853 wv_title->title = TRUE; 1907 wv_title->title = TRUE;
@@ -2150,6 +2204,46 @@ add_left_right_boundary (HMENU menu)
2150 return AppendMenu (menu, MF_MENUBARBREAK, 0, NULL); 2204 return AppendMenu (menu, MF_MENUBARBREAK, 0, NULL);
2151} 2205}
2152 2206
2207/* UTF8: 0xxxxxxx, 110xxxxx 10xxxxxx, 1110xxxx, 10xxxxxx, 10xxxxxx */
2208static void
2209utf8to16 (unsigned char * src, int len, WCHAR * dest)
2210{
2211 while (len > 0)
2212 {
2213 int utf16;
2214 if (*src < 0x80)
2215 {
2216 *dest = (WCHAR) *src;
2217 dest++; src++; len--;
2218 }
2219 /* Since we might get >3 byte sequences which we don't handle, ignore the extra parts. */
2220 else if (*src < 0xC0)
2221 {
2222 src++; len--;
2223 }
2224 /* 2 char UTF-8 sequence. */
2225 else if (*src < 0xE0)
2226 {
2227 *dest = (WCHAR) (((*src & 0x1f) << 6)
2228 | (*(src + 1) & 0x3f));
2229 src += 2; len -= 2; dest++;
2230 }
2231 else if (*src < 0xF0)
2232 {
2233 *dest = (WCHAR) (((*src & 0x0f) << 12)
2234 | ((*(src + 1) & 0x3f) << 6)
2235 | (*(src + 2) & 0x3f));
2236 src += 3; len -= 3; dest++;
2237 }
2238 else /* Not encodable. Insert Unicode Substitution char. */
2239 {
2240 *dest = (WCHAR) 0xfffd;
2241 src++; len--; dest++;
2242 }
2243 }
2244 *dest = 0;
2245}
2246
2153static int 2247static int
2154add_menu_item (HMENU menu, widget_value *wv, HMENU item) 2248add_menu_item (HMENU menu, widget_value *wv, HMENU item)
2155{ 2249{
@@ -2206,11 +2300,32 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
2206 fuFlags |= MF_UNCHECKED; 2300 fuFlags |= MF_UNCHECKED;
2207 } 2301 }
2208 2302
2209 return_value = 2303 if (unicode_append_menu && out_string)
2210 AppendMenu (menu, 2304 {
2211 fuFlags, 2305 /* Convert out_string from UTF-8 to UTF-16-LE. */
2212 item != NULL ? (UINT) item : (UINT) wv->call_data, 2306 int utf8_len = strlen (out_string);
2213 out_string ); 2307 WCHAR * utf16_string;
2308 if (fuFlags & MF_OWNERDRAW)
2309 utf16_string = local_alloc ((utf8_len + 1) * sizeof (WCHAR));
2310 else
2311 utf16_string = alloca ((utf8_len + 1) * sizeof (WCHAR));
2312
2313 utf8to16 (out_string, utf8_len, utf16_string);
2314 return_value = unicode_append_menu (menu, fuFlags,
2315 item != NULL ? (UINT) item
2316 : (UINT) wv->call_data,
2317 utf16_string);
2318 if (fuFlags & MF_OWNERDRAW)
2319 local_free (out_string);
2320 }
2321 else
2322 {
2323 return_value =
2324 AppendMenu (menu,
2325 fuFlags,
2326 item != NULL ? (UINT) item : (UINT) wv->call_data,
2327 out_string );
2328 }
2214 2329
2215 /* This must be done after the menu item is created. */ 2330 /* This must be done after the menu item is created. */
2216 if (!wv->title && wv->call_data != 0) 2331 if (!wv->title && wv->call_data != 0)
@@ -2298,7 +2413,7 @@ w32_menu_display_help (HWND owner, HMENU menu, UINT item, UINT flags)
2298 struct frame *f = x_window_to_frame (&one_w32_display_info, owner); 2413 struct frame *f = x_window_to_frame (&one_w32_display_info, owner);
2299 Lisp_Object frame, help; 2414 Lisp_Object frame, help;
2300 2415
2301 // No help echo on owner-draw menu items. 2416 /* No help echo on owner-draw menu items. */
2302 if (flags & MF_OWNERDRAW || flags & MF_POPUP) 2417 if (flags & MF_OWNERDRAW || flags & MF_POPUP)
2303 help = Qnil; 2418 help = Qnil;
2304 else 2419 else
@@ -2422,6 +2537,7 @@ void globals_of_w32menu ()
2422 HMODULE user32 = GetModuleHandle ("user32.dll"); 2537 HMODULE user32 = GetModuleHandle ("user32.dll");
2423 get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA"); 2538 get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA");
2424 set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA"); 2539 set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA");
2540 unicode_append_menu = (AppendMenuW_Proc) GetProcAddress (user32, "AppendMenuW");
2425} 2541}
2426 2542
2427/* arch-tag: 0eaed431-bb4e-4aac-a527-95a1b4f1fed0 2543/* arch-tag: 0eaed431-bb4e-4aac-a527-95a1b4f1fed0
diff --git a/src/xdisp.c b/src/xdisp.c
index 35a4d755577..779109b83ab 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -307,6 +307,7 @@ Lisp_Object Qline_height, Qtotal;
307extern Lisp_Object Qheight; 307extern Lisp_Object Qheight;
308extern Lisp_Object QCwidth, QCheight, QCascent; 308extern Lisp_Object QCwidth, QCheight, QCascent;
309extern Lisp_Object Qscroll_bar; 309extern Lisp_Object Qscroll_bar;
310extern Lisp_Object Qcursor;
310 311
311/* Non-nil means highlight trailing whitespace. */ 312/* Non-nil means highlight trailing whitespace. */
312 313
@@ -10747,6 +10748,7 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
10747{ 10748{
10748 struct glyph *glyph = row->glyphs[TEXT_AREA]; 10749 struct glyph *glyph = row->glyphs[TEXT_AREA];
10749 struct glyph *end = glyph + row->used[TEXT_AREA]; 10750 struct glyph *end = glyph + row->used[TEXT_AREA];
10751 struct glyph *cursor = NULL;
10750 /* The first glyph that starts a sequence of glyphs from string. */ 10752 /* The first glyph that starts a sequence of glyphs from string. */
10751 struct glyph *string_start; 10753 struct glyph *string_start;
10752 /* The X coordinate of string_start. */ 10754 /* The X coordinate of string_start. */
@@ -10756,6 +10758,7 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
10756 /* The last known character position before string_start. */ 10758 /* The last known character position before string_start. */
10757 int string_before_pos; 10759 int string_before_pos;
10758 int x = row->x; 10760 int x = row->x;
10761 int cursor_x = x;
10759 int pt_old = PT - delta; 10762 int pt_old = PT - delta;
10760 10763
10761 /* Skip over glyphs not having an object at the start of the row. 10764 /* Skip over glyphs not having an object at the start of the row.
@@ -10788,12 +10791,29 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
10788 string_start = glyph; 10791 string_start = glyph;
10789 string_start_x = x; 10792 string_start_x = x;
10790 /* Skip all glyphs from string. */ 10793 /* Skip all glyphs from string. */
10791 SKIP_GLYPHS (glyph, end, x, STRINGP (glyph->object)); 10794 do
10795 {
10796 if ((cursor == NULL || glyph > cursor)
10797 && !NILP (Fget_char_property (make_number ((glyph)->charpos),
10798 Qcursor, (glyph)->object)))
10799 {
10800 cursor = glyph;
10801 cursor_x = x;
10802 }
10803 x += glyph->pixel_width;
10804 ++glyph;
10805 }
10806 while (glyph < end && STRINGP (glyph->object));
10792 } 10807 }
10793 } 10808 }
10794 10809
10795 if (string_start 10810 if (cursor != NULL)
10796 && (glyph == end || !BUFFERP (glyph->object) || last_pos > pt_old)) 10811 {
10812 glyph = cursor;
10813 x = cursor_x;
10814 }
10815 else if (string_start
10816 && (glyph == end || !BUFFERP (glyph->object) || last_pos > pt_old))
10797 { 10817 {
10798 /* We may have skipped over point because the previous glyphs 10818 /* We may have skipped over point because the previous glyphs
10799 are from string. As there's no easy way to know the 10819 are from string. As there's no easy way to know the
@@ -11185,8 +11205,8 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
11185 start_display (&it, w, startp); 11205 start_display (&it, w, startp);
11186 11206
11187 if (scroll_conservatively) 11207 if (scroll_conservatively)
11188 amount_to_scroll = 11208 amount_to_scroll
11189 max (dy, FRAME_LINE_HEIGHT (f) * max (scroll_step, temp_scroll_step)); 11209 = max (dy, FRAME_LINE_HEIGHT (f) * max (scroll_step, temp_scroll_step));
11190 else if (scroll_step || temp_scroll_step) 11210 else if (scroll_step || temp_scroll_step)
11191 amount_to_scroll = scroll_max; 11211 amount_to_scroll = scroll_max;
11192 else 11212 else
@@ -11465,8 +11485,7 @@ try_cursor_movement (window, startp, scroll_step)
11465 else if (PT < XFASTINT (w->last_point)) 11485 else if (PT < XFASTINT (w->last_point))
11466 { 11486 {
11467 /* Cursor has to be moved backward. Note that PT >= 11487 /* Cursor has to be moved backward. Note that PT >=
11468 CHARPOS (startp) because of the outer 11488 CHARPOS (startp) because of the outer if-statement. */
11469 if-statement. */
11470 while (!row->mode_line_p 11489 while (!row->mode_line_p
11471 && (MATRIX_ROW_START_CHARPOS (row) > PT 11490 && (MATRIX_ROW_START_CHARPOS (row) > PT
11472 || (MATRIX_ROW_START_CHARPOS (row) == PT 11491 || (MATRIX_ROW_START_CHARPOS (row) == PT
@@ -11978,8 +11997,8 @@ redisplay_window (window, just_this_one_p)
11978 buffer. */ 11997 buffer. */
11979 || !NILP (Vwindow_scroll_functions) 11998 || !NILP (Vwindow_scroll_functions)
11980 || MINI_WINDOW_P (w) 11999 || MINI_WINDOW_P (w)
11981 || !(used_current_matrix_p = 12000 || !(used_current_matrix_p
11982 try_window_reusing_current_matrix (w))) 12001 = try_window_reusing_current_matrix (w)))
11983 { 12002 {
11984 IF_DEBUG (debug_method_add (w, "1")); 12003 IF_DEBUG (debug_method_add (w, "1"));
11985 try_window (window, startp); 12004 try_window (window, startp);
@@ -12108,8 +12127,8 @@ redisplay_window (window, just_this_one_p)
12108 || !NILP (Vwindow_scroll_functions) 12127 || !NILP (Vwindow_scroll_functions)
12109 || !just_this_one_p 12128 || !just_this_one_p
12110 || MINI_WINDOW_P (w) 12129 || MINI_WINDOW_P (w)
12111 || !(used_current_matrix_p = 12130 || !(used_current_matrix_p
12112 try_window_reusing_current_matrix (w))) 12131 = try_window_reusing_current_matrix (w)))
12113 try_window (window, startp); 12132 try_window (window, startp);
12114 12133
12115 /* If new fonts have been loaded (due to fontsets), give up. We 12134 /* If new fonts have been loaded (due to fontsets), give up. We
@@ -15774,7 +15793,8 @@ display_mode_element (it, depth, field_width, precision, elt, props, risky)
15774 The mode_line_string_face face property is always added to the string. 15793 The mode_line_string_face face property is always added to the string.
15775 */ 15794 */
15776 15795
15777static int store_mode_line_string (string, lisp_string, copy_string, field_width, precision, props) 15796static int
15797store_mode_line_string (string, lisp_string, copy_string, field_width, precision, props)
15778 char *string; 15798 char *string;
15779 Lisp_Object lisp_string; 15799 Lisp_Object lisp_string;
15780 int copy_string; 15800 int copy_string;
@@ -15886,32 +15906,32 @@ If third optional arg NO-PROPS is non-nil, string is not propertized. */)
15886 15906
15887 if (NILP (format) || EQ (format, Qt)) 15907 if (NILP (format) || EQ (format, Qt))
15888 { 15908 {
15889 face_id = NILP (format) 15909 face_id = (NILP (format)
15890 ? CURRENT_MODE_LINE_FACE_ID (w) : 15910 ? CURRENT_MODE_LINE_FACE_ID (w)
15891 HEADER_LINE_FACE_ID; 15911 : HEADER_LINE_FACE_ID);
15892 format = NILP (format) 15912 format = (NILP (format)
15893 ? current_buffer->mode_line_format 15913 ? current_buffer->mode_line_format
15894 : current_buffer->header_line_format; 15914 : current_buffer->header_line_format);
15895 } 15915 }
15896 15916
15897 init_iterator (&it, w, -1, -1, NULL, face_id); 15917 init_iterator (&it, w, -1, -1, NULL, face_id);
15898 15918
15899 if (NILP (no_props)) 15919 if (NILP (no_props))
15900 { 15920 {
15901 mode_line_string_face = 15921 mode_line_string_face
15902 (face_id == MODE_LINE_FACE_ID ? Qmode_line : 15922 = (face_id == MODE_LINE_FACE_ID ? Qmode_line
15903 face_id == MODE_LINE_INACTIVE_FACE_ID ? Qmode_line_inactive : 15923 : face_id == MODE_LINE_INACTIVE_FACE_ID ? Qmode_line_inactive
15904 face_id == HEADER_LINE_FACE_ID ? Qheader_line : Qnil); 15924 : face_id == HEADER_LINE_FACE_ID ? Qheader_line : Qnil);
15905 15925
15906 mode_line_string_face_prop = 15926 mode_line_string_face_prop
15907 NILP (mode_line_string_face) ? Qnil : 15927 = (NILP (mode_line_string_face) ? Qnil
15908 Fcons (Qface, Fcons (mode_line_string_face, Qnil)); 15928 : Fcons (Qface, Fcons (mode_line_string_face, Qnil)));
15909 15929
15910 /* We need a dummy last element in mode_line_string_list to 15930 /* We need a dummy last element in mode_line_string_list to
15911 indicate we are building the propertized mode-line string. 15931 indicate we are building the propertized mode-line string.
15912 Using mode_line_string_face_prop here GC protects it. */ 15932 Using mode_line_string_face_prop here GC protects it. */
15913 mode_line_string_list = 15933 mode_line_string_list
15914 Fcons (mode_line_string_face_prop, Qnil); 15934 = Fcons (mode_line_string_face_prop, Qnil);
15915 frame_title_ptr = NULL; 15935 frame_title_ptr = NULL;
15916 } 15936 }
15917 else 15937 else
@@ -21038,7 +21058,8 @@ note_mouse_highlight (f, x, y)
21038 21058
21039 if (part == ON_VERTICAL_BORDER) 21059 if (part == ON_VERTICAL_BORDER)
21040 cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor; 21060 cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor;
21041 else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE) 21061 else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE
21062 || part == ON_SCROLL_BAR)
21042 cursor = FRAME_X_OUTPUT (f)->nontext_cursor; 21063 cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
21043 else 21064 else
21044 cursor = FRAME_X_OUTPUT (f)->text_cursor; 21065 cursor = FRAME_X_OUTPUT (f)->text_cursor;
diff --git a/src/xfns.c b/src/xfns.c
index f392757b949..b0864cbdffe 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1540,61 +1540,15 @@ x_encode_text (string, coding_system, selectionp, text_bytes, stringp)
1540} 1540}
1541 1541
1542 1542
1543/* Change the name of frame F to NAME. If NAME is nil, set F's name to 1543/* Set the WM name to NAME for frame F. Also set the icon name.
1544 x_id_name. 1544 If the frame already has an icon name, use that, otherwise set the
1545 1545 icon name to NAME. */
1546 If EXPLICIT is non-zero, that indicates that lisp code is setting the
1547 name; if NAME is a string, set F's name to NAME and set
1548 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1549 1546
1550 If EXPLICIT is zero, that indicates that Emacs redisplay code is 1547static void
1551 suggesting a new name, which lisp code should override; if 1548x_set_name_internal (f, name)
1552 F->explicit_name is set, ignore the new name; otherwise, set it. */ 1549 FRAME_PTR f;
1553
1554void
1555x_set_name (f, name, explicit)
1556 struct frame *f;
1557 Lisp_Object name; 1550 Lisp_Object name;
1558 int explicit;
1559{ 1551{
1560 /* Make sure that requests from lisp code override requests from
1561 Emacs redisplay code. */
1562 if (explicit)
1563 {
1564 /* If we're switching from explicit to implicit, we had better
1565 update the mode lines and thereby update the title. */
1566 if (f->explicit_name && NILP (name))
1567 update_mode_lines = 1;
1568
1569 f->explicit_name = ! NILP (name);
1570 }
1571 else if (f->explicit_name)
1572 return;
1573
1574 /* If NAME is nil, set the name to the x_id_name. */
1575 if (NILP (name))
1576 {
1577 /* Check for no change needed in this very common case
1578 before we do any consing. */
1579 if (!strcmp (FRAME_X_DISPLAY_INFO (f)->x_id_name,
1580 SDATA (f->name)))
1581 return;
1582 name = build_string (FRAME_X_DISPLAY_INFO (f)->x_id_name);
1583 }
1584 else
1585 CHECK_STRING (name);
1586
1587 /* Don't change the name if it's already NAME. */
1588 if (! NILP (Fstring_equal (name, f->name)))
1589 return;
1590
1591 f->name = name;
1592
1593 /* For setting the frame title, the title parameter should override
1594 the name parameter. */
1595 if (! NILP (f->title))
1596 name = f->title;
1597
1598 if (FRAME_X_WINDOW (f)) 1552 if (FRAME_X_WINDOW (f))
1599 { 1553 {
1600 BLOCK_INPUT; 1554 BLOCK_INPUT;
@@ -1602,8 +1556,10 @@ x_set_name (f, name, explicit)
1602 { 1556 {
1603 XTextProperty text, icon; 1557 XTextProperty text, icon;
1604 int bytes, stringp; 1558 int bytes, stringp;
1559 int do_free_icon_value = 0, do_free_text_value = 0;
1605 Lisp_Object coding_system; 1560 Lisp_Object coding_system;
1606 1561
1562 coding_system = Qcompound_text;
1607 /* Note: Encoding strategy 1563 /* Note: Encoding strategy
1608 1564
1609 We encode NAME by compound-text and use "COMPOUND-TEXT" in 1565 We encode NAME by compound-text and use "COMPOUND-TEXT" in
@@ -1618,13 +1574,16 @@ x_set_name (f, name, explicit)
1618 in the future which can encode all Unicode characters. 1574 in the future which can encode all Unicode characters.
1619 But, for the moment, there's no way to know that the 1575 But, for the moment, there's no way to know that the
1620 current window manager supports it or not. */ 1576 current window manager supports it or not. */
1621 coding_system = Qcompound_text;
1622 text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp); 1577 text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);
1623 text.encoding = (stringp ? XA_STRING 1578 text.encoding = (stringp ? XA_STRING
1624 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); 1579 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
1625 text.format = 8; 1580 text.format = 8;
1626 text.nitems = bytes; 1581 text.nitems = bytes;
1627 1582
1583 /* Check early, because ENCODE_UTF_8 below may GC and name may be
1584 relocated. */
1585 do_free_text_value = text.value != SDATA (name);
1586
1628 if (NILP (f->icon_name)) 1587 if (NILP (f->icon_name))
1629 { 1588 {
1630 icon = text; 1589 icon = text;
@@ -1638,7 +1597,9 @@ x_set_name (f, name, explicit)
1638 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); 1597 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
1639 icon.format = 8; 1598 icon.format = 8;
1640 icon.nitems = bytes; 1599 icon.nitems = bytes;
1600 do_free_icon_value = icon.value != SDATA (f->icon_name);
1641 } 1601 }
1602
1642#ifdef USE_GTK 1603#ifdef USE_GTK
1643 gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), 1604 gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
1644 SDATA (ENCODE_UTF_8 (name))); 1605 SDATA (ENCODE_UTF_8 (name)));
@@ -1648,10 +1609,9 @@ x_set_name (f, name, explicit)
1648 1609
1649 XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &icon); 1610 XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &icon);
1650 1611
1651 if (!NILP (f->icon_name) 1612 if (do_free_icon_value)
1652 && icon.value != (unsigned char *) SDATA (f->icon_name))
1653 xfree (icon.value); 1613 xfree (icon.value);
1654 if (text.value != (unsigned char *) SDATA (name)) 1614 if (do_free_text_value)
1655 xfree (text.value); 1615 xfree (text.value);
1656 } 1616 }
1657#else /* not HAVE_X11R4 */ 1617#else /* not HAVE_X11R4 */
@@ -1664,6 +1624,64 @@ x_set_name (f, name, explicit)
1664 } 1624 }
1665} 1625}
1666 1626
1627/* Change the name of frame F to NAME. If NAME is nil, set F's name to
1628 x_id_name.
1629
1630 If EXPLICIT is non-zero, that indicates that lisp code is setting the
1631 name; if NAME is a string, set F's name to NAME and set
1632 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1633
1634 If EXPLICIT is zero, that indicates that Emacs redisplay code is
1635 suggesting a new name, which lisp code should override; if
1636 F->explicit_name is set, ignore the new name; otherwise, set it. */
1637
1638void
1639x_set_name (f, name, explicit)
1640 struct frame *f;
1641 Lisp_Object name;
1642 int explicit;
1643{
1644 /* Make sure that requests from lisp code override requests from
1645 Emacs redisplay code. */
1646 if (explicit)
1647 {
1648 /* If we're switching from explicit to implicit, we had better
1649 update the mode lines and thereby update the title. */
1650 if (f->explicit_name && NILP (name))
1651 update_mode_lines = 1;
1652
1653 f->explicit_name = ! NILP (name);
1654 }
1655 else if (f->explicit_name)
1656 return;
1657
1658 /* If NAME is nil, set the name to the x_id_name. */
1659 if (NILP (name))
1660 {
1661 /* Check for no change needed in this very common case
1662 before we do any consing. */
1663 if (!strcmp (FRAME_X_DISPLAY_INFO (f)->x_id_name,
1664 SDATA (f->name)))
1665 return;
1666 name = build_string (FRAME_X_DISPLAY_INFO (f)->x_id_name);
1667 }
1668 else
1669 CHECK_STRING (name);
1670
1671 /* Don't change the name if it's already NAME. */
1672 if (! NILP (Fstring_equal (name, f->name)))
1673 return;
1674
1675 f->name = name;
1676
1677 /* For setting the frame title, the title parameter should override
1678 the name parameter. */
1679 if (! NILP (f->title))
1680 name = f->title;
1681
1682 x_set_name_internal (f, name);
1683}
1684
1667/* This function should be called when the user's lisp code has 1685/* This function should be called when the user's lisp code has
1668 specified a name for the frame; the name will override any set by the 1686 specified a name for the frame; the name will override any set by the
1669 redisplay code. */ 1687 redisplay code. */
@@ -1715,62 +1733,7 @@ x_set_title (f, name, old_name)
1715 else 1733 else
1716 CHECK_STRING (name); 1734 CHECK_STRING (name);
1717 1735
1718 if (FRAME_X_WINDOW (f)) 1736 x_set_name_internal (f, name);
1719 {
1720 BLOCK_INPUT;
1721#ifdef HAVE_X11R4
1722 {
1723 XTextProperty text, icon;
1724 int bytes, stringp;
1725 Lisp_Object coding_system;
1726
1727 coding_system = Qcompound_text;
1728 /* See the comment "Note: Encoding strategy" in x_set_name. */
1729 text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);
1730 text.encoding = (stringp ? XA_STRING
1731 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
1732 text.format = 8;
1733 text.nitems = bytes;
1734
1735 if (NILP (f->icon_name))
1736 {
1737 icon = text;
1738 }
1739 else
1740 {
1741 /* See the comment "Note: Encoding strategy" in x_set_name. */
1742 icon.value = x_encode_text (f->icon_name, coding_system, 0,
1743 &bytes, &stringp);
1744 icon.encoding = (stringp ? XA_STRING
1745 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
1746 icon.format = 8;
1747 icon.nitems = bytes;
1748 }
1749
1750#ifdef USE_GTK
1751 gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
1752 SDATA (ENCODE_UTF_8 (name)));
1753#else /* not USE_GTK */
1754 XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text);
1755#endif /* not USE_GTK */
1756
1757 XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
1758 &icon);
1759
1760 if (!NILP (f->icon_name)
1761 && icon.value != (unsigned char *) SDATA (f->icon_name))
1762 xfree (icon.value);
1763 if (text.value != (unsigned char *) SDATA (name))
1764 xfree (text.value);
1765 }
1766#else /* not HAVE_X11R4 */
1767 XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1768 SDATA (name));
1769 XStoreName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1770 SDATA (name));
1771#endif /* not HAVE_X11R4 */
1772 UNBLOCK_INPUT;
1773 }
1774} 1737}
1775 1738
1776void 1739void
diff --git a/src/xmenu.c b/src/xmenu.c
index 08bad9c2241..eddda3ef91b 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -1701,12 +1701,9 @@ digest_single_submenu (start, end, top_level_items)
1701 save_wv->next = wv; 1701 save_wv->next = wv;
1702 else 1702 else
1703 first_wv->contents = wv; 1703 first_wv->contents = wv;
1704 wv->name = pane_string; 1704 wv->lname = pane_name;
1705 /* Ignore the @ that means "separate pane". 1705 /* Set value to 1 so update_submenu_strings can handle '@' */
1706 This is a kludge, but this isn't worth more time. */ 1706 wv->value = (char *)1;
1707 if (!NILP (prefix) && wv->name[0] == '@')
1708 wv->name++;
1709 wv->value = 0;
1710 wv->enabled = 1; 1707 wv->enabled = 1;
1711 wv->button_type = BUTTON_TYPE_NONE; 1708 wv->button_type = BUTTON_TYPE_NONE;
1712 wv->help = Qnil; 1709 wv->help = Qnil;
@@ -1749,9 +1746,9 @@ digest_single_submenu (start, end, top_level_items)
1749 else 1746 else
1750 save_wv->contents = wv; 1747 save_wv->contents = wv;
1751 1748
1752 wv->name = (char *) SDATA (item_name); 1749 wv->lname = item_name;
1753 if (!NILP (descrip)) 1750 if (!NILP (descrip))
1754 wv->key = (char *) SDATA (descrip); 1751 wv->lkey = descrip;
1755 wv->value = 0; 1752 wv->value = 0;
1756 /* The EMACS_INT cast avoids a warning. There's no problem 1753 /* The EMACS_INT cast avoids a warning. There's no problem
1757 as long as pointers have enough bits to hold small integers. */ 1754 as long as pointers have enough bits to hold small integers. */
@@ -1790,6 +1787,42 @@ digest_single_submenu (start, end, top_level_items)
1790 1787
1791 return first_wv; 1788 return first_wv;
1792} 1789}
1790
1791/* Walk through the widget_value tree starting at FIRST_WV and update
1792 the char * pointers from the corresponding lisp values.
1793 We do this after building the whole tree, since GC may happen while the
1794 tree is constructed, and small strings are relocated. So we must wait
1795 until no GC can happen before storing pointers into lisp values. */
1796static void
1797update_submenu_strings (first_wv)
1798 widget_value *first_wv;
1799{
1800 widget_value *wv;
1801
1802 for (wv = first_wv; wv; wv = wv->next)
1803 {
1804 if (wv->lname && ! NILP (wv->lname))
1805 {
1806 wv->name = SDATA (wv->lname);
1807
1808 /* Ignore the @ that means "separate pane".
1809 This is a kludge, but this isn't worth more time. */
1810 if (wv->value == (char *)1)
1811 {
1812 if (wv->name[0] == '@')
1813 wv->name++;
1814 wv->value = 0;
1815 }
1816 }
1817
1818 if (wv->lkey && ! NILP (wv->lkey))
1819 wv->key = SDATA (wv->lkey);
1820
1821 if (wv->contents)
1822 update_submenu_strings (wv->contents);
1823 }
1824}
1825
1793 1826
1794/* Recompute all the widgets of frame F, when the menu bar has been 1827/* Recompute all the widgets of frame F, when the menu bar has been
1795 changed. Value is non-zero if widgets were updated. */ 1828 changed. Value is non-zero if widgets were updated. */
@@ -2022,9 +2055,10 @@ set_frame_menubar (f, first_time, deep_p)
2022 Lisp_Object string; 2055 Lisp_Object string;
2023 string = XVECTOR (items)->contents[i + 1]; 2056 string = XVECTOR (items)->contents[i + 1];
2024 if (NILP (string)) 2057 if (NILP (string))
2025 break; 2058 break;
2026 wv->name = (char *) SDATA (string); 2059 wv->name = (char *) SDATA (string);
2027 wv = wv->next; 2060 update_submenu_strings (wv->contents);
2061 wv = wv->next;
2028 } 2062 }
2029 2063
2030 f->menu_bar_vector = menu_items; 2064 f->menu_bar_vector = menu_items;