# HG changeset patch # User Katsumi Yamaoka # Date 1270132460 0 # Node ID 5a619d0a915869284e4b25f5041ba3fc91befd92 # Parent 86c85c80cd84c8f4c7f97b696cf82b09764f18c3# Parent dc45468b314057f671a73cabaf02593157a8fb6a Merge from mainline. diff -r 86c85c80cd84 -r 5a619d0a9158 ChangeLog --- a/ChangeLog Mon Mar 29 14:00:56 2010 +0000 +++ b/ChangeLog Thu Apr 01 14:34:20 2010 +0000 @@ -1,6 +1,6 @@ -2010-03-27 Nick Roberts - - * Restore GDB/MI fuctionality removed by r99212. +2010-03-30 Dan Nicolaescu + + * configure.in: Remove all references to C_DEBUG_SWITCH. 2010-03-27 Eli Zaretskii diff -r 86c85c80cd84 -r 5a619d0a9158 admin/CPP-DEFINES --- a/admin/CPP-DEFINES Mon Mar 29 14:00:56 2010 +0000 +++ b/admin/CPP-DEFINES Thu Apr 01 14:34:20 2010 +0000 @@ -106,7 +106,6 @@ CLASH_DETECTION COFF_BSD_SYMBOLS CRT0_DUMMIES -C_DEBUG_SWITCH C_SWITCH_MACHINE C_SWITCH_SYSTEM C_SWITCH_SYSTEM_TEMACS @@ -234,7 +233,6 @@ LD_SWITCH_SYSTEM_TEMACS LD_SWITCH_SYSTEM_tmp LD_SWITCH_X_DEFAULT -LIBS_DEBUG LIBS_MACHINE LIBS_SYSTEM LIBS_TERMCAP diff -r 86c85c80cd84 -r 5a619d0a9158 configure.in --- a/configure.in Mon Mar 29 14:00:56 2010 +0000 +++ b/configure.in Thu Apr 01 14:34:20 2010 +0000 @@ -888,10 +888,6 @@ configure___ use_mmap_for_buffers=no #endif -#ifndef C_DEBUG_SWITCH -#define C_DEBUG_SWITCH -g -#endif - #ifndef C_OPTIMIZE_SWITCH #ifdef __GNUC__ #define C_OPTIMIZE_SWITCH -O2 @@ -923,18 +919,18 @@ /* Get the CFLAGS for tests in configure. */ #ifdef __GNUC__ -configure___ CFLAGS=C_DEBUG_SWITCH C_OPTIMIZE_SWITCH '${SPECIFIED_CFLAGS}' +configure___ CFLAGS=C_OPTIMIZE_SWITCH '${SPECIFIED_CFLAGS}' #else -configure___ CFLAGS=C_DEBUG_SWITCH '${SPECIFIED_CFLAGS}' +configure___ CFLAGS='${SPECIFIED_CFLAGS}' #endif #else /* not THIS_IS_CONFIGURE */ /* Get the CFLAGS for real compilation. */ #ifdef __GNUC__ -configure___ REAL_CFLAGS=C_DEBUG_SWITCH C_OPTIMIZE_SWITCH C_WARNINGS_SWITCH ${PROFILING_CFLAGS} '${SPECIFIED_CFLAGS}' +configure___ REAL_CFLAGS=C_OPTIMIZE_SWITCH C_WARNINGS_SWITCH ${PROFILING_CFLAGS} '${SPECIFIED_CFLAGS}' #else -configure___ REAL_CFLAGS=C_DEBUG_SWITCH '${SPECIFIED_CFLAGS}' +configure___ REAL_CFLAGS='${SPECIFIED_CFLAGS}' #endif #endif /* not THIS_IS_CONFIGURE */ diff -r 86c85c80cd84 -r 5a619d0a9158 doc/emacs/ChangeLog --- a/doc/emacs/ChangeLog Mon Mar 29 14:00:56 2010 +0000 +++ b/doc/emacs/ChangeLog Thu Apr 01 14:34:20 2010 +0000 @@ -1,7 +1,81 @@ +2010-03-30 Eli Zaretskii + + * mule.texi (Input Methods): Mention "C-x 8 RET" and add a + cross-reference to "Inserting Text". + + * basic.texi (Inserting Text): Add an index entry for "C-x 8 RET". + Mention completion provided by `ucs-insert'. + +2010-03-30 Chong Yidong + + * sending.texi (Sending Mail): Note variables that may need + customizing. + (Mail Sending): Expand discussion of send-mail-function. + +2010-03-30 Chong Yidong + + Document Message mode as the default mail mode. + + * sending.texi (Sending Mail): Copyedits. + (Mail Format, Mail Headers): Document mail-from-style changes. + (Mail Commands): Rename from Mail mode. Document Message mode. + (Mail Misc): Rename from Mail mode Misc. + (Mail Sending, Header Editing, Mail Misc): Switch to Message mode + command names and update keybindings. + (Header Editing): Document message-tab. De-document + mail-self-blind, mail-default-reply-to, and mail-archive-file-name in + favor of mail-default-headers. Ad index entries for user-full-name and + user-mail-address. + (Citing Mail): Update changes in Message mode behavior. Document + mail-yank-prefix. + (Mail Signature): New node, moved from Mail Misc. + (Mail Aliases): Mail abbrevs are the default with Message mode. + (Mail Methods): Note that Message mode is now the default. + + * rmail.texi (Rmail Reply): + * text.texi (Text Mode): + * major.texi (Major Modes): + * mule.texi (Output Coding): Refer to Message mode. + + * custom.texi (Init Examples): Add xref to Mail Header. + + * emacs.texi (Top): Fix xrefs. + +2010-03-30 Chong Yidong + + * maintaining.texi (VC With A Merging VCS): C-x v v now creates a + repository if there is none. + (VC Change Log): Rename from VC Status. Document vc-log-show-limit and + vc-print-root-log. + (Old Revisions): Copyedits. Document vc-root-diff. + + * programs.texi (Program Modes): Mention Javascript mode. + + * text.texi (HTML Mode): Note that nXML is now the default XML mode. + * emacs.texi: Update node description. + + * misc.texi (Navigation): Document doc-view-continuous. + (Shell Ring): Document new M-r binding. M-s is no longer bound. + +2010-03-30 Juri Linkov + + * search.texi (Other Repeating Search): Remove line that `occur' + can not handle multiline matches. + +2010-03-30 Eli Zaretskii + + * mule.texi (International): Mention support of bidirectional editing. + (Bidirectional Editing): New section. + 2010-03-28 Nick Roberts * emacs.texi (Top): Update node names to those in building.texi. +2010-03-27 Nick Roberts + + doc/emacs/building.texi: Describe restored GDB/MI fuctionality removed by r99212. + doc/emacs/emacs.texi: Update node names for building.texi. + 2010-03-24 Glenn Morris * ack.texi (Acknowledgments): diff -r 86c85c80cd84 -r 5a619d0a9158 doc/emacs/basic.texi --- a/doc/emacs/basic.texi Mon Mar 29 14:00:56 2010 +0000 +++ b/doc/emacs/basic.texi Thu Apr 01 14:34:20 2010 +0000 @@ -100,13 +100,15 @@ character to insert (@pxref{Arguments}). @findex ucs-insert +@kindex C-x 8 RET @cindex Unicode Instead of @kbd{C-q}, you can use @kbd{C-x 8 @key{RET}} (@code{ucs-insert}) to insert a character based on its Unicode name or code-point. This commands prompts for a character to insert, using the minibuffer; you can specify the character using either (i) the character's name in the Unicode standard, or (ii) the character's -code-point in the Unicode standard. +code-point in the Unicode standard. If you specify the character's +name, the command provides completion. @node Moving Point @section Changing the Location of Point diff -r 86c85c80cd84 -r 5a619d0a9158 doc/emacs/custom.texi --- a/doc/emacs/custom.texi Mon Mar 29 14:00:56 2010 +0000 +++ b/doc/emacs/custom.texi Thu Apr 01 14:34:20 2010 +0000 @@ -2269,8 +2269,9 @@ (setq user-mail-address "cheney@@torture.gov") @end example -Various Emacs packages that need your own email address use the value of -@code{user-mail-address}. +Various Emacs packages, such as Message mode, consult +@code{user-mail-address} when they need to know your email address. +@xref{Mail Headers}. @item Make Text mode the default mode for new buffers. diff -r 86c85c80cd84 -r 5a619d0a9158 doc/emacs/emacs.texi --- a/doc/emacs/emacs.texi Mon Mar 29 14:00:56 2010 +0000 +++ b/doc/emacs/emacs.texi Thu Apr 01 14:34:20 2010 +0000 @@ -574,7 +574,7 @@ * Text Mode:: The major modes for editing text files. * Outline Mode:: Editing outlines. * TeX Mode:: Editing input to the formatter TeX. -* HTML Mode:: Editing HTML, SGML, and XML files. +* HTML Mode:: Editing HTML and SGML files. * Nroff Mode:: Editing input to the formatter nroff. * Formatted Text:: Editing formatted text directly in WYSIWYG fashion. * Text Based Tables:: Editing text-based tables in WYSIWYG fashion. @@ -796,7 +796,7 @@ The Secondary Commands of VC * Registering:: Putting a file under version control. -* VC Status:: Viewing the VC status of files. +* VC Change Log:: Viewing the VC Change Log. * VC Undo:: Canceling changes before or after check-in. VC Directory Mode @@ -888,16 +888,17 @@ * Mail Format:: Format of the mail being composed. * Mail Headers:: Details of some standard mail header fields. * Mail Aliases:: Abbreviating and grouping mail addresses. -* Mail Mode:: Special commands for editing mail being composed. +* Mail Commands:: Special commands for editing mail being composed. +* Mail Signature:: Adding a signature to every message. * Mail Amusements:: Distracting the NSA; adding fortune messages. * Mail Methods:: Using alternative mail-composition methods. -Mail Mode +Mail Commands * Mail Sending:: Commands to send the message. * Header Editing:: Commands to move to header fields and edit them. -* Citing Mail:: Copying all or part of a message you are replying to. -* Mail Mode Misc:: Spell checking, signatures, etc. +* Citing Mail:: Quoting a message you are replying to. +* Mail Misc:: Attachments, spell checking, etc. Reading Mail with Rmail diff -r 86c85c80cd84 -r 5a619d0a9158 doc/emacs/maintaining.texi --- a/doc/emacs/maintaining.texi Mon Mar 29 14:00:56 2010 +0000 +++ b/doc/emacs/maintaining.texi Thu Apr 01 14:34:20 2010 +0000 @@ -224,7 +224,7 @@ @cindex revision @cindex revision ID A copy of a file stored in a repository is called a @dfn{revision}. -The history of a file is a sequence of revisions. Each revisions is +The history of a file is a sequence of revisions. Each revision is named by a @dfn{revision ID}. The format of the revision ID depends on the version control system; in the simplest case, it is just an integer. @@ -403,10 +403,10 @@ consists of the marked files (@pxref{VC Directory Mode}). The principal VC command is an all-purpose command, @kbd{C-x v v} -(@code{vc-next-action}), that performs either locking, merging or a -check-in (depending on the situation) on the current VC fileset. You -can use @kbd{C-x v v} in a file-visiting buffer or in a VC Directory -buffer. +(@code{vc-next-action}), that performs either registration, locking, +merging or a check-in (depending on the situation) on the current VC +fileset. You can use @kbd{C-x v v} in a file-visiting buffer or in a +VC Directory buffer. @table @kbd @itemx C-x v v @@ -461,23 +461,31 @@ @itemize @bullet @item -If the work file is the same as in the repository, it does nothing. +If the work file is in a directory that is not controlled by any +version control system, prompt for a repository type. Then, create a +version control repository of that type and register the file with it. + +@item +If the work file is in a directory that is controlled by a version +control system but not registered with it, register the file. + +@item +If the work file is the same as in the repository, do nothing. @item If you have not changed the work file, but some other user has checked -in changes to the repository, @kbd{C-x v v} merges those changes into -the work file. +in changes to the repository, merge those changes into the work file. @item -If you have made modifications to the work file, @kbd{C-x v v} -attempts to check in your changes. To do this, Emacs first reads the -log entry for the new revision (@pxref{Log Buffer}). If some other -user has checked in changes to the repository since you last checked -it out, the checkin fails. In that case, type @kbd{C-x v v} again to -merge those changes into your own work file; this puts the work file -into a ``conflicted'' state. Type @kbd{C-x v v} to clear the -``conflicted'' state; VC then regards the file as up-to-date and -modified, and you can try to check it in again. +If you have made modifications to the work file, attempts to check in +your changes. To do this, Emacs first reads the log entry for the new +revision (@pxref{Log Buffer}). If some other user has checked in +changes to the repository since you last checked it out, the checkin +fails. In that case, type @kbd{C-x v v} again to merge those changes +into your own work file; this puts the work file into a ``conflicted'' +state. Type @kbd{C-x v v} to clear the ``conflicted'' state; VC then +regards the file as up-to-date and modified, and you can try to check +it in again. To pick up any recent changes from the repository @emph{without} trying to commit your own changes, type @kbd{C-x v m @key{RET}}. @@ -485,15 +493,15 @@ @end itemize These rules also apply when you use RCS in its ``non-locking'' mode, -except that changes will not be automatically merged from the -repository. Nothing informs you if another user has checked in -changes in the same file since you began editing it; when you check in -your revision, his changes are removed (however, they remain in the -repository and are thus not irrevocably lost). Therefore, you must -verify that the current revision is unchanged before checking in your -changes. In addition, locking is possible with RCS even in this mode: -@kbd{C-x v v} with an unmodified file locks the file, just as it does -with RCS in its normal locking mode (@pxref{VC With A Locking VCS}). +except that changes are not automatically merged from the repository. +Nothing informs you if another user has checked in changes in the same +file since you began editing it; when you check in your revision, his +changes are removed (however, they remain in the repository and are +thus not irrevocably lost). Therefore, you must verify that the +current revision is unchanged before checking in your changes. In +addition, locking is possible with RCS even in this mode: @kbd{C-x v +v} with an unmodified file locks the file, just as it does with RCS in +its normal locking mode (@pxref{VC With A Locking VCS}). @node VC With A Locking VCS @subsubsection Basic Version Control with Locking @@ -501,26 +509,25 @@ Under a locking-based version control system (such as SCCS, and RCS in its default mode), @kbd{C-x v v} does the following: - @itemize @bullet +@itemize @bullet @item -If the file is not locked, @kbd{C-x v v} locks it, and makes it -writable so that you can change it. +If the file is not locked, lock it and make it writable, so that you +can change it. @item -If the file is locked by you, and contains changes, @kbd{C-x v v} -checks in the changes. In order to do this, it first reads the log -entry for the new revision. @xref{Log Buffer}. +If the file is locked by you, and contains changes, check in the +changes. In order to do this, Emacs first reads the log entry for the +new revision. @xref{Log Buffer}. @item If the file is locked by you, but you have not changed it since you -locked it, @kbd{C-x v v} releases the lock and makes the file -read-only again. +locked it, release the lock and makes the file read-only again. @item -If the file is locked by some other user, @kbd{C-x v v} asks you whether -you want to ``steal the lock'' from that user. If you say yes, the file -becomes locked by you, but a message is sent to the person who had -formerly locked the file, to inform him of what has happened. +If the file is locked by some other user, ask whether you want to +``steal the lock'' from that user. If you say yes, the file becomes +locked by you, but a message is sent to the person who had formerly +locked the file, to inform him of what has happened. @end itemize These rules also apply when you use CVS in locking mode, except @@ -639,20 +646,23 @@ to examine any revision of a file, or compare two revisions. @table @kbd -@item C-x v ~ @var{revision} @key{RET} -Examine revision @var{revision} of the visited file, in a buffer of its -own. +@item C-x v ~ +Prompt for a revision of the current file, and visit it in a buffer of +its own (@code{vc-revision-other-window}). @item C-x v = -Compare the buffer contents associated with the current -fileset with the working revision(s) from which you started editing. +Compare the files in the current fileset with the working revision(s) +you started from (@code{vc-diff}). With a prefix argument, prompt for +two revisions of the current fileset and compare them. -@item C-u C-x v = @key{RET} @var{oldvers} @key{RET} @var{newvers} @key{RET} -Compare the specified two repository revisions of the current fileset. +@item C-x v D +Compare the entire tree corresponding to the current fileset with the +tree you started from (@code{vc-root-diff}). With a prefix argument, +prompt for two revisions and compare their trees. @item C-x v g Display an annotated version of the file: for each line, show the -latest revision in which it was modified. +latest revision in which it was modified (@code{vc-annotate}). @end table @findex vc-revision-other-window @@ -673,12 +683,11 @@ @findex vc-diff @kindex C-x v = - @kbd{C-x v =} (@code{vc-diff}) compares the current buffer contents -of each file in the current VC fileset (saving them if necessary) with -the repository revision from which you started editing. Note that the -latter may or may not be the latest revision of the file(s). The diff -is displayed in a special buffer in another window. @xref{Comparing -Files}. + @kbd{C-x v =} (@code{vc-diff}) compares each file in the current VC +fileset (saving them if necessary) with the repository revision(s) +from which you started editing. Note that the latter may or may not +be the latest revision of the file(s). The diff is displayed in a +special buffer in another window. @xref{Comparing Files}. @findex vc-diff @kindex C-u C-x v = @@ -700,6 +709,12 @@ name) is unlikely to return diffs that are connected in any meaningful way. + The command @kbd{C-x v D} (@code{vc-root-diff}) is similar to +@kbd{C-x v =}, but it compares the entire tree associated with the +current VC fileset with the tree you started with. This means all the +files controlled by the current version control repository, even those +that are not part of the current VC fileset. + If you invoke @kbd{C-x v =} or @kbd{C-u C-x v =} from a buffer that is neither visiting a version-controlled file nor a VC directory buffer, these commands generate a diff of all registered files in the @@ -801,7 +816,7 @@ @menu * Registering:: Putting a file under version control. -* VC Status:: Viewing the VC status of files. +* VC Change Log:: Viewing the VC Change Log. * VC Undo:: Canceling changes before or after check-in. @end menu @@ -857,22 +872,36 @@ initial comment to describe the purpose of this source file. Reading the initial comment works like reading a log entry (@pxref{Log Buffer}). -@node VC Status -@subsubsection VC Status Commands +@node VC Change Log +@subsubsection VC Change Log @table @kbd @item C-x v l -Display revision control state and change history. +Display revision control state and change history +(@code{vc-print-log}). + +@item C-x v L +Display the change history for the current repository +(@code{vc-print-root-log}). @end table @kindex C-x v l @findex vc-print-log - To view the detailed revision control status and history of a file, -type @kbd{C-x v l} (@code{vc-print-log}). This pops up a special -buffer named @samp{*vc-change-log*}, in a new window, that displays -the history of changes to the current file, including the text of the -log entries. The point is centered at the revision of the file that -is currently being visited. + The command @kbd{C-x v l} (@code{vc-print-log}) displays a buffer +named @samp{*vc-change-log*} in a new window. This buffer lists the +changes to the current file, including the associated log entries. +(These are the log entries associated with the version control system, +i.e. the ones you enter via the @samp{*VC-Log*} buffer. @xref{Log +Buffer}.) Point is centered at the revision of the file currently +being visited. With a prefix argument, the command prompts for the +revision to center on, and the maximum number of revisions to display. + +@findex vc-print-root-log + Type @kbd{C-x v L} (@code{vc-print-root-log}) to display a +@samp{*vc-change-log*} buffer showing the history of the +version-controlled directory tree as a whole. With a prefix argument, +the command prompts for the maximum number of revisions to display. +RCS, SCCS, and CVS do not support this feature. In the @samp{*vc-change-log*} buffer, you can use the following keys to move between the logs of revisions and of files, to view past @@ -926,6 +955,16 @@ indicated on the current line did when it was committed. @end table +@vindex vc-log-show-limit +Because fetching many log entries can be slow, the +@samp{*vc-change-log*} buffer displays no more than 2000 revisions by +default. The variable @code{vc-log-show-limit} specifies this limit; +if you set the value to zero, that removes the limit. You can also +increase the number of revisions shown in an existing +@samp{*vc-change-log*} buffer by clicking on the @samp{Show 2X +entries} or @samp{Show unlimited entries} buttons at the end of the +buffer. However, RCS, SCCS, and CVS do not support this feature. + @node VC Undo @subsubsection Undoing Version Control Actions diff -r 86c85c80cd84 -r 5a619d0a9158 doc/emacs/major.texi --- a/doc/emacs/major.texi Mon Mar 29 14:00:56 2010 +0000 +++ b/doc/emacs/major.texi Thu Apr 01 14:34:20 2010 +0000 @@ -41,7 +41,7 @@ mode, Fortran mode, and others. The remaining major modes are not intended for use on users' files; they are used in buffers created for specific purposes by Emacs, such as Dired mode for buffers made by -Dired (@pxref{Dired}), Mail mode for buffers made by @kbd{C-x m} +Dired (@pxref{Dired}), Message mode for buffers made by @kbd{C-x m} (@pxref{Sending Mail}), and Shell mode for buffers used for communicating with an inferior shell process (@pxref{Interactive Shell}). diff -r 86c85c80cd84 -r 5a619d0a9158 doc/emacs/misc.texi --- a/doc/emacs/misc.texi Mon Mar 29 14:00:56 2010 +0000 +++ b/doc/emacs/misc.texi Thu Apr 01 14:34:20 2010 +0000 @@ -84,11 +84,20 @@ Emacs movement keys: @kbd{C-p}, @kbd{C-n}, @kbd{C-b}, @kbd{C-f}, and the arrow keys. +@vindex doc-view-continuous + By default, the line-motion keys @kbd{C-p} and @kbd{C-n} stop +scrolling at the beginning and end of the current page, respectively. +However, if you change the variable @code{doc-view-continuous} to a +non-@code{nil} value, then @kbd{C-p} displays the previous page if you +are already at the beginning of the current page, and @kbd{C-n} +displays the next page if you are at the end of the current page. + @findex doc-view-next-page @findex doc-view-previous-page - To display the next page, type @kbd{n}, @key{next} or @kbd{C-x ]} -(@code{doc-view-next-page}). To display the previous page, type -@kbd{p}, @key{prior} or @kbd{C-x [} (@code{doc-view-previous-page}). + You can also display the next page by typing @kbd{n}, @key{next} or +@kbd{C-x ]} (@code{doc-view-next-page}). To display the previous +page, type @kbd{p}, @key{prior} or @kbd{C-x [} +(@code{doc-view-previous-page}). @findex doc-view-scroll-up-or-next-page @findex doc-view-scroll-down-or-previous-page @@ -957,12 +966,9 @@ Fetch the next later old shell command. @kindex M-r @r{(Shell mode)} -@kindex M-s @r{(Shell mode)} -@findex comint-previous-matching-input -@findex comint-next-matching-input -@item M-r @var{regexp} @key{RET} -@itemx M-s @var{regexp} @key{RET} -Search backwards or forwards for old shell commands that match @var{regexp}. +@findex comint-history-isearch-backward-regexp +@item M-r +Begin an incremental regexp search of old shell commands. @item C-c C-x @kindex C-c C-x @r{(Shell mode)} @@ -995,15 +1001,15 @@ @kbd{C-@key{UP}} works like @kbd{M-p}, and @kbd{C-@key{DOWN}} like @kbd{M-n}. - The history search commands @kbd{M-r} and @kbd{M-s} read a regular -expression and search through the history for a matching command. Aside -from the choice of which command to fetch, they work just like @kbd{M-p} -and @kbd{M-n}. If you enter an empty regexp, these commands reuse the -same regexp used last time. - - When you find the previous input you want, you can resubmit it by -typing @key{RET}, or you can edit it first and then resubmit it if you -wish. Any partial input you were composing before navigating the + The history search command @kbd{M-r} begins an incremental regular +expression search of previous shell commands. After typing @kbd{M-r}, +start typing the desired string or regular expression; the last +matching shell command will be displayed in the current line. +Incremental search commands have their usual effects---for instance, +@kbd{C-s} and @kbd{C-r} search forward and backward for the next match +(@pxref{Incremental Search}). When you find the desired input, type +@key{RET} to terminate the search. This puts the input in the command +line. Any partial input you were composing before navigating the history list is restored when you go to the beginning or end of the history ring. diff -r 86c85c80cd84 -r 5a619d0a9158 doc/emacs/mule.texi --- a/doc/emacs/mule.texi Mon Mar 29 14:00:56 2010 +0000 +++ b/doc/emacs/mule.texi Thu Apr 01 14:34:20 2010 +0000 @@ -67,6 +67,12 @@ possible problems and explains how to solve them. @item +Characters from scripts whose natural ordering of text is from right +to left are reordered for display (@pxref{Bidirectional Editing}). +These scripts include Arabic, Hebrew, Syriac, Thaana, and a few +others. + +@item You can insert non-@acronym{ASCII} characters or search for them. To do that, you can specify an input method (@pxref{Select Input Method}) suitable for your language, or use the default input method set up when you set @@ -107,6 +113,7 @@ * Unibyte Mode:: You can pick one European character set to use without multibyte characters. * Charsets:: How Emacs groups its internal character codes. +* Bidirectional Editing:: Support for right-to-left scripts. @end menu @node International Chars @@ -533,6 +540,11 @@ possible characters to type next is displayed in the echo area (but not when you are in the minibuffer). + Another facility for typing characters not on your keyboard is by +using the @kbd{C-x 8 @key{RET}} (@code{ucs-insert}) to insert a single +character based on its Unicode name or code-point; see @ref{Inserting +Text}. + @node Select Input Method @section Selecting an Input Method @@ -961,15 +973,16 @@ to the question.) @vindex sendmail-coding-system - When you send a message with Mail mode (@pxref{Sending Mail}), Emacs has -four different ways to determine the coding system to use for encoding -the message text. It tries the buffer's own value of -@code{buffer-file-coding-system}, if that is non-@code{nil}. Otherwise, -it uses the value of @code{sendmail-coding-system}, if that is -non-@code{nil}. The third way is to use the default coding system for -new files, which is controlled by your choice of language environment, -if that is non-@code{nil}. If all of these three values are @code{nil}, -Emacs encodes outgoing mail using the Latin-1 coding system. + When you send a message with Message mode (@pxref{Sending Mail}), +Emacs has four different ways to determine the coding system to use +for encoding the message text. It tries the buffer's own value of +@code{buffer-file-coding-system}, if that is non-@code{nil}. +Otherwise, it uses the value of @code{sendmail-coding-system}, if that +is non-@code{nil}. The third way is to use the default coding system +for new files, which is controlled by your choice of language +environment, if that is non-@code{nil}. If all of these three values +are @code{nil}, Emacs encodes outgoing mail using the Latin-1 coding +system. @node Text Coding @section Specifying a Coding System for File Text @@ -1653,6 +1666,84 @@ point before it and type @kbd{C-u C-x =} (@pxref{International Chars}). +@node Bidirectional Editing +@section Bidirectional Editing +@cindex bidirectional editing +@cindex right-to-left text + + Emacs supports editing text written in scripts, such as Arabic and +Hebrew, whose natural ordering of horizontal text for display is from +right to left. However, digits and Latin text embedded in these +scripts are still displayed left to right. It is also not uncommon to +have small portions of text in Arabic or Hebrew embedded in otherwise +Latin document, e.g., as comments and strings in a program source +file. For these reasons, text that uses these scripts is actually +@dfn{bidirectional}: a mixture of runs of left-to-right and +right-to-left characters. + + This section describes the facilities and options provided by Emacs +for editing bidirectional text. + +@cindex logical order +@cindex visual order + Emacs stores right-to-left and bidirectional text in the so-called +@dfn{logical} (or @dfn{reading}) order: the buffer or string position +of the first character you read precedes that of the next character. +Reordering of bidirectional text into the @dfn{visual} order happens +at display time. As result, character positions no longer increase +monotonically with their positions on display. Emacs implements the +Unicode Bidirectional Algorithm described in the Unicode Standard +Annex #9, for reordering of bidirectional text for display. + +@vindex bidi-display-reordering + The buffer-local variable @code{bidi-display-reordering} controls +whether text in the buffer is reordered for display. If its value is +non-@code{nil}, Emacs reorders characters that have right-to-left +directionality when they are displayed. The default value is +@code{nil}. + + Each paragraph of bidirectional text can have its own @dfn{base +direction}, either right-to-left or left-to-right. (Paragraph +boundaries are defined by the regular expressions +@code{paragraph-start} and @code{paragraph-separate}, see +@ref{Paragraphs}.) Text in left-to-right paragraphs begins at the +left margin of the window and is truncated or continued when it +reaches the right margin. By contrast, text in right-to-left +paragraphs begins at the right margin and is continued or truncated at +the left margin. + +@vindex bidi-paragraph-direction + Emacs determines the base direction of each paragraph dynamically, +based on the text at the beginning of the paragraph. However, +sometimes a buffer may need to force a certain base direction for its +paragraphs. The variable @code{bidi-paragraph-direction}, if +non-@code{nil}, disables the dynamic determination of the base +direction, and instead forces all paragraphs in the buffer to have the +direction specified by its buffer-local value. The value can be either +@code{right-to-left} or @code{left-to-right}. Any other value is +interpreted as @code{nil}. + +@cindex LRM +@cindex RLM + Alternatively, you can control the base direction of a paragraph by +inserting special formatting characters in front of the paragraph. +The special character @code{RIGHT-TO-LEFT MARK}, or @sc{rlm}, forces +the right-to-left direction on the following paragraph, while +@code{LEFT-TO-RIGHT MARK}, or @sc{lrm} forces the left-to-right +direction. (You can use @kbd{C-x 8 RET} to insert these characters.) +In a GUI session, the @sc{lrm} and @sc{rlm} characters display as +blanks. + + Because characters are reordered for display, Emacs commands that +operate in the logical order or on stretches of buffer positions may +produce unusual effects. For example, @kbd{C-f} and @kbd{C-b} +commands move point in the logical order, so the cursor will sometimes +jump when point traverses reordered bidirectional text. Similarly, a +highlighted region covering a contiguous range of character positions +may look discontinuous if the region spans reordered text. This is +normal and similar to behavior of other programs that support +bidirectional text. + @ignore arch-tag: 310ba60d-31ef-4ce7-91f1-f282dd57b6b3 @end ignore diff -r 86c85c80cd84 -r 5a619d0a9158 doc/emacs/programs.texi --- a/doc/emacs/programs.texi Mon Mar 29 14:00:56 2010 +0000 +++ b/doc/emacs/programs.texi Thu Apr 01 14:34:20 2010 +0000 @@ -88,11 +88,12 @@ @cindex PostScript mode @cindex Conf mode @cindex DNS mode +@cindex Javascript mode The existing programming language major modes include Lisp, Scheme (a variant of Lisp) and the Scheme-based DSSSL expression language, Ada, ASM, AWK, C, C++, Delphi (Object Pascal), Fortran, Icon, IDL -(CORBA), IDLWAVE, Java, Metafont (@TeX{}'s companion for font -creation), Modula2, Objective-C, Octave, Pascal, Perl, Pike, +(CORBA), IDLWAVE, Java, Javascript, Metafont (@TeX{}'s companion for +font creation), Modula2, Objective-C, Octave, Pascal, Perl, Pike, PostScript, Prolog, Python, Ruby, Simula, Tcl, and VHDL. An alternative mode for Perl is called CPerl mode. Modes are available for the scripting languages of the common GNU and Unix shells, VMS diff -r 86c85c80cd84 -r 5a619d0a9158 doc/emacs/rmail.texi --- a/doc/emacs/rmail.texi Mon Mar 29 14:00:56 2010 +0000 +++ b/doc/emacs/rmail.texi Thu Apr 01 14:34:20 2010 +0000 @@ -683,12 +683,12 @@ @node Rmail Reply @section Sending Replies - Rmail has several commands that use Mail mode to send outgoing mail. -@xref{Sending Mail}, for information on using Mail mode, including -certain features meant to work with Rmail. What this section documents -are the special commands of Rmail for entering Mail mode. Note that the -usual keys for sending mail---@kbd{C-x m}, @kbd{C-x 4 m}, and @kbd{C-x 5 -m}---also work normally in Rmail mode. + Rmail has several commands to send outgoing mail. @xref{Sending +Mail}, for information on using Message mode, including certain +features meant to work with Rmail. What this section documents are +the special commands of Rmail for entering the mail buffer. Note that +the usual keys for sending mail---@kbd{C-x m}, @kbd{C-x 4 m}, and +@kbd{C-x 5 m}---also work normally in Rmail mode. @table @kbd @item m @@ -735,12 +735,12 @@ This means to reply only to the sender of the original message. Once the @samp{*mail*} buffer has been initialized, editing and -sending the mail goes as usual (@pxref{Sending Mail}). You can edit the -presupplied header fields if they are not what you want. You can also -use the commands of Mail mode (@pxref{Mail Mode}), including @kbd{C-c -C-y} which yanks in the message that you are replying to. You can -also switch to the Rmail buffer, select a different message there, switch -back, and yank the new current message. +sending the mail goes as usual (@pxref{Sending Mail}). You can edit +the presupplied header fields if they are not what you want. You can +also use commands such as @kbd{C-c C-y}, which yanks in the message +that you are replying to (@pxref{Mail Commands}). You can also switch +to the Rmail buffer, select a different message there, switch back, +and yank the new current message. @kindex M-m @r{(Rmail)} @findex rmail-retry-failure diff -r 86c85c80cd84 -r 5a619d0a9158 doc/emacs/search.texi --- a/doc/emacs/search.texi Mon Mar 29 14:00:56 2010 +0000 +++ b/doc/emacs/search.texi Thu Apr 01 14:34:20 2010 +0000 @@ -1311,8 +1311,7 @@ buffer that contains a match for it. To limit the search to part of the buffer, narrow to that part (@pxref{Narrowing}). A numeric argument @var{n} specifies that @var{n} lines of context are to be -displayed before and after each matching line. Currently, -@code{occur} can not correctly handle multiline matches. +displayed before and after each matching line. @kindex RET @r{(Occur mode)} @kindex o @r{(Occur mode)} diff -r 86c85c80cd84 -r 5a619d0a9158 doc/emacs/sending.texi --- a/doc/emacs/sending.texi Mon Mar 29 14:00:56 2010 +0000 +++ b/doc/emacs/sending.texi Thu Apr 01 14:34:20 2010 +0000 @@ -6,120 +6,110 @@ @chapter Sending Mail @cindex sending mail @cindex mail +@cindex email @cindex message - To send a message in Emacs, you start by typing a command (@kbd{C-x m}) -to select and initialize the @samp{*mail*} buffer. Then you edit the text -and headers of the message in this buffer, and type another command -(@kbd{C-c C-s} or @kbd{C-c C-c}) to send the message. +@kindex C-x m +@findex compose-mail + To send an @dfn{e-mail} message in Emacs, type @kbd{C-x m}. This +selects and initializes a buffer named @samp{*mail*}, where you can +edit the text and headers of the message. Finally, type @kbd{C-c C-s} +or @kbd{C-c C-c} to send the message. @table @kbd @item C-x m -Begin composing a message to send (@code{compose-mail}). +Begin composing mail (@code{compose-mail}). @item C-x 4 m -Likewise, but display the message in another window -(@code{compose-mail-other-window}). +Likewise, in another window (@code{compose-mail-other-window}). @item C-x 5 m -Likewise, but make a new frame (@code{compose-mail-other-frame}). +Likewise, but in a new frame (@code{compose-mail-other-frame}). @item C-c C-s -In Mail mode, send the message (@code{mail-send}). +In the mail buffer, send the message (@code{message-send}). @item C-c C-c -Send the message and bury the mail buffer (@code{mail-send-and-exit}). +In the mail buffer, send the message and bury the buffer +(@code{message-send-and-exit}). @end table -@kindex C-x m -@findex compose-mail @kindex C-x 4 m @findex compose-mail-other-window @kindex C-x 5 m @findex compose-mail-other-frame - The command @kbd{C-x m} (@code{compose-mail}) selects a buffer named -@samp{*mail*} and initializes it with the skeleton of an outgoing -message. @kbd{C-x 4 m} (@code{compose-mail-other-window}) selects the -@samp{*mail*} buffer in a different window, leaving the previous current -buffer visible. @kbd{C-x 5 m} (@code{compose-mail-other-frame}) creates -a new frame to select the @samp{*mail*} buffer. - - Because the mail-composition buffer is an ordinary Emacs buffer, you can -switch to other buffers while in the middle of composing mail, and switch -back later (or never). If you use the @kbd{C-x m} command again when you -have been composing another message but have not sent it, you are asked to -confirm before the old message is erased. If you answer @kbd{n}, the -@samp{*mail*} buffer remains selected with its old contents, so you can -finish the old message and send it. @kbd{C-u C-x m} is another way to do -this. Sending the message marks the @samp{*mail*} buffer ``unmodified,'' -which avoids the need for confirmation when @kbd{C-x m} is next used. +@noindent +The command @kbd{C-x 4 m} (@code{compose-mail-other-window}) does the +same as @kbd{C-x m}, except it displays the mail buffer in a different +window. The command @kbd{C-x 5 m} (@code{compose-mail-other-frame}) +creates a new frame for the mail buffer. - If you are composing a message in the @samp{*mail*} buffer and want to -send another message before finishing the first, rename the -@samp{*mail*} buffer using @kbd{M-x rename-uniquely} (@pxref{Misc -Buffer}). Then you can use @kbd{C-x m} or its variants described above -to make a new @samp{*mail*} buffer. Once you've done that, you can work -with each mail buffer independently. - -@vindex mail-default-directory - The variable @code{mail-default-directory} controls the default -directory for mail buffers, and also says where to put their auto-save -files. + Because the mail buffer is an ordinary Emacs buffer, you can switch +to other buffers while in the middle of composing mail, and switch +back later (or never). If you type @kbd{C-x m} again when you have +been composing another message but have not sent it, Emacs asks for +confirmation before erasing the old message. If you answer @kbd{n}, +Emacs selects the mail buffer with its old contents, so you can finish +the old message and send it. @kbd{C-u C-x m} is another way to do +this. Sending the message marks the mail buffer ``unmodified,'' which +avoids the need for confirmation when @kbd{C-x m} is next used. -@c Not mentioned: mail-bury-selects-summary. Really an Rmail feature. + If you want to send another message before finishing the current +message, use the command @kbd{M-x rename-uniquely} to rename the +current mail buffer (@pxref{Misc Buffer}). Then you can use @kbd{C-x +m} to make a new mail buffer, and work with each mail buffer +independently. -@ignore -@c Commented out because it is not user-oriented; -@c it doesn't say how to do some job. -- rms. -@cindex directory servers -@cindex LDAP -@cindex PH/QI -@cindex names and addresses -There is an interface to directory servers using various protocols such -as LDAP or the CCSO white pages directory system (PH/QI), described in a -separate manual. It may be useful for looking up names and addresses. -@xref{Top,,EUDC, eudc, EUDC Manual}. -@end ignore + Before using Emacs to send mail, you may need to customize the +variable @code{send-mail-function} if your system is not set up to +deliver mail directly via SMTP (@pxref{Mail Sending}). In addition, +you may need to customize @code{user-mail-address} if the system +cannot receive mail via SMTP (@pxref{Mail Headers}). @menu -* Format: Mail Format. Format of the mail being composed. -* Headers: Mail Headers. Details of some standard mail header fields. -* Aliases: Mail Aliases. Abbreviating and grouping mail addresses. -* Mode: Mail Mode. Special commands for editing mail being composed. -* Amuse: Mail Amusements. Distracting the NSA; adding fortune messages. -* Methods: Mail Methods. Using alternative mail-composition methods. +* Format: Mail Format. Format of a mail message. +* Headers: Mail Headers. Details of some standard mail header fields. +* Aliases: Mail Aliases. Abbreviating and grouping mail addresses. +* Commands: Mail Commands. Special commands for editing mail being composed. +* Signature: Mail Signature. Adding a signature to every message. +* Amuse: Mail Amusements. Distracting the NSA; adding fortune messages. +* Methods: Mail Methods. Using alternative mail-composition methods. @end menu @node Mail Format @section The Format of the Mail Buffer - In addition to the @dfn{text} or @dfn{body}, a message has @dfn{header -fields} which say who sent it, when, to whom, why, and so on. Some -header fields, such as @samp{Date} and @samp{Message-Id}, are created -automatically when you send the message. Others, such as the recipient -names, must be specified by you in order to send the message properly. + An email message must contain certain pieces of information, called +@dfn{headers}, which specify the message's sender, recipient(s), and +so on. - In the mail buffer, you can insert and edit header fields using -ordinary editing commands. Mail mode provides commands to help you -edit some header fields, and some are automatically preinitialized in -the buffer, when appropriate. + At the top of the mail buffer is a set of @dfn{header fields}, where +you can enter this information. You can insert and edit header fields +using ordinary editing commands. @xref{Header Editing}, for commands +specific to editing header fields. + + Some header fields are automatically pre-initialized in the buffer, +when appropriate; other headers, such as @samp{Date} and +@samp{Message-Id}, are normally omitted from the mail buffer and +created automatically when the message is sent. @vindex mail-header-separator The line in the buffer that says -@example +@smallexample --text follows this line-- -@end example +@end smallexample @noindent -is a special delimiter that separates the headers you have specified from -the text. Whatever follows this line is the text of the message; the -headers precede it. The delimiter line itself does not appear in the -message actually sent. The text used for the delimiter line is controlled -by the variable @code{mail-header-separator}. +separates the header fields from the @dfn{body} (or @dfn{text}) of the +message. Everything above this line is treated as part of the +headers; everything below it is treated as the body. The delimiter +line itself does not appear in the message actually sent. The text +used for the delimiter line is controlled by the variable +@code{mail-header-separator}. Here is an example of what the headers and text in the mail buffer might look like. @example -To: gnu@@gnu.org -CC: lungfish@@spam.org, byob@@spam.org +To: gnu@@example.org +CC: lungfish@@example.com, byob@@example.net Subject: The Emacs Manual --text follows this line-- Please ignore this message. @@ -134,85 +124,51 @@ equivalent in field names (and in mailing addresses also). After the colon and optional whitespace comes the contents of the field. - You can use any name you like for a header field, but normally people -use only standard field names with accepted meanings. Here is a table -of fields commonly used in outgoing messages. Emacs preinitializes some -of these when you start to compose a mail, depending on various options -you can set. You can delete or alter any header field before you send -the message, if you wish. + You can use any name you like for a header field, but normally +people use only standard field names with accepted meanings. Here is +a table of commonly-used fields. Emacs pre-initializes some of these, +depending on various options you can set. You can delete or alter any +header field before you send the message, if you wish. @table @samp +@item From +@vindex user-mail-address +The address of the sender (you). This should be a valid mailing +address, as replies will normally go there. Emacs initializes this +field using the variables @code{user-full-name} and +@code{user-mail-address}; see below. + @item To -This field contains the mailing addresses to which the message is -addressed. If you list more than one address, use commas, not spaces, -to separate them. +The mailing address(es) to which the message is addressed. To list +more than one address, use commas (not spaces) to separate them. @item Subject -The contents of the @samp{Subject} field should be a piece of text -that says what the message is about. The reason @samp{Subject} fields -are useful is that most mail-reading programs can provide a summary of -messages, listing the subject of each message but not its text. +A piece of text saying what the message is about. Most mail-reading +programs can display a summary of messages, listing the subject of +each message but not its text. @item CC -This field contains additional mailing addresses to send the message to, -like @samp{To} except that these readers should not regard the message -as directed at them. +Additional mailing address(es) to send the message to. This is like +@samp{To}, except that these readers should not regard the message as +directed at them. @item BCC -This field contains additional mailing addresses to send the message to, -which should not appear in the header of the message actually sent. -Copies sent this way are called @dfn{blind carbon copies}. - -@vindex mail-self-blind -@cindex copy of every outgoing message -To send a blind carbon copy of every outgoing message to yourself, set -the variable @code{mail-self-blind} to @code{t}. To send a blind carbon -copy of every message to some other @var{address}, set the variable -@code{mail-default-headers} to @code{"Bcc: @var{address}\n"}. +Additional mailing address(es) to send the message to, which should +not appear in the header of the message actually sent. ``BCC'' stands +for @dfn{blind carbon copies}. @item FCC -This field contains the name of one file and directs Emacs to append a -copy of the message to that file when you send the message. Emacs -writes the message in mbox format, unless the file is in Babyl format -(used by Rmail before Emacs 23), in which case Emacs writes Babyl. If -an Rmail buffer is visiting the file, Emacs updates it accordingly. -To specify more than one file, use several @samp{FCC} fields, with one -file name in each field. - -@vindex mail-archive-file-name -To put a fixed file name in the @samp{FCC} field each time you start -editing an outgoing message, set the variable -@code{mail-archive-file-name} to that file name. Unless you remove the -@samp{FCC} field before sending, the message will be written into that -file when it is sent. - -@item From -Use the @samp{From} field to say who you are. You might need to change -this if the account you are using to send the mail is not your own. The -contents of the @samp{From} field should be a valid mailing address, -since replies will normally go there. - -@vindex mail-setup-with-from -Emacs initializes this field (unless the variable -@code{mail-setup-with-from} is @code{nil}) using -@code{user-mail-address} as the default. If there is no @samp{From} -field when you send a mail, Emacs adds one. +The name of one file, to which a copy of the sent message should be +appended. Emacs writes the message in mbox format, unless the file is +in Babyl format (used by Rmail before Emacs 23), in which case Emacs +writes Babyl. If an Rmail buffer is visiting the file, Emacs updates +it accordingly. To specify more than one file, use several @samp{FCC} +fields, with one file name in each field. @item Reply-to -Use this field to direct replies to a different address. Most -mail-reading programs (including Rmail) automatically send replies to -the @samp{Reply-to} address in preference to the @samp{From} address. -By adding a @samp{Reply-to} field to your header, you can work around -any problems your @samp{From} address may cause for replies. - -@cindex @env{REPLYTO} environment variable -@vindex mail-default-reply-to -To put a fixed @samp{Reply-to} address into every outgoing message, set -the variable @code{mail-default-reply-to} to that address (as a string). -Then Emacs initializes the message with a @samp{Reply-to} field as -specified. When you first compose a mail, if -@code{mail-default-reply-to} is @code{nil}, Emacs initializes it from the -environment variable @env{REPLYTO}. +An address to which replies should be sent, instead of @samp{From}. +You can use this header if, for some reason, your @samp{From} address +is unable to receive replies. @item Mail-reply-to This field takes precedence over @samp{Reply-to}. It is used because @@ -225,70 +181,88 @@ It usually indicates that you want replies to go to the list, and that you do not need an extra copy sent directly to you. -@vindex mail-mailing-lists - The variable @code{mail-mailing-lists} holds a list of mailing list -addresses that you are subscribed to. If it is non-@code{nil}, Emacs -inserts an appropriate @samp{Mail-followup-to} header when sending mail -to a mailing list. - -@c There is also "Sent-via", added by C-c C-v, but it does not seem -@c particularly useful (?). +@c Message mode handles this differently... +@c @vindex mail-mailing-lists +@c The variable @code{mail-mailing-lists} holds a list of mailing list +@c addresses that you are subscribed to. If it is non-@code{nil}, Emacs +@c inserts an appropriate @samp{Mail-followup-to} header when sending mail +@c to a mailing list. @item In-reply-to -This field contains a piece of text describing the message you are -replying to. Some mail systems can use this information to correlate -related pieces of mail. Normally this field is filled in by Rmail -when you reply to a message in Rmail, and you never need to -think about it (@pxref{Rmail}). +A piece of text describing the message you are replying to. Some mail +systems can use this information to correlate related pieces of mail. +Normally, you never need to think about this, because it is filled in +automatically when you reply to a message in Rmail (or any other mail +program built into Emacs). @item References -This field lists the Message-Ids of related previous messages (a -Message-Id is a unique identifier generated when a message is sent). -Rmail sets up this field automatically when you reply to a message. +The Message-Ids of previous related messages (a Message-Id is a unique +identifier generated when a message is sent). Like +@samp{In-reply-to}, this is normally set up automatically for you. @end table - The @samp{To}, @samp{CC}, and @samp{BCC} header fields can appear -any number of times, and each such header field can contain multiple -addresses, separated by commas. This way, you can specify any number -of places to send the message. These fields can also have -continuation lines: one or more lines starting with whitespace, -following the starting line of the field, are considered part of the -field. Here's an example of a @samp{To} field with a continuation -line: +@noindent +The @samp{To}, @samp{CC}, and @samp{BCC} fields can appear any number +of times, and each such header field can contain multiple addresses, +separated by commas. This way, you can specify any number of places +to send the message. These fields can also have continuation lines: +one or more lines starting with whitespace, following the starting +line of the field, are considered part of the field. Here's an +example of a @samp{To} field with a continuation line: @example @group -To: foo@@here.net, this@@there.net, - me@@gnu.cambridge.mass.usa.earth.spiral3281 +To: foo@@example.net, this@@example.net, + bob@@example.com @end group @end example +@vindex user-full-name +@vindex user-mail-address + The default contents of the @samp{From} header field are computed +from the variables @code{user-full-name} and @code{user-mail-address}. +On some operating systems, Emacs initializes these two variables using +environment variables (@pxref{General Variables}). If this +information is unavailable or wrong, you can customize the variables +yourself (@pxref{Easy Customization}). + @vindex mail-from-style - When you send the message, if you didn't write a @samp{From} field -yourself, Emacs puts in one for you, using @code{user-mail-address}. -The variable @code{mail-from-style} controls the format: + The value of the variable @code{mail-from-style} specifies how to +format the address in the @samp{From} field: -@table @code -@item nil -Use just the email address, as in @samp{king@@grassland.com}. -@item parens -Use both email address and full name, as in:@* +@table @asis +@item @code{nil} +Use just the address, as in @samp{king@@grassland.com}. +@item @code{parens} +Use both address and full name, as in:@* @samp{king@@grassland.com (Elvis Parsley)}. -@item angles -Use both email address and full name, as in:@* +@item @code{angles} +Use both address and full name, as in:@* @samp{Elvis Parsley }. -@item system-default -Allow the system to insert the @samp{From} field. +@item any other value +Use @code{angles} for most addresses. However, if the address must be +``quoted'' to remain syntactically-valid under the @code{angles} +format but not under the @code{parens} format, use @code{parens} +instead. This is the default. @end table @c There is also mail-specify-envelope-from and mail-envelope-from, but @c these are probably not topics for the Emacs manual. @vindex mail-default-headers - You can direct Emacs to insert certain default headers into the -outgoing message by setting the variable @code{mail-default-headers} -to a string. Then @code{C-x m} inserts this string into the message -headers. If the default header fields are not appropriate for a + You can direct Emacs to insert certain default headers into the mail +buffer by setting the variable @code{mail-default-headers} to a +string. Then @kbd{C-x m} inserts this string into the message +headers. For example, here is how to add a @samp{Reply-to} and +@samp{FCC} header to each message: + +@smallexample +(setq mail-default-headers + "Reply-to: foo@@example.com\nFCC: ~/Mail/sent") +@end smallexample + +@noindent +If the default header fields are not appropriate for a particular message, edit them as necessary before sending the message. @node Mail Aliases @@ -296,29 +270,26 @@ @cindex mail aliases @cindex @file{.mailrc} file @cindex mailrc file +@vindex mail-personal-alias-file - You can define @dfn{mail aliases} in a file named @file{~/.mailrc}. -These are short mnemonic names which stand for mail addresses or groups of -mail addresses. Like many other mail programs, Emacs expands aliases -when they occur in the @samp{To}, @samp{From}, @samp{CC}, @samp{BCC}, and -@samp{Reply-to} fields, plus their @samp{Resent-} variants. -@c The list is defined by mail-address-field-regexp. + You can define @dfn{mail aliases}, which are short mnemonic names +that stand for mail addresses or groups of mail addresses. By +default, mail aliases are defined in the file @file{~/.mailrc}. You +can specify a different file name to use, by setting the variable +@code{mail-personal-alias-file}. - To define an alias in @file{~/.mailrc}, write a line in the following + To define an alias in @file{.mailrc}, write a line in the following format: @example -alias @var{shortaddress} @var{fulladdresses} +alias @var{nick} @var{fulladdresses} @end example @noindent -Here @var{fulladdresses} stands for one or more mail addresses for -@var{shortaddress} to expand into. Separate multiple addresses with -spaces; if an address contains a space, quote the whole address with a -pair of double quotes. - -For instance, to make @code{maingnu} stand for -@code{gnu@@gnu.org} plus a local address of your own, put in +This means that @var{nick} should expand into @var{fulladdresses}, +where @var{fulladdresses} can be either a single address, or multiple +addresses separated with spaces. For instance, to make @code{maingnu} +stand for @code{gnu@@gnu.org} plus a local address of your own, put in this line:@refill @example @@ -326,329 +297,248 @@ @end example @noindent -Addresses specified in this way should use double quotes around an -entire address when the address contains spaces. But you need not -include double quotes around parts of the address, such as the person's -full name. Emacs puts them in if they are needed. For example, +If an address contains a space, quote the whole address with a pair of +double quotes, like this: @example alias jsmith "John Q. Smith " @end example @noindent -is correct in @samp{.mailrc}. Emacs will insert the address as +Note that you need not include double quotes around individual parts +of the address, such as the person's full name. Emacs puts them in if +they are needed. For instance, it inserts the above address as @samp{"John Q. Smith" }. - Emacs also recognizes ``include'' commands in @samp{.mailrc} files. -They look like this: + Emacs also recognizes ``include'' commands in @file{.mailrc}. They +look like this: @example source @var{filename} @end example @noindent -The file @file{~/.mailrc} is used primarily by other mail-reading -programs; it can contain various other commands. Emacs ignores -everything in it except for alias definitions and include commands. - -@findex define-mail-alias - Another way to define a mail alias, within Emacs alone, is with the -@code{define-mail-alias} command. It prompts for the alias and then the -full address. You can use it to define aliases in your @file{.emacs} -file, like this: - -@example -(define-mail-alias "maingnu" "gnu@@gnu.org") -@end example - -@vindex mail-aliases - @code{define-mail-alias} records aliases by adding them to a -variable named @code{mail-aliases}. If you are comfortable with -manipulating Lisp lists, you can set @code{mail-aliases} directly. The -initial value of @code{mail-aliases} is @code{t}, which means that -Emacs should read @file{.mailrc} to get the proper value. +The @file{.mailrc} file is not unique to Emacs; many other +mail-reading programs use it for mail aliases, and it can contain +various other commands. However, Emacs ignores everything except +alias definitions and include commands. -@vindex mail-personal-alias-file - You can specify a different file name to use instead of -@file{~/.mailrc} by setting the variable -@code{mail-personal-alias-file}. - -@c There is also mail-alias-file for the system aliases. +@findex mail-abbrev-insert-alias + Mail aliases expand as abbrevs---that is to say, as soon as you type +a word-separator character after an alias (@pxref{Abbrevs}). This +expansion takes place only within the @samp{To}, @samp{From}, +@samp{CC}, @samp{BCC}, and @samp{Reply-to} header fields (plus their +@samp{Resent-} variants); it does not take place in other header +fields, such as @samp{Subject}. -@findex expand-mail-aliases - Normally, Emacs expands aliases when you send the message. You do not -need to expand mail aliases before sending the message, but you can -expand them if you want to see where the mail will actually go. To do -this, use the command @kbd{M-x expand-mail-aliases}; it expands all mail -aliases currently present in the mail headers that hold addresses. - - If you like, you can have mail aliases expand as abbrevs, as soon as -you type them in (@pxref{Abbrevs}). To enable this feature, execute the -following: - -@example -(add-hook 'mail-mode-hook 'mail-abbrevs-setup) -@end example + You can also insert an aliased address directly, using the command +@kbd{M-x mail-abbrev-insert-alias}. This reads an alias name, with +completion, and inserts its definition at point. -@noindent -@findex define-mail-abbrev -@vindex mail-abbrevs -This can go in your @file{.emacs} file. @xref{Hooks}. If you use this -feature, you must use @code{define-mail-abbrev} instead of -@code{define-mail-alias}; the latter does not work with this package. -Note that the mail abbreviation package uses the variable -@code{mail-abbrevs} instead of @code{mail-aliases}, and that all alias -names are converted to lower case. - -@kindex C-c C-a @r{(Mail mode)} -@findex mail-abbrev-insert-alias - The mail abbreviation package also provides the @kbd{C-c C-a} -(@code{mail-abbrev-insert-alias}) command, which reads an alias -name (with completion) and inserts its definition at point. This is -useful when editing the message text itself or a header field such as -@samp{Subject} in which Emacs does not normally expand aliases. - - Note that abbrevs expand only if you insert a word-separator character -afterward. However, you can rebind @kbd{C-n} and @kbd{M->} to cause -expansion as well. Here's how to do that: +@node Mail Commands +@section Mail Commands +@cindex Message mode +@cindex mode, Message -@smallexample -(add-hook 'mail-mode-hook - (lambda () - (define-key - mail-mode-map [remap next-line] 'mail-abbrev-next-line) - (define-key - mail-mode-map [remap end-of-buffer] 'mail-abbrev-end-of-buffer))) -@end smallexample + The default major mode for the @samp{*mail*} buffer is called +Message mode. It behaves like Text mode in many ways, but provides +several additional commands on the @kbd{C-c} prefix, which make +editing a message more convenient. -@node Mail Mode -@section Mail Mode -@cindex Mail mode -@cindex mode, Mail - - The major mode used in the mail buffer is Mail mode, which is much -like Text mode except that various special commands are provided on the -@kbd{C-c} prefix. These commands all have to do specifically with -editing or sending the message. - - Mail mode is normally used in buffers set up automatically by the -@code{mail} command and related commands. However, you can also switch -to Mail mode in a file-visiting buffer. This is a useful thing to do if -you have saved the text of a draft message in a file. + In this section, we will describe some of the most commonly-used +commands available in Message mode. +@ifnottex +Message mode also has its own manual, where its features are described +in greater detail. @xref{Top,,Message, message, Message}. +@end ifnottex @menu * Mail Sending:: Commands to send the message. * Header Editing:: Commands to move to header fields and edit them. -* Citing Mail:: Copying all or part of a message you are replying to. -* Mail Mode Misc:: Spell checking, signatures, etc. +* Citing Mail:: Quoting a message you are replying to. +* Mail Misc:: Attachments, spell checking, etc. @end menu @node Mail Sending @subsection Mail Sending - Mail mode has two commands for sending the message you have been -editing: + There are two commands to send a message you have been editing: @table @kbd +@item C-c C-c +Send the message, and deselect the mail buffer (@code{message-send-and-exit}). @item C-c C-s -Send the message, and leave the mail buffer selected (@code{mail-send}). -@item C-c C-c -Send the message, and select some other buffer (@code{mail-send-and-exit}). +Send the message, and leave the mail buffer selected (@code{message-send}). @end table -@kindex C-c C-s @r{(Mail mode)} -@kindex C-c C-c @r{(Mail mode)} -@findex mail-send -@findex mail-send-and-exit -@vindex mail-send-hook - @kbd{C-c C-s} (@code{mail-send}) sends the message and marks the mail -buffer unmodified, but leaves that buffer selected so that you can -modify the message (perhaps with new recipients) and send it again. -@kbd{C-c C-c} (@code{mail-send-and-exit}) sends and then deletes the -window or switches to another buffer. It puts the mail buffer at the -lowest priority for reselection by default, since you are finished with -using it. This is the usual way to send the message. Sending a message -runs the hook @code{mail-send-hook}. +@kindex C-c C-s @r{(Message mode)} +@kindex C-c C-c @r{(Message mode)} +@findex message-send + If you want to send a message and be done with it, type @kbd{C-c +C-c} (@code{mail-send-and-exit}). This sends the message and then +either deletes the window or switches to another buffer. It also +``buries'' the mail buffer, putting it at the lowest priority for +reselection. This is the usual command for sending a message. -@c Options not mentioned: mail-interactive, mail-use-dsn. +@findex message-send-and-exit + The command @kbd{C-c C-s} (@code{message-send}) sends the message +and marks the mail buffer unmodified, but leaves the buffer selected. +Use this command if you want to modify the message (perhaps with new +recipients) and send it again. + +@vindex message-send-hook + Sending a message runs the hook @code{message-send-hook}. In a file-visiting buffer, sending the message does not clear the modified flag, because only saving the file should do that. Also, you don't get a warning if you try to send the same message twice. -@c This is indexed in mule.texi, node "Recognize Coding". -@c @vindex sendmail-coding-system - When you send a message that contains non-@acronym{ASCII} characters, they need -to be encoded with a coding system (@pxref{Coding Systems}). Usually -the coding system is specified automatically by your chosen language -environment (@pxref{Language Environments}). You can explicitly specify -the coding system for outgoing mail by setting the variable -@code{sendmail-coding-system} (@pxref{Recognize Coding}). - - If the coding system thus determined does not handle the characters in -a particular message, Emacs asks you to select the coding system to use, +@vindex sendmail-coding-system + When you send a message containing non-@acronym{ASCII} characters, +they need to be encoded with a coding system (@pxref{Coding Systems}). +Usually the coding system is specified automatically by your chosen +language environment (@pxref{Language Environments}). You can +explicitly specify the coding system for outgoing mail by setting the +variable @code{sendmail-coding-system} (@pxref{Recognize Coding}). If +the coding system thus determined does not handle the characters in a +particular message, Emacs asks you to select the coding system to use, showing a list of possible coding systems. -@c Not mentioned: mail-send-nonascii. - @cindex SMTP @cindex Feedmail @cindex Sendmail @cindex Mailclient @vindex send-mail-function The variable @code{send-mail-function} controls how the default mail -user agent sends mail. It should be set to a function. In most cases, -the default is @code{sendmail-send-it}, which delivers mail using the -Sendmail installation on the local host. On Mac OS X and MS-Windows, -however, the default is normally @code{mailclient-send-it}, which -passes the mail buffer on to the system's designated mail client (see -@file{mailclient.el}). To send mail through an SMTP server, set -@code{send-mail-function} to @code{smtpmail-send-it} and set up the -Emacs SMTP library (@pxref{Top,,Emacs SMTP Library, smtpmail, Sending -mail via SMTP}). Another option is @code{feedmail-send-it} (see the -commentary section of the @file{feedmail.el} package). +user agent sends mail. Its value should be a function, which can be +one of the following: + +@table @code +@item sendmail-send-it +Send mail using the system's default @command{sendmail} (or +@command{sendmail}-compatible) program. This is the default on Unix +and GNU, and works provided the system is a valid @dfn{mail host} +(that is, provided it can deliver mail via SMTP). + +@item mailclient-send-it +Pass the mail buffer on to the system's designated mail client (see +@file{mailclient.el}). This is the default on Mac OS X and +MS-Windows. + +@item smtpmail-send-it +Send mail through an external mail host (e.g., your Internet service +provider's SMTP server). You will need to tell Emacs how to contact +the SMTP server, by customizing the variables +@code{smtpmail-smtp-server} and @code{smtpmail-auth-credentials}. +@xref{Top,,Emacs SMTP Library, smtpmail, Sending mail via SMTP}. + +@item feedmail-send-it +This is similar to @code{sendmail-send-it}, but allows you to queue +messages for later sending. See the commentary section in the file +@file{feedmail.el} for more information. +@end table @node Header Editing @subsection Mail Header Editing - Mail mode provides special commands to move to particular header -fields and to complete addresses in headers. + Message mode provides the following special commands to move to +particular header fields and to complete addresses in headers. @table @kbd @item C-c C-f C-t -Move to the @samp{To} header field, creating one if there is none -(@code{mail-to}). +Move to the @samp{To} header (@code{message-goto-to}). @item C-c C-f C-s -Move to the @samp{Subject} header field, creating one if there is -none (@code{mail-subject}). +Move to the @samp{Subject} header (@code{message-goto-subject}). @item C-c C-f C-c -Move to the @samp{CC} header field, creating one if there is none -(@code{mail-cc}). +Move to the @samp{CC} header (@code{message-goto-cc}). @item C-c C-f C-b -Move to the @samp{BCC} header field, creating one if there is none -(@code{mail-bcc}). +Move to the @samp{BCC} header (@code{message-goto-bcc}). @item C-c C-f C-r -Move to the @samp{Reply-To} header field, creating one if there is none -(@code{mail-reply-to}). -@item C-c C-f C-a -Move to the @samp{Mail-Reply-To} header field, creating one if there is none -(@code{mail-mail-reply-to}). -@item C-c C-f C-l -Move to the @samp{Mail-Followup-To} header field, creating one if there is none -(@code{mail-mail-followup-to}). +Move to the @samp{Reply-To} header (@code{message-goto-reply-to}). @item C-c C-f C-f +Move to the @samp{Mail-Followup-To} header field +(@code{message-goto-followup-to}). +@item C-c C-f C-w Add a new @samp{FCC} header field, with file-name completion -(@code{mail-fcc}). -@c There is also C-c C-v, mail-sent-via, which adds one or more -@c "Sent-via" headers, but I don't know what the point of that header is. -@item M-@key{TAB} -Complete a mailing address (@code{mail-complete}). +(@code{message-goto-fcc}). +@item C-c C-b +Move to the start of the message body (@code{message-goto-body}). +@item @key{TAB} +Complete a mailing address (@code{message-tab}). @end table -@kindex C-c C-f C-t @r{(Mail mode)} -@findex mail-to -@kindex C-c C-f C-s @r{(Mail mode)} -@findex mail-subject -@kindex C-c C-f C-c @r{(Mail mode)} -@findex mail-cc -@kindex C-c C-f C-b @r{(Mail mode)} -@findex mail-bcc -@kindex C-c C-f C-r @r{(Mail mode)} -@findex mail-reply-to -@kindex C-c C-f C-a @r{(Mail mode)} -@findex mail-mail-reply-to -@kindex C-c C-f C-l @r{(Mail mode)} -@findex mail-mail-followup-to -@kindex C-c C-f C-f @r{(Mail mode)} -@findex mail-fcc - There are several commands to move point to particular header fields, -all based on the prefix @kbd{C-c C-f} (@samp{C-f} is for ``field''). -They are listed in the table above. If the field in question does not -exist, these commands create one (the exception is @code{mail-fcc}, -which creates a new field each time). We provide special motion -commands for these particular fields because they are the fields users -most often want to edit. +@kindex C-c C-f C-t @r{(Message mode)} +@findex message-goto-to +@kindex C-c C-f C-s @r{(Message mode)} +@findex message-goto-subject +@kindex C-c C-f C-c @r{(Message mode)} +@findex message-goto-cc +@kindex C-c C-f C-b @r{(Message mode)} +@findex message-goto-bcc +@kindex C-c C-f C-r @r{(Message mode)} +@findex goto-reply-to +@kindex C-c C-f C-f @r{(Message mode)} +@findex goto-followup-to +@kindex C-c C-f C-w @r{(Message mode)} +@findex message-goto-fcc + The commands to move point to particular header fields are all based +on the prefix @kbd{C-c C-f} (@samp{C-f} is for ``field''). If the +field in question does not exist, the command creates one (the +exception is @code{mail-fcc}, which creates a new field each time). -@findex mail-complete -@kindex M-TAB @r{(Mail mode)} -@c `mail-complete-alist' specifies the headers. - While editing a header field that contains mailing addresses, such -as @samp{To:}, @samp{CC:} and @samp{BCC:}, you can complete a mailing -address by typing @kbd{M-@key{TAB}} (@code{mail-complete}). It -inserts the full name corresponding to the address, if it can -determine the full name. The variable @code{mail-complete-style} -controls whether to insert the full name, and what style to use, as in -@code{mail-from-style} (@pxref{Mail Headers}). (If your window -manager defines @kbd{M-@key{TAB}} to switch windows, you can type -@kbd{@key{ESC} @key{TAB}} or @kbd{C-M-i}.) +@kindex C-c C-b @r{(Message mode)} +@findex mail-text + The command @kbd{C-c C-b} (@code{message-goto-body}) moves point to +just after the header separator line---that is, to the beginning of +the body. - For completion purposes, the valid mailing addresses are taken to be -the local users' names plus your personal mail aliases (@pxref{Mail -Aliases}). You can specify additional sources of valid addresses; -browse the customization group @samp{mailalias} to see the variables for -customizing this feature (@pxref{Customization Groups}). - - If you type @kbd{M-@key{TAB}} in the body of the message, or on a -unrecognized header, @code{mail-complete} invokes the function specified -by @code{mail-complete-function}. By default, this is -@code{ispell-complete-word}, as in Text mode. +@findex message-tab +@kindex TAB @r{(Message mode)} + While editing a header field that contains addresses, such as +@samp{To:}, @samp{CC:} and @samp{BCC:}, you can complete an address by +typing @key{TAB} (@code{message-tab}). This attempts to insert the +full name corresponding to the address based on a couple of methods, +including EUDC, a library that recognizes a number of directory server +protocols (@pxref{Top,,EUDC,eudc, The Emacs Unified Directory +Client}). Failing that, it attempts to expand the address as a mail +alias (@pxref{Mail Aliases}). If point is on a header field that does +not take addresses, or if it is in the message body, then @key{TAB} +just inserts a tab character. @node Citing Mail @subsection Citing Mail @cindex citing mail - Mail mode also has commands for yanking or @dfn{citing} all or part of -a message that you are replying to. These commands are active only when -you started sending a message using an Rmail command. - @table @kbd @item C-c C-y -Yank the selected message from Rmail (@code{mail-yank-original}). -@item C-c C-r -Yank the region from the Rmail buffer (@code{mail-yank-region}). +Yank the selected message from Rmail (@code{message-yank-original}). @item C-c C-q Fill each paragraph cited from another message -(@code{mail-fill-yanked-message}). -@c There is also mail-split-line, but it does not seem very useful. +(@code{message-fill-yanked-message}). @end table -@kindex C-c C-y @r{(Mail mode)} -@findex mail-yank-original - When mail sending is invoked from the Rmail mail reader using an Rmail -command, @kbd{C-c C-y} can be used inside the mail buffer to insert the -text of the message you are replying to. Normally it indents each line -of that message three spaces and eliminates most header fields (as -specified by the variable @code{mail-yank-ignored-headers}). A numeric -argument specifies the number of spaces to indent (the variable -@code{mail-indentation-spaces} specifies the default number). An -argument of just @kbd{C-u} says not to indent at all and not to -eliminate anything. @kbd{C-c C-y} always uses the current message from -the Rmail buffer, so you can insert several old messages by selecting -one in Rmail, switching to @samp{*mail*} and yanking it, then switching -back to Rmail to select another. +@kindex C-c C-y @r{(Message mode)} +@findex message-yank-original +@findex message-yank-prefix + You can use the command @kbd{C-c C-y} (@code{message-yank-original}) +to @dfn{cite} a message that you are replying to. This inserts the +text of that message into the mail buffer. This command is active +only when the mail buffer is invoked from a mail program running in +Emacs, such as Rmail. -@vindex mail-yank-prefix - You can specify the text for @kbd{C-c C-y} to insert at the beginning -of each line: set @code{mail-yank-prefix} to the desired string. (A -value of @code{nil} means to use indentation; this is the default.) -However, @kbd{C-u C-c C-y} never adds anything at the beginning of the -inserted lines, regardless of the value of @code{mail-yank-prefix}. + By default, Emacs inserts the string @samp{>} in front of each line +of the cited text; this prefix string is specified by the variable +@code{message-yank-prefix}. If you call @code{message-yank-original} +with a prefix argument, the citation prefix is not inserted. -@kindex C-c C-r @r{(Mail mode)} -@findex mail-yank-region - To yank just a part of an incoming message, set the region in Rmail to -the part you want; then go to the @samp{*Mail*} message and type -@kbd{C-c C-r} (@code{mail-yank-region}). Each line that is copied is -indented or prefixed according to @code{mail-yank-prefix}. - -@kindex C-c C-q @r{(Mail mode)} +@kindex C-c C-q @r{(Message mode)} @findex mail-fill-yanked-message - After using @kbd{C-c C-y} or @kbd{C-c C-r}, you can type @kbd{C-c C-q} -(@code{mail-fill-yanked-message}) to fill the paragraphs of the yanked -old message or messages. One use of @kbd{C-c C-q} fills all such -paragraphs, each one individually. To fill a single paragraph of the -quoted message, use @kbd{M-q}. If filling does not automatically -handle the type of citation prefix you use, try setting the fill prefix + After using @kbd{C-c C-y}, you can type @kbd{C-c C-q} +(@code{message-fill-yanked-message}) to fill the paragraphs of the +cited message. One use of @kbd{C-c C-q} fills all such paragraphs, +each one individually. To fill a single paragraph of the quoted +message, use @kbd{M-q}. If filling does not automatically handle the +type of citation prefix you use, try setting the fill prefix explicitly. @xref{Filling}. @vindex mail-citation-hook @@ -657,91 +547,103 @@ package, which provides more flexible citation (@pxref{Introduction,,,sc, Supercite}). -@c No need to mention: mail-citation-prefix-regexp. - -@node Mail Mode Misc -@subsection Mail Mode Miscellany +@node Mail Misc +@subsection Mail Miscellany -@table @kbd -@item C-c C-t -Move to the beginning of the message body text (@code{mail-text}). -@item C-c C-w -Insert a signature at the end of the message text (@code{mail-signature}). -@item C-c C-i @var{file} @key{RET} -Insert the contents of @var{file} at the end of the message text -(@code{mail-attach-file}). -@item M-x ispell-message -Perform spelling correction on the message text, but not on citations from -other messages, or the message headers. -@end table - -@kindex C-c C-t @r{(Mail mode)} -@findex mail-text - @kbd{C-c C-t} (@code{mail-text}) moves point to just after the header -separator line---that is, to the beginning of the message body text. +@kindex C-c C-a @r{(Message mode)} +@findex mail-attach-file +@cindex MIME +@cindex Multipurpose Internet Mail Extensions + You can @dfn{attach} a file to an outgoing message by typing +@kbd{C-c C-a} (@code{mml-attach-file}) in the mail buffer. Attaching +is done using the MIME (Multipurpose Internet Mail Extensions) +standard. -@kindex C-c C-w @r{(Mail mode)} -@findex mail-signature -@vindex mail-signature - @kbd{C-c C-w} (@code{mail-signature}) adds a standard piece of text -(your @dfn{mail signature}) at the end of the message to say more about who -you are. For example, it may contain telephone numbers, or your -physical location. The text comes from the variable -@code{mail-signature}. It can be a fixed string, or a Lisp expression -that returns a string. If it is @code{t} or @code{nil}, the function -inserts the contents of the file @code{mail-signature-file}. By -default, this is the file @file{~/.signature} in your home directory. + The @code{mml-attach-file} command prompts for the name of the file, +and for the attachment's @dfn{content type}, @dfn{description}, and +@dfn{disposition}. The content type is normally detected +automatically; just type @key{RET} to accept the default. The +description is a single line of text that the recipient will see next +to the attachment; you may also choose to leave this empty. The +disposition is either @samp{inline} (the default), which means the +recipient will see a link to the attachment within the message body, +or @samp{attachment}, which means the link will be separate from the +body. - If the variable @code{mail-signature} has a non-@code{nil} value, -starting a mail automatically inserts your signature. Otherwise, you -must explicitly use the command @code{mail-signature}. If you want to -omit your signature from a particular message, just delete it from the -buffer before you send the message. + The actual contents of the attached file are not inserted into the +mail buffer. Instead, some placeholder text is inserted into the mail +buffer, like this: - Convention says that the start of your signature should be marked by a -line whose contents are @samp{-- }. If your signature comes from a -file, this prefix is added for you, but in all other cases you must add -it yourself. The remainder of your signature should be no more than -four lines. +@smallexample +<#part type="text/plain" filename="~/foo.txt" disposition=inline> +<#/part> +@end smallexample + +@noindent +When you type @kbd{C-c C-c} or @kbd{C-c C-s} to send the message, the +attached file will be delivered with it. @findex ispell-message - You can do spelling correction on the message text you have written -with the command @kbd{M-x ispell-message}. If you have yanked an -incoming message into the outgoing draft, this command skips what was -yanked, but it checks the text that you yourself inserted. (It looks -for indentation or @code{mail-yank-prefix} to distinguish the cited -lines from your input.) @xref{Spelling}. - -@kindex C-c C-i @r{(Mail mode)} -@findex mail-attach-file - To include a file in the outgoing message, you can use @kbd{C-x i}, -the usual command to insert a file in the current buffer. But it is -often more convenient to use a special command, @kbd{C-c C-i} -(@code{mail-attach-file}). This command inserts the file contents at -the end of the buffer, after your signature (if any), with a delimiter -line that includes the file name. Note that this is not a MIME -attachment. + While composing a message, you can do spelling correction on the +message text by typing @kbd{M-x ispell-message}. If you have yanked +an incoming message into the outgoing draft, this command skips what +was yanked, but it checks the text that you yourself inserted (it +looks for indentation or @code{mail-yank-prefix} to distinguish the +cited lines from your input). @xref{Spelling}. @vindex mail-mode-hook @vindex mail-setup-hook - Turning on Mail mode (which @kbd{C-x m} does automatically) runs the -normal hooks @code{text-mode-hook} and @code{mail-mode-hook}. + Turning on Message mode (which @kbd{C-x m} does automatically) runs +the normal hooks @code{text-mode-hook} and @code{message-mode-hook}. Initializing a new outgoing message runs the normal hook -@code{mail-setup-hook}; if you want to add special fields to your mail -header or make other changes to the appearance of the mail buffer, use -that hook. @xref{Hooks}. +@code{message-setup-hook}; you can use this hook if you want to make +changes to the appearance of the mail buffer. @xref{Hooks}. The main difference between these hooks is just when they are -invoked. Whenever you type @kbd{M-x mail}, @code{mail-mode-hook} runs -as soon as the @samp{*mail*} buffer is created. Then the -@code{mail-setup} function inserts the default contents of the buffer. -After these default contents are inserted, @code{mail-setup-hook} runs. +invoked. Whenever you type @kbd{C-x m}, @code{message-mode-hook} runs +as soon as the mail buffer is created. Then the @code{message-setup} +function inserts the default contents of the buffer. After these +default contents are inserted, @code{message-setup-hook} runs. + + If you use @kbd{C-x m} to continue an existing composition, +@code{message-mode-hook} runs immediately after switching to the mail +buffer. If the buffer is unmodified, or if you decide to erase it and +start again, @code{message-setup-hook} runs after the default contents +are inserted. + +@node Mail Signature +@section Mail Signature - If you use @kbd{M-x mail} to continue an existing composition, -@code{mail-mode-hook} runs immediately after switching to the -@samp{*mail*} buffer. If the buffer is unmodified, or if you decide to -erase it and start again, @code{mail-setup-hook} runs after the default -contents are inserted. +@cindex mail signature +@vindex mail-signature-file +@vindex mail-signature + You can add a standard piece of text---your @dfn{mail +signature}---to the end of every message. This signature may contain +information such as your telephone number or your physical location. +The variable @code{mail-signature} determines how Emacs handles the +mail signature. + + The default value of @code{mail-signature} is @code{t}; this means +to look for your mail signature in the file @file{~/.signature}. If +this file exists, its contents are automatically inserted into the end +of the mail buffer. You can change the signature file via the +variable @code{mail-signature-file}. + + If you change @code{mail-signature} to a string, that specifies the +text of the signature directly. + +@kindex C-c C-w @r{(Message mode)} +@findex message-insert-signature + If you change @code{mail-signature} to @code{nil}, Emacs will not +insert your mail signature automatically. You can insert your mail +signature by typing @kbd{C-c C-w} (@code{message-insert-signature}) in +the mail buffer. Emacs will look for your signature in the signature +file. + + By convention, a mail signature should be marked by a line whose +contents are @samp{-- }. If your signature lacks this prefix, it is +added for you. The remainder of your signature should be no more than +four lines. @node Mail Amusements @section Mail Amusements @@ -778,28 +680,32 @@ @node Mail Methods @section Mail-Composition Methods @cindex mail-composition methods +@cindex Mail mode +@cindex mode, Mail @cindex MH mail interface @cindex Message mode for sending mail In this chapter we have described the usual Emacs mode for editing -and sending mail---Mail mode. Emacs has alternative facilities for -editing and sending mail, including -MH-E and Message mode, not documented in this manual. -@xref{Top,,MH-E,mh-e, The Emacs Interface to MH}. @xref{Top,,Message,message, -Message Manual}. You can choose any of them as your preferred method. -The commands @code{C-x m}, @code{C-x 4 m} and @code{C-x 5 m} use -whichever agent you have specified, as do various other Emacs commands -and facilities that send mail. +and sending mail---Message mode. This is only one of several +available modes. Prior to Emacs 23.2, the default mode was Mail mode, +which is similar to Message mode in many respects but lacks features +such as MIME support. Another available mode is MH-E +(@pxref{Top,,MH-E,mh-e, The Emacs Interface to MH}). @vindex mail-user-agent - To specify your mail-composition method, customize the variable -@code{mail-user-agent}. Currently legitimate values include -@code{sendmail-user-agent} (Mail mode), @code{mh-e-user-agent}, -@code{message-user-agent} and @code{gnus-user-agent}. + You can choose any of these @dfn{mail user agents} as your preferred +method for editing and sending mail. The commands @code{C-x m}, +@code{C-x 4 m} and @code{C-x 5 m} use whichever agent you have +specified; so do various other parts of Emacs that send mail, such as +the bug reporter (@pxref{Bugs}). To specify a mail user agent, +customize the variable @code{mail-user-agent}. Currently, legitimate +values include @code{message-user-agent} (Message mode) +@code{sendmail-user-agent} (Mail mode), @code{gnus-user-agent}, and +@code{mh-e-user-agent}. If you select a different mail-composition method, the information -in this chapter about the @samp{*mail*} buffer and Mail mode does not -apply; the other methods use a different format of text in a different +in this chapter about the mail buffer and Message mode does not apply; +the other methods use a different format of text in a different buffer, and their commands are different as well. @vindex read-mail-command diff -r 86c85c80cd84 -r 5a619d0a9158 doc/emacs/text.texi --- a/doc/emacs/text.texi Mon Mar 29 14:00:56 2010 +0000 +++ b/doc/emacs/text.texi Thu Apr 01 14:34:20 2010 +0000 @@ -26,11 +26,16 @@ @xref{Outline Mode}. @end iftex +@cindex nXML mode +@cindex mode, XML +@cindex mode, nXML +@findex nxml-mode Emacs has other major modes for text which contains ``embedded'' -commands, such as @TeX{} and La@TeX{} (@pxref{TeX Mode}); HTML, SGML, -and XML (@pxref{HTML Mode}); and Groff and Nroff (@pxref{Nroff Mode}). -In addition, you can edit formatted text in WYSIWYG style (``what you -see is what you get''), using Enriched mode (@pxref{Formatted Text}). +commands, such as @TeX{} and La@TeX{} (@pxref{TeX Mode}); HTML and +SGML (@pxref{HTML Mode}); XML (@pxref{Top, nXML Mode,,nxml-mode, nXML +Mode}); and Groff and Nroff (@pxref{Nroff Mode}). In addition, you +can edit formatted text in WYSIWYG style (``what you see is what you +get''), using Enriched mode (@pxref{Formatted Text}). @cindex ASCII art If you need to edit pictures made out of text characters (commonly @@ -61,7 +66,7 @@ * Text Mode:: The major modes for editing text files. * Outline Mode:: Editing outlines. * TeX Mode:: Editing input to the formatter TeX. -* HTML Mode:: Editing HTML, SGML, and XML files. +* HTML Mode:: Editing HTML and SGML files. * Nroff Mode:: Editing input to the formatter nroff. * Formatted Text:: Editing formatted text directly in WYSIWYG fashion. * Text Based Tables:: Editing text-based tables in WYSIWYG fashion. @@ -923,10 +928,10 @@ @vindex text-mode-hook Entering Text mode runs the hook @code{text-mode-hook}. Other major modes related to Text mode also run this hook, followed by hooks of -their own; this includes Paragraph-Indent Text mode, Nroff mode, @TeX{} -mode, Outline mode, and Mail mode. Hook functions on -@code{text-mode-hook} can look at the value of @code{major-mode} to see -which of these modes is actually being entered. @xref{Hooks}. +their own; this includes Paragraph-Indent Text mode, Nroff mode, +@TeX{} mode, Outline mode, and Message mode. Hook functions on +@code{text-mode-hook} can look at the value of @code{major-mode} to +see which of these modes is actually being entered. @xref{Hooks}. @node Outline Mode @section Outline Mode @@ -1743,29 +1748,17 @@ Ref@TeX{}. @inforef{Top,, reftex}. @node HTML Mode -@section SGML, XML, and HTML Modes +@section SGML and HTML Modes @cindex SGML mode @cindex HTML mode -@cindex XML mode @cindex mode, SGML @cindex mode, HTML -@cindex mode, XML @findex sgml-mode @findex html-mode -@findex xml-mode - - The major modes for SGML, XML, and HTML provide indentation support -and commands for operating on tags. XML mode is actually identical to -SGML mode (to be precise, @code{xml-mode} is an alias for -@code{sgml-mode}), because XML is a strict subset of SGML. HTML mode -is a slightly customized variant of SGML mode. - -@vindex sgml-xml-mode - In XML, every opening tag must have an explicit closing tag. When -the variable @code{sgml-xml-mode} is non-@code{nil}, the tag insertion -commands described below always insert explicit closing tags as well. -When you visit a file, Emacs determines whether it is XML by examining -the file contents, and sets @code{sgml-xml-mode} accordingly. + + The major modes for SGML and HTML provide indentation support and +commands for operating on tags. HTML mode is a slightly customized +variant of SGML mode. @table @kbd @item C-c C-n @@ -1855,13 +1848,22 @@ @cindex mode, nXML @findex nxml-mode @cindex XML schema - Emacs also provides a more advanced mode for editing XML -documents, called nXML mode (@code{nxml-mode}). nXML mode is aware of -many existing XML schema, and uses them to provide completion of XML -elements via @kbd{C-@key{RET}} or @kbd{M-@key{TAB}}, as well as -``on-the-fly'' validation of XML, with errors highlighted via Font -Lock (@pxref{Font Lock}). It is described in its own manual. -@xref{Top, nXML Mode,,nxml-mode, nXML Mode}. + The default mode for editing XML documents is called nXML mode +(@code{xml-mode} or @code{nxml-mode}). This is a powerful major mode +that can recognize many existing XML schema and use them to provide +completion of XML elements via @kbd{C-@key{RET}} or @kbd{M-@key{TAB}}, +as well as ``on-the-fly'' XML validation with error highlighting. It +is described in its own manual. @xref{Top, nXML Mode,,nxml-mode, nXML +Mode}. + +@vindex sgml-xml-mode + However, you can also use SGML mode to edit XML, since XML is a +strict subset of SGML. In XML, every opening tag must have an +explicit closing tag. When the variable @code{sgml-xml-mode} is +non-@code{nil}, the tag insertion commands described above always +insert explicit closing tags as well. When you visit a file in SGML +mode, Emacs determines whether it is XML by examining the file +contents, and sets @code{sgml-xml-mode} accordingly. @node Nroff Mode @section Nroff Mode diff -r 86c85c80cd84 -r 5a619d0a9158 doc/lispref/ChangeLog --- a/doc/lispref/ChangeLog Mon Mar 29 14:00:56 2010 +0000 +++ b/doc/lispref/ChangeLog Thu Apr 01 14:34:20 2010 +0000 @@ -1,3 +1,8 @@ +2010-03-26 Chong Yidong + + * loading.texi (Hooks for Loading): Document after-load-functions. + Copyedits. + 2010-03-24 Arni Magnusson (tiny change) * frames.texi (Cursor Parameters): Fix typo. (Bug#5760) diff -r 86c85c80cd84 -r 5a619d0a9158 doc/lispref/loading.texi --- a/doc/lispref/loading.texi Mon Mar 29 14:00:56 2010 +0000 +++ b/doc/lispref/loading.texi Thu Apr 01 14:34:20 2010 +0000 @@ -920,8 +920,17 @@ @cindex loading hooks @cindex hooks for loading -You can ask for code to be executed if and when a particular library is -loaded, by calling @code{eval-after-load}. +You can ask for code to be executed each time Emacs loads a library, +by using the variable @code{after-load-functions}: + +@defvar after-load-functions +This abnormal hook is run after loading a file. Each function in the +hook is called with a single argument, the absolute filename of the +file that was just loaded. +@end defvar + +If you want code to be executed when a @emph{particular} library is +loaded, use the function @code{eval-after-load}: @defun eval-after-load library form This function arranges to evaluate @var{form} at the end of loading @@ -930,7 +939,7 @@ Don't forget to quote @var{form}! You don't need to give a directory or extension in the file name -@var{library}---normally you just give a bare file name, like this: +@var{library}. Normally, you just give a bare file name, like this: @example (eval-after-load "edebug" '(def-edebug-spec c-point t)) @@ -955,31 +964,30 @@ execution of the rest of @var{form}. @end defun -In general, well-designed Lisp programs should not use this feature. -The clean and modular ways to interact with a Lisp library are (1) -examine and set the library's variables (those which are meant for -outside use), and (2) call the library's functions. If you wish to -do (1), you can do it immediately---there is no need to wait for when -the library is loaded. To do (2), you must load the library (preferably -with @code{require}). +Normally, well-designed Lisp programs should not use +@code{eval-after-load}. If you need to examine and set the variables +defined in another library (those meant for outside use), you can do +it immediately---there is no need to wait until the library is loaded. +If you need to call functions defined by that library, you should load +the library, preferably with @code{require} (@pxref{Named Features}). But it is OK to use @code{eval-after-load} in your personal -customizations if you don't feel they must meet the design standards for -programs meant for wider use. +customizations if you don't feel that they must meet the design +standards for programs meant for wider use. @defvar after-load-alist -This variable, an alist built by @code{eval-after-load}, holds the -expressions to evaluate when particular libraries are loaded. Each -element looks like this: +This variable stores an alist built by @code{eval-after-load}, +containing the expressions to evaluate when certain libraries are +loaded. Each element looks like this: @example (@var{regexp-or-feature} @var{forms}@dots{}) @end example The key @var{regexp-or-feature} is either a regular expression or a -symbol, and the value is a list of forms. The forms are evaluated when -the key matches the absolute true name of the file being -@code{load}ed or the symbol being @code{provide}d. +symbol, and the value is a list of forms. The forms are evaluated +when the key matches the absolute true name or feature name of the +library being loaded. @end defvar @ignore diff -r 86c85c80cd84 -r 5a619d0a9158 doc/misc/ChangeLog --- a/doc/misc/ChangeLog Mon Mar 29 14:00:56 2010 +0000 +++ b/doc/misc/ChangeLog Thu Apr 01 14:34:20 2010 +0000 @@ -1,3 +1,13 @@ +2010-04-01 Teodor Zlatanov + + * gnus.texi (Finding the News): Add pointers to the Server buffer + because it's essential. + +2010-03-31 Katsumi Yamaoka + + * gnus.texi (MIME Commands): Update description of + gnus-article-browse-html-article. + 2010-03-27 Teodor Zlatanov * auth.texi (Secret Service API): Add TODO node. diff -r 86c85c80cd84 -r 5a619d0a9158 doc/misc/calc.texi --- a/doc/misc/calc.texi Mon Mar 29 14:00:56 2010 +0000 +++ b/doc/misc/calc.texi Thu Apr 01 14:34:20 2010 +0000 @@ -12167,7 +12167,7 @@ their default values, then settings from the file you named are loaded if this file exists, and this file becomes the one that Calc will use in the future for commands like @kbd{m m}. The default settings -file name is @file{~/.calc.el}. You can see the current file name by +file name is @file{~/.emacs.d/calc.el}. You can see the current file name by giving a blank response to the @kbd{m F} prompt. See also the discussion of the @code{calc-settings-file} variable; @pxref{Customizing Calc}. @@ -16006,7 +16006,7 @@ Selections show deep structure (@kbd{j b}; @pxref{Making Selections}). @item Save -Record modes in @file{~/.calc.el} (@kbd{m R}; @pxref{General Mode Commands}). +Record modes in @file{~/.emacs.d/calc.el} (@kbd{m R}; @pxref{General Mode Commands}). @item Local Record modes in Embedded buffer (@kbd{m R}). @@ -28108,7 +28108,7 @@ @cindex Calc init file, user-defined units The @kbd{u p} (@code{calc-permanent-units}) command stores the user-defined units in your Calc init file (the file given by the variable -@code{calc-settings-file}, typically @file{~/.calc.el}), so that the +@code{calc-settings-file}, typically @file{~/.emacs.d/calc.el}), so that the units will still be available in subsequent Emacs sessions. If there was already a set of user-defined units in your Calc init file, it is replaced by the new set. (@xref{General Mode Commands}, for a way to @@ -28509,7 +28509,7 @@ @cindex Calc init file, variables The @kbd{s p} (@code{calc-permanent-variable}) command saves a variable's value permanently in your Calc init file (the file given by -the variable @code{calc-settings-file}, typically @file{~/.calc.el}), so +the variable @code{calc-settings-file}, typically @file{~/.emacs.d/calc.el}), so that its value will still be available in future Emacs sessions. You can re-execute @w{@kbd{s p}} later on to update the saved value, but the only way to remove a saved variable is to edit your calc init file @@ -30862,7 +30862,7 @@ which are also available outside of Embedded mode. (@pxref{General Mode Commands}.) They are @code{Save}, in which mode settings are recorded permanently in your Calc init file (the file given -by the variable @code{calc-settings-file}, typically @file{~/.calc.el}) +by the variable @code{calc-settings-file}, typically @file{~/.emacs.d/calc.el}) rather than by annotating the current document, and no-recording mode (where there is no symbol like @code{Save} or @code{Local} in the mode line), in which mode-changing commands do not leave any @@ -31122,7 +31122,7 @@ binding permanent so that it will remain in effect even in future Emacs sessions. (It does this by adding a suitable bit of Lisp code into your Calc init file; that is, the file given by the variable -@code{calc-settings-file}, typically @file{~/.calc.el}.) For example, +@code{calc-settings-file}, typically @file{~/.emacs.d/calc.el}.) For example, @kbd{Z P s} would register our @code{sincos} command permanently. If you later wish to unregister this command you must edit your Calc init file by hand. (@xref{General Mode Commands}, for a way to tell Calc to @@ -31855,7 +31855,7 @@ A good place to put your @code{defmath} commands is your Calc init file (the file given by @code{calc-settings-file}, typically -@file{~/.calc.el}), which will not be loaded until Calc starts. +@file{~/.emacs.d/calc.el}), which will not be loaded until Calc starts. If a file named @file{.emacs} exists in your home directory, Emacs reads and executes the Lisp forms in this file as it starts up. While it may seem reasonable to put your favorite @code{defmath} commands there, @@ -34956,7 +34956,9 @@ @code{nil}, then Calc will automatically load your settings file (if it exists) the first time Calc is invoked. -The default value for this variable is @code{"~/.calc.el"}. +The default value for this variable is @code{"~/.emacs.d/calc.el"} +unless the file @file{~/.calc.el} exists, in which case the default +value will be @code{"~/.calc.el"}. @end defvar @defvar calc-gnuplot-name diff -r 86c85c80cd84 -r 5a619d0a9158 doc/misc/gnus.texi --- a/doc/misc/gnus.texi Mon Mar 29 14:00:56 2010 +0000 +++ b/doc/misc/gnus.texi Thu Apr 01 14:34:20 2010 +0000 @@ -996,6 +996,15 @@ @section Finding the News @cindex finding news +First of all, you should know that there is a special buffer called +@code{*Server*} that lists all the servers Gnus knows about. You can +press @kbd{^} from the Group buffer to see it. In the Server buffer, +you can press @kbd{RET} on a defined server to see all the groups it +serves (subscribed or not!). You can also add or delete servers, edit +a foreign server's definition, agentize or de-agentize a server, and +do many other neat things. @xref{Server Buffer}. +@xref{Foreign Groups}. @xref{Agent Basics}. + @vindex gnus-select-method @c @head The @code{gnus-select-method} variable says where Gnus should look for @@ -10506,17 +10515,24 @@ @kindex K H (Summary) @findex gnus-article-browse-html-article View @samp{text/html} parts of the current article with a WWW browser. -The message header is added to the beginning of every html part unless -the prefix argument is given. - -Warning: Spammers use links to images in HTML articles to verify whether -you have read the message. As this command passes the @acronym{HTML} -content to the browser without eliminating these ``web bugs'' you should -only use it for mails from trusted senders. +Inline images embedded in a message using the @code{cid} scheme, as they +are generally considered to be safe, will be processed properly. The +message header is added to the beginning of every @acronym{HTML} part +unless the prefix argument is given. + +Warning: Spammers use links to images (using the @code{http} scheme) in +@acronym{HTML} articles to verify whether you have read the message. As +this command passes the @acronym{HTML} content to the browser without +eliminating these ``web bugs'' you should only use it for mails from +trusted senders. If you always want to display @acronym{HTML} parts in the browser, set @code{mm-text-html-renderer} to @code{nil}. +This command creates temporary files to pass @acronym{HTML} contents +including images if any to the browser, and deletes them when exiting +the group (if you want). + @item K b @kindex K b (Summary) Make all the @acronym{MIME} parts have buttons in front of them. This is diff -r 86c85c80cd84 -r 5a619d0a9158 etc/ChangeLog --- a/etc/ChangeLog Mon Mar 29 14:00:56 2010 +0000 +++ b/etc/ChangeLog Thu Apr 01 14:34:20 2010 +0000 @@ -1,3 +1,21 @@ +2010-03-30 Chong Yidong + + * images/icons/hicolor/scalable/apps/emacs.svg: Put preamble after + svg tag (Bug#5790). + +2010-03-30 Eli Zaretskii + + * PROBLEMS: Mention problems on MS-Windows with incompatible + regex.h headers. + +2010-03-28 Eli Zaretskii + + * HELLO: Reorder Arabic and Hebrew into logical order, and + insert RLM before the opening paren, to make the display more + reasonable. Add setting for bidi-display-reordering in the local + variables section. + * NEWS: Mention initial support for bidirectional editing. + 2010-03-24 Francesc Rocher * MORE.STUFF: Remove CEDET entry, now distributed as part of diff -r 86c85c80cd84 -r 5a619d0a9158 etc/HELLO --- a/etc/HELLO Mon Mar 29 14:00:56 2010 +0000 +++ b/etc/HELLO Thu Apr 01 14:34:20 2010 +0000 @@ -16,7 +16,7 @@ LANGUAGE (NATIVE NAME) HELLO ---------------------- ----- Amharic ($,1O M[MmN{(B) $,1M`MKM](B -Arabic (,GIqjHQYdG(B) ,GecjdY(B ,GeGdqSdG(B +Arabic $,1ro(B(,GGdYQHjqI(B) ,GecjdY(B ,GeGdqSdG(B Bengali ($,17,7>6b727>(B) $,17(7.787M6u7>70(B Braille $,2(3(1('('(5(B Burmese ($,1H9HYH;H4HYrlH9HL(B) $,1H9H$HYrmH"H + - + + * cus-edit.el (custom-buffer-sort-alphabetically): Update + :version. + +2010-03-31 Juri Linkov + + * simple.el (next-line, previous-line): Re-throw a signal + with `signal' instead of using `ding'. + http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg01432.html + +2010-03-31 Juri Linkov + + * simple.el (keyboard-escape-quit): Raise deselecting the active + region higher than exiting the minibuffer. + http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg00904.html + +2010-03-31 Juri Linkov + + * image.el (image-animated-p): Use `image-metadata' instead of + `image-extension-data'. Get GIF extenstion data from metadata + property `extension-data'. + +2010-03-31 Stefan Monnier + + * simple.el (append-to-buffer): Simplify. + +2010-03-31 Tomas Abrahamsson + + * textmodes/artist.el (artist-mode): Fix typo in docstring. + Reported by Alex Schröder . (Bug#5807) + +2010-03-31 Kenichi Handa + + * language/sinhala.el (composition-function-table): Fix regexp for + the new Unicode specification. + + * language/indian.el (devanagari-composable-pattern) + (tamil-composable-pattern, kannada-composable-pattern) + (malayalam-composable-pattern): Adjust for the new Unicode + specification. + (bengali-composable-pattern, gurmukhi-composable-pattern) + (gujarati-composable-pattern, oriya-composable-pattern) + (telugu-composable-pattern): New variables to cope with the new + Unicode specification. Use them in composition-function-table. + +2010-03-31 Stefan Monnier + + Make tmm-menubar work for the Buffers menu again. + * tmm.el (tmm-prompt): Also handle keymap entries in the form of + vectors rather than cons cells, as used in menu-bar-update-buffers. + +2010-03-31 Chong Yidong + + * progmodes/js.el (js-auto-indent-flag, js-mode-map) + (js-insert-and-indent): Revert 2009-08-15 change, restoring + electric punctuation for "{}();,:" (Bug#5586). + + * mail/sendmail.el (mail-default-directory): Doc fix. + +2010-03-31 Chong Yidong + + * mail/sendmail.el (mail-default-directory): Doc fix. + +2010-03-31 Eli Zaretskii + + * subr.el (version-regexp-alist, version-to-list) + (version-list-<, version-list-=, version-list-<=) + (version-list-not-zero, version<, version<=, version=): Doc fix. + (Bug#5744). + +2010-02-31 Dan Nicolaescu + + * vc.el (vc-root-diff): Doc fix. + +2010-03-31 Chong Yidong + + * vc.el (vc-print-log, vc-print-root-log): Doc fix. + + * simple.el (append-to-buffer): Fix last change. + +2010-03-31 Chong Yidong + + * simple.el (append-to-buffer): Ensure that point is preserved if + BUFFER is the current buffer. Suggested by YAMAMOTO Mitsuharu. + (Bug#5749) + +2010-03-31 Stefan Monnier + + * files.el (auto-mode-case-fold): Change default to t. + +2010-03-30 Juri Linkov + + * dired-x.el (dired-omit-mode): Doc fix. + +2010-03-30 Juri Linkov + + * replace.el (occur-accumulate-lines): Move occur-engine related + functions `occur-accumulate-lines' and `occur-engine-add-prefix' + to be located after `occur-engine'. + +2010-03-30 Juri Linkov + + Make occur handle multi-line matches cleanly with context. + http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg01280.html + + * replace.el (occur-accumulate-lines): Add optional arg `pt'. + (occur-engine): Add local variables `ret', `prev-after-lines', + `prev-lines'. Use more arguments for `occur-context-lines'. + Set first elem of its returned list to `data', and the second elem + to `prev-after-lines'. Don't print the separator line. + In the end, print remaining context after-lines. + (occur-context-lines): Add new arguments `begpt', `endpt', + `lines', `prev-lines', `prev-after-lines'. Rewrite to combine + after-lines of the previous match with before-lines of the + current match and not overlap them. Return a list with two + values: the output line and the list of context after-lines. + +2010-03-30 Juri Linkov + + * replace.el (occur-accumulate-lines): Fix a bug where the first + context line at the beginning of the buffer was missing. + +2010-03-30 Eli Zaretskii + + * files.el: Make bidi-display-reordering safe variable for boolean + values. + +2010-03-29 Phil Hagelberg + Chong Yidong + + * subr.el: Extend progress reporters to perform "spinning". + (progress-reporter-update, progress-reporter-do-update): + Handle non-numeric value arguments. + (progress-reporter--pulse-characters): New var. + 2010-03-28 Chong Yidong * progmodes/compile.el (compilation-start): Fix regexp detection @@ -7,6 +143,13 @@ * find-dired.el (find-dired): Use read-directory-name (Bug#5777). +2010-03-27 Nick Roberts + + Restore GDB/MI fuctionality removed by r99212. + * lisp/progmodes/gdb-mi.el: Restore. + * lisp/progmodes/gdb-ui.el: Remove. + * lisp/progmodes/gud.el: Re-accommodate for gdb-mi.el. + 2010-03-25 Glenn Morris * desktop.el (desktop-save-buffer-p): Don't mistakenly include @@ -320,11 +463,13 @@ * vc-bzr.el (vc-bzr-checkin): Pass extra arguments to the commit command. - (log-edit-extra-flags, log-edit-before-checkin-process): New declarations. + (log-edit-extra-flags, log-edit-before-checkin-process): + New declarations. * vc-hg.el (vc-hg-checkin): Pass extra arguments to the commit command. - (log-edit-extra-flags, log-edit-before-checkin-process): New declarations. + (log-edit-extra-flags, log-edit-before-checkin-process): + New declarations. (vc-hg-log-edit-mode): New derived mode. * vc-arch.el (vc-arch-checkin): @@ -423,8 +568,8 @@ (widget-field-value-set): New fun. (editable-field): Use it. (widget-field-value-get): Clean up unused var. - (widget-color-value-create, widget-color--choose-action): New - funs. Allow using list-colors-display to choose color. + (widget-color-value-create, widget-color--choose-action): + New funs. Allow using list-colors-display to choose color. 2010-03-12 Chong Yidong @@ -435,8 +580,7 @@ (custom-buffer-create-internal): Add custom-apropos search field. (custom-add-parent-links): Don't display parent doc. (custom-group-value-create): Don't sort top-level custom group. - (custom-magic-value-create): Show visibility button before option - name. + (custom-magic-value-create): Show visibility button before option name. (custom-variable-state): New fun, from custom-variable-state-set. (custom-variable-state-set): Use it. @@ -574,8 +718,8 @@ 2010-03-07 Å tÄ›pán NÄ›mec (tiny change) - * vc-git.el (vc-git-annotate-extract-revision-at-line): Use - vc-git-root as default directory for revision path (Bug#5657). + * vc-git.el (vc-git-annotate-extract-revision-at-line): + Use vc-git-root as default directory for revision path (Bug#5657). 2010-03-06 Chong Yidong @@ -664,8 +808,8 @@ 2010-02-28 Michael Albinus * net/dbus.el (dbus-introspect, dbus-get-property) - (dbus-set-property, dbus-get-all-properties): Use - `dbus-call-method' when noninteractive. (Bug#5645) + (dbus-set-property, dbus-get-all-properties): + Use `dbus-call-method' when noninteractive. (Bug#5645) 2010-02-28 Chong Yidong @@ -2050,9 +2194,9 @@ 2009-12-18 Ulf Jasper - * calendar/icalendar.el (icalendar--convert-tz-offset): Fixed - timezone names. - (icalendar--convert-tz-offset): Fixed the "last-day-problem". + * calendar/icalendar.el (icalendar--convert-tz-offset): + Fix timezone names. + (icalendar--convert-tz-offset): Fix the "last-day-problem". (icalendar--add-diary-entry): Remove the trailing blank that diary-make-entry inserts. @@ -2069,7 +2213,7 @@ (tramp-advice-file-expand-wildcards): Remove it. * net/tramp-compat.el (top): Autoload `tramp-handle-file-remote-p'. - (tramp-advice-file-expand-wildcards): Moved from tramp.el. + (tramp-advice-file-expand-wildcards): Move from tramp.el. Activate advice for older GNU Emacs versions. (Bug#5237) 2009-12-17 Juanma Barranquero @@ -2086,12 +2230,12 @@ * files.el (hack-local-variables-filter): While ignoring duplicates, don't take `mode' into account. - (hack-local-variables-filter, hack-dir-local-variables): Don't - remove duplicate `mode' from local-variables-alist (like `eval'). + (hack-local-variables-filter, hack-dir-local-variables): + Don't remove duplicate `mode' from local-variables-alist (like `eval'). 2009-12-17 Juri Linkov - Make `dired-diff' more safe. (Bug#5225) + Make `dired-diff' safer. (Bug#5225) * dired-aux.el (dired-diff): Signal an error when `file' equals to `current' or when `file' is a directory of the `current' file. @@ -2288,7 +2432,7 @@ 2009-12-09 Vivek Dasmohapatra - Drop some properties to avoid surprises. + Drop some properties to avoid surprises (bug#5002). * htmlfontify.el (hfy-ignored-properties): New defcustom. (hfy-fontify-buffer): Use it. diff -r 86c85c80cd84 -r 5a619d0a9158 lisp/cus-edit.el --- a/lisp/cus-edit.el Mon Mar 29 14:00:56 2010 +0000 +++ b/lisp/cus-edit.el Thu Apr 01 14:34:20 2010 +0000 @@ -675,7 +675,8 @@ (defcustom custom-buffer-sort-alphabetically t "Whether to sort customization groups alphabetically in Custom buffer." :type 'boolean - :group 'custom-buffer) + :group 'custom-buffer + :version "24.1") (defcustom custom-buffer-order-groups 'last "If non-nil, order group members within each customization group. diff -r 86c85c80cd84 -r 5a619d0a9158 lisp/dired-x.el --- a/lisp/dired-x.el Mon Mar 29 14:00:56 2010 +0000 +++ b/lisp/dired-x.el Thu Apr 01 14:34:20 2010 +0000 @@ -163,7 +163,13 @@ otherwise. Enabling and disabling is buffer-local. If enabled, \"uninteresting\" files are not listed. Uninteresting files are those whose filenames match regexp `dired-omit-files', -plus those ending with extensions in `dired-omit-extensions'." +plus those ending with extensions in `dired-omit-extensions'. + +To enable omitting in every Dired buffer, you can put in your ~/.emacs + + (add-hook 'dired-mode-hook (lambda () (dired-omit-mode 1))) + +See Info node `(dired-x) Omitting Variables' for more information." :group 'dired-x (if dired-omit-mode ;; This will mention how many lines were omitted: diff -r 86c85c80cd84 -r 5a619d0a9158 lisp/files.el --- a/lisp/files.el Mon Mar 29 14:00:56 2010 +0000 +++ b/lisp/files.el Thu Apr 01 14:34:20 2010 +0000 @@ -2159,7 +2159,7 @@ (if (fboundp 'ucs-set-table-for-input) ; don't lose when building (ucs-set-table-for-input))) -(defcustom auto-mode-case-fold nil +(defcustom auto-mode-case-fold t "Non-nil means to try second pass through `auto-mode-alist'. This means that if the first case-sensitive search through the alist fails to find a matching major mode, a second case-insensitive search is made. @@ -2768,14 +2768,15 @@ (mapc (lambda (pair) (put (car pair) 'safe-local-variable (cdr pair))) - '((buffer-read-only . booleanp) ;; C source code - (default-directory . stringp) ;; C source code - (fill-column . integerp) ;; C source code - (indent-tabs-mode . booleanp) ;; C source code - (left-margin . integerp) ;; C source code - (no-update-autoloads . booleanp) - (tab-width . integerp) ;; C source code - (truncate-lines . booleanp))) ;; C source code + '((buffer-read-only . booleanp) ;; C source code + (default-directory . stringp) ;; C source code + (fill-column . integerp) ;; C source code + (indent-tabs-mode . booleanp) ;; C source code + (left-margin . integerp) ;; C source code + (no-update-autoloads . booleanp) + (tab-width . integerp) ;; C source code + (truncate-lines . booleanp) ;; C source code + (bidi-display-reordering . booleanp))) ;; C source code (put 'c-set-style 'safe-local-eval-function t) diff -r 86c85c80cd84 -r 5a619d0a9158 lisp/gnus/ChangeLog --- a/lisp/gnus/ChangeLog Mon Mar 29 14:00:56 2010 +0000 +++ b/lisp/gnus/ChangeLog Thu Apr 01 14:34:20 2010 +0000 @@ -1,3 +1,39 @@ +2010-03-31 Katsumi Yamaoka + + * gnus-art.el (gnus-article-browse-html-save-cid-content): Rename from + gnus-article-browse-html-save-cid-image; make it work recursively for + forwarded messages as well. + (gnus-article-browse-html-parts): Work when prefix arg is given. + (gnus-article-browse-html-article): Doc fix. + +2010-03-30 Chong Yidong + + * message.el (message-default-mail-headers): + (message-default-headers): Carry the value mail-default-headers over + into message-default-mail-headers, rather than message-default-headers. + +2010-03-30 Martin Stjernholm + + * mm-decode.el (mm-add-meta-html-tag): Add option to override the + charset. + + * gnus-art.el (gnus-article-browse-html-parts): Force the correct + charset into the tag when the article is encoded to utf-8. + +2010-03-30 Katsumi Yamaoka + + * gnus-art.el (gnus-article-browse-delete-temp-files): + Delete directories as well. + (gnus-article-browse-html-parts): Work for images that do not specify + file names; delete temp directory when quitting; insert header at the + right place; use file: scheme for image files. + +2010-03-30 Eric Schulte + + * gnus-art.el (gnus-article-browse-html-save-cid-image): New function. + (gnus-article-browse-html-parts): Use it to make temporary cid image + files in addition to html file so that browser may display them. + 2010-03-29 Katsumi Yamaoka * mm-decode.el (mm-add-meta-html-tag): Fix regexp matching meta tag. @@ -8,8 +44,8 @@ 2010-03-27 Teodor Zlatanov - * auth-source.el (auth-sources): Change default to be simpler. Explain - about Secret Service API sources. Improve Customize options. + * auth-source.el (auth-sources): Change default to be simpler. + Explain about Secret Service API sources. Improve Customize options. (auth-source-pick): Change to accept any number of search parameters. Implement fallbacks iteratively, not recursively. Add scoring on the second pass and sort by score. Call Secret Service API when needed. diff -r 86c85c80cd84 -r 5a619d0a9158 lisp/gnus/gnus-art.el --- a/lisp/gnus/gnus-art.el Mon Mar 29 14:00:56 2010 +0000 +++ b/lisp/gnus/gnus-art.el Thu Apr 01 14:34:20 2010 +0000 @@ -2819,18 +2819,47 @@ ;; `how' is neither `nil', `ask' nor `t' (i.e. `file'): (gnus-y-or-n-p (format "Delete temporary HTML file `%s'? " file)))) - (delete-file file))) + (if (file-directory-p file) + (gnus-delete-directory file) + (delete-file file)))) ;; Also remove file from the list when not deleted or if file doesn't ;; exist anymore. (setq gnus-article-browse-html-temp-list nil)) gnus-article-browse-html-temp-list) +(defun gnus-article-browse-html-save-cid-content (cid handles directory) + "Find CID content in HANDLES and save it in a file in DIRECTORY. +Return file name." + (save-match-data + (let (file type) + (catch 'found + (dolist (handle handles) + (cond + ((not (listp handle))) + ((equal (mm-handle-media-supertype handle) "multipart") + (when (setq file (gnus-article-browse-html-save-cid-content + cid handle directory)) + (throw 'found file))) + ((equal (concat "<" cid ">") (mm-handle-id handle)) + (setq file + (expand-file-name + (or (mail-content-type-get + (mm-handle-disposition handle) 'filename) + (mail-content-type-get + (setq type (mm-handle-type handle)) 'name) + (concat + (make-temp-name "cid") + (car (rassoc (car type) mailcap-mime-extensions)))) + directory)) + (mm-save-part-to-file handle file) + (throw 'found file)))))))) + (defun gnus-article-browse-html-parts (list &optional header) "View all \"text/html\" parts from LIST. Recurse into multiparts. The optional HEADER that should be a decoded message header will be added to the bodies of the \"text/html\" parts." ;; Internal function used by `gnus-article-browse-html-article'. - (let (type file charset tmp-file showed) + (let (type file charset content cid-dir tmp-file showed) ;; Find and show the html-parts. (dolist (handle list) ;; If HTML, show it: @@ -2853,16 +2882,42 @@ (setq handle (mm-handle-cache handle) type (mm-handle-type handle)) (equal (car type) "text/html")))) - (when (or (setq charset (mail-content-type-get type 'charset)) - header - (not file)) + (setq charset (mail-content-type-get type 'charset) + content (mm-get-part handle)) + (with-temp-buffer + (if (eq charset 'gnus-decoded) + (mm-enable-multibyte) + (mm-disable-multibyte)) + (insert content) + ;; resolve cid contents + (let ((case-fold-search t) + cid-file) + (goto-char (point-min)) + (while (re-search-forward "\ +]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\"" + nil t) + (unless cid-dir + (setq cid-dir (make-temp-file "cid" t)) + (add-to-list 'gnus-article-browse-html-temp-list cid-dir)) + (setq file nil + content nil) + (when (setq cid-file + (gnus-article-browse-html-save-cid-content + (match-string 2) + (with-current-buffer gnus-article-buffer + gnus-article-mime-handles) + cid-dir)) + (replace-match (concat "file://" cid-file) + nil nil nil 1)))) + (unless content (setq content (buffer-string)))) + (when (or charset header (not file)) (setq tmp-file (mm-make-temp-file ;; Do we need to care for 8.3 filenames? "mm-" nil ".html"))) ;; Add a meta html tag to specify charset and a header. (cond (header - (let (title eheader body hcharset coding) + (let (title eheader body hcharset coding force-charset) (with-temp-buffer (mm-enable-multibyte) (setq case-fold-search t) @@ -2885,8 +2940,8 @@ charset) title (when title (mm-encode-coding-string title charset)) - body (mm-encode-coding-string (mm-get-part handle) - charset)) + body (mm-encode-coding-string content charset) + force-charset t) (setq hcharset (mm-find-mime-charset-region (point-min) (point-max))) (cond ((= (length hcharset) 1) @@ -2907,7 +2962,7 @@ title (when title (mm-encode-coding-string title coding)) - body (mm-get-part handle)) + body content) (setq charset 'utf-8 eheader (mm-encode-coding-string (buffer-string) charset) @@ -2916,22 +2971,23 @@ title charset)) body (mm-encode-coding-string (mm-decode-coding-string - (mm-get-part handle) body) - charset)))) + content body) + charset) + force-charset t))) (setq charset hcharset eheader (mm-encode-coding-string (buffer-string) coding) title (when title (mm-encode-coding-string title coding)) - body (mm-get-part handle))) + body content)) (setq eheader (mm-string-as-unibyte (buffer-string)) - body (mm-get-part handle)))) + body content))) (erase-buffer) (mm-disable-multibyte) (insert body) (when charset - (mm-add-meta-html-tag handle charset)) + (mm-add-meta-html-tag handle charset force-charset)) (when title (goto-char (point-min)) (unless (search-forward "" nil t) @@ -2948,10 +3004,9 @@ (charset (mm-with-unibyte-buffer (insert (if (eq charset 'gnus-decoded) - (mm-encode-coding-string - (mm-get-part handle) - (setq charset 'utf-8)) - (mm-get-part handle))) + (mm-encode-coding-string content + (setq charset 'utf-8)) + content)) (if (or (mm-add-meta-html-tag handle charset) (not file)) (mm-write-region (point-min) (point-max) @@ -2998,17 +3053,23 @@ (defun gnus-article-browse-html-article (&optional arg) "View \"text/html\" parts of the current article with a WWW browser. +Inline images embedded in a message using the cid scheme, as they are +generally considered to be safe, will be processed properly. The message header is added to the beginning of every html part unless the prefix argument ARG is given. -Warning: Spammers use links to images in HTML articles to verify -whether you have read the message. As +Warning: Spammers use links to images (using the http scheme) in HTML +articles to verify whether you have read the message. As `gnus-article-browse-html-article' passes the HTML content to the browser without eliminating these \"web bugs\" you should only use it for mails from trusted senders. If you always want to display HTML parts in the browser, set -`mm-text-html-renderer' to nil." +`mm-text-html-renderer' to nil. + +This command creates temporary files to pass HTML contents including +images if any to the browser, and deletes them when exiting the group +\(if you want)." ;; Cf. `mm-w3m-safe-url-regexp' (interactive "P") (if arg diff -r 86c85c80cd84 -r 5a619d0a9158 lisp/gnus/message.el --- a/lisp/gnus/message.el Mon Mar 29 14:00:56 2010 +0000 +++ b/lisp/gnus/message.el Thu Apr 01 14:34:20 2010 +0000 @@ -1167,11 +1167,7 @@ :valid-regexp "^\\'" :error "All header lines must be newline terminated") -(defcustom message-default-headers - ;; Default to the value of `mail-default-headers' if available. - ;; Note: as for Emacs 21, XEmacs 21.4 and 21.5, it is unavailable - ;; unless sendmail.el is loaded. - (if (boundp 'mail-default-headers) mail-default-headers "") +(defcustom message-default-headers "" "*A string containing header lines to be inserted in outgoing messages. It is inserted before you edit the message, so you can edit or delete these lines." @@ -1184,16 +1180,18 @@ ;; Ease the transition from mail-mode to message-mode. See bugs#4431, 5555. (concat (if (and (boundp 'mail-default-reply-to) (stringp mail-default-reply-to)) - (format "Reply-to: %s\n" mail-default-reply-to) - "") + (format "Reply-to: %s\n" mail-default-reply-to)) (if (and (boundp 'mail-self-blind) mail-self-blind) - (format "BCC: %s\n" user-mail-address) - "") + (format "BCC: %s\n" user-mail-address)) (if (and (boundp 'mail-archive-file-name) (stringp mail-archive-file-name)) - (format "FCC: %s\n" mail-archive-file-name) - "")) + (format "FCC: %s\n" mail-archive-file-name)) + ;; Use the value of `mail-default-headers' if available. + ;; Note: as for Emacs 21, XEmacs 21.4 and 21.5, it is + ;; unavailable unless sendmail.el is loaded. + (if (boundp 'mail-default-headers) + mail-default-headers)) "*A string of header lines to be inserted in outgoing mails." :version "23.2" :group 'message-headers diff -r 86c85c80cd84 -r 5a619d0a9158 lisp/gnus/mm-decode.el --- a/lisp/gnus/mm-decode.el Mon Mar 29 14:00:56 2010 +0000 +++ b/lisp/gnus/mm-decode.el Thu Apr 01 14:34:20 2010 +0000 @@ -1258,11 +1258,11 @@ (mm-save-part-to-file handle file) file)))) -(defun mm-add-meta-html-tag (handle &optional charset) +(defun mm-add-meta-html-tag (handle &optional charset force-charset) "Add meta html tag to specify CHARSET of HANDLE in the current buffer. CHARSET defaults to the one HANDLE specifies. Existing meta tag that -specifies charset will not be modified. Return t if meta tag is added -or replaced." +specifies charset will not be modified unless FORCE-CHARSET is non-nil. +Return t if meta tag is added or replaced." (when (equal (mm-handle-media-type handle) "text/html") (when (or charset (setq charset (mail-content-type-get (mm-handle-type handle) @@ -1274,7 +1274,8 @@ (if (re-search-forward "\ <meta\\s-+http-equiv=[\"']?content-type[\"']?\\s-+content=[\"']\ text/\\(\\sw+\\)\\(?:\;\\s-*charset=\\(.+\\)\\)?[\"'][^>]*>" nil t) - (if (and (match-beginning 2) + (if (and (not force-charset) + (match-beginning 2) (string-match "\\`html\\'" (match-string 1))) ;; Don't modify existing meta tag. nil diff -r 86c85c80cd84 -r 5a619d0a9158 lisp/image.el --- a/lisp/image.el Mon Mar 29 14:00:56 2010 +0000 +++ b/lisp/image.el Thu Apr 01 14:34:20 2010 +0000 @@ -681,8 +681,9 @@ shall be displayed." (cond ((eq (plist-get (cdr image) :type) 'gif) - (let* ((extdata (image-extension-data image)) - (images (plist-get extdata 'count)) + (let* ((metadata (image-metadata image)) + (images (plist-get metadata 'count)) + (extdata (plist-get metadata 'extension-data)) (anim (plist-get extdata #xF9))) (and (integerp images) (> images 1) (stringp anim) (>= (length anim) 4) diff -r 86c85c80cd84 -r 5a619d0a9158 lisp/language/indian.el --- a/lisp/language/indian.el Mon Mar 29 14:00:56 2010 +0000 +++ b/lisp/language/indian.el Thu Apr 01 14:34:20 2010 +0000 @@ -140,28 +140,25 @@ (defconst devanagari-composable-pattern (let ((table - '(("V" . "[\u0904-\u0914\u0960-\u0961\u0972]") ; independent vowel - ("C" . "[\u0915-\u0939\u0958-\u095F\u097B-\u097C\u097E-\u097F]") ; consonant - ("R" . "\u0930") ; RA - ("n" . "\u093C") ; NUKTA - ("H" . "\u094D") ; HALANT - ("m" . "\u093F") ; vowel sign (pre) - ("u" . "[\u0945-\u0948\u0955]") ; vowel sign (above) - ("b" . "[\u0941-\u0944\u0962-\u0963]") ; vowel sign (below) - ("p" . "[\u093E\u0940\u0949-\u094C]") ; vowel sign (post) - ("A" . "[\u0900-\u0902\u0953-\u0954]") ; vowel modifier (above) - ("a" . "\u0903") ; vowel modifier (post) - ("S" . "\u0951") ; stress sign (above) - ("s" . "\u0952") ; stress sign (below) - ("N" . "\u200C") ; ZWNJ - ("J" . "\u200D") ; ZWJ - ("X" . "[\u0900-\u097F]")))) ; all coverage + '(("a" . "[\u0900-\u0902]") ; vowel modifier (above) + ("A" . "\u0903") ; vowel modifier (post) + ("V" . "[\u0904-\u0914\u0960-\u0961\u0972]") ; independent vowel + ("C" . "[\u0915-\u0939\u0958-\u095F\u0979-\u097F]") ; consonant + ("R" . "\u0930") ; RA + ("n" . "\u093C") ; NUKTA + ("v" . "[\u093E-\u094C\u094E\u0955\u0962-\u0963]") ; vowel sign + ("H" . "\u094D") ; HALANT + ("s" . "[\u0951-\u0952]") ; stress sign + ("t" . "[\u0953-\u0954]") ; accent + ("N" . "\u200C") ; ZWNJ + ("J" . "\u200D") ; ZWJ + ("X" . "[\u0900-\u097F]")))) ; all coverage (indian-compose-regexp (concat ;; syllables with an independent vowel, or - "\\(?:RH\\)?Vn?m?b?u?p?n?A?s?S?a?\\|" + "\\(?:RH\\)?Vn?\\(?:J?HR\\)?v*n?a?s?t?A?\\|" ;; consonant-based syllables, or - "\\(?:Cn?J?HJ?\\)*Cn?\\(?:H[NJ]?\\|m?b?u?p?n?A?s?S?a?\\)\\|" + "Cn?\\(?:J?HJ?Cn?\\)*\\(?:H[NJ]?\\|v*n?a?s?t?A?\\)\\|" ;; special consonant form, or "JHR\\|" ;; any other singleton characters @@ -169,43 +166,202 @@ table)) "Regexp matching a composable sequence of Devanagari characters.") +(defconst bengali-composable-pattern + (let ((table + '(("a" . "\u0981") ; SIGN CANDRABINDU + ("A" . "[\u0982-\u0983]") ; SIGN ANUSVARA .. VISARGA + ("V" . "[\u0985-\u0994\u09E0-\u09E1]") ; independent vowel + ("C" . "[\u0995-\u09B9\u09DC-\u09DF\u09F1]") ; consonant + ("B" . "[\u09AC\u09AF-\u09B0\u09F0]") ; BA, YA, RA + ("R" . "[\u09B0\u09F0]") ; RA + ("n" . "\u09BC") ; NUKTA + ("v" . "[\u09BE-\u09CC\u09D7\u09E2-\u09E3]") ; vowel sign + ("H" . "\u09CD") ; HALANT + ("T" . "\u09CE") ; KHANDA TA + ("N" . "\u200C") ; ZWNJ + ("J" . "\u200D") ; ZWJ + ("X" . "[\u0980-\u09FF]")))) ; all coverage + (indian-compose-regexp + (concat + ;; syllables with an independent vowel, or + "\\(?:RH\\)?Vn?\\(?:J?HB\\)?v*n?a?A?\\|" + ;; consonant-based syllables, or + "Cn?\\(?:J?HJ?Cn?\\)*\\(?:H[NJ]?\\|v*[NJ]?v?a?A?\\)\\|" + ;; another syllables with an independent vowel, or + "\\(?:RH\\)?T\\|" + ;; special consonant form, or + "JHB\\|" + ;; any other singleton characters + "X") + table)) + "Regexp matching a composable sequence of Bengali characters.") + +(defconst gurmukhi-composable-pattern + (let ((table + '(("a" . "[\u0A01-\u0A02]") ; SIGN ADAK BINDI .. BINDI + ("A" . "\u0A03]") ; SIGN VISARGA + ("V" . "[\u0A05-\u0A14]") ; independent vowel + ("C" . "[\u0A15-\u0A39\u0A59-\u0A5E]") ; consonant + ("Y" . "[\u0A2F\u0A30\u0A35\u0A39]") ; YA, RA, VA, HA + ("n" . "\u0A3C") ; NUKTA + ("v" . "[\u0A3E-\u0A4C]") ; vowel sign + ("H" . "\u0A4D") ; VIRAMA + ("a" . "\u0A70") ; TIPPI + ("N" . "\u200C") ; ZWNJ + ("J" . "\u200D") ; ZWJ + ("X" . "[\u0A00-\u0A7F]")))) ; all coverage + (indian-compose-regexp + (concat + ;; consonant-based syllables, or + "Cn?\\(?:J?HJ?Cn?\\)*\\(?:H[NJ]?\\|v*n?a?A?\\)\\|" + ;; syllables with an independent vowel, or + "Vn?\\(?:J?HY\\)?v*n?a?A?\\|" + ;; special consonant form, or + "JHY\\|" + ;; any other singleton characters + "X") + table)) + "Regexp matching a composable sequence of Gurmukhi characters.") + +(defconst gujarati-composable-pattern + (let ((table + '(("a" . "[\u0A81-\u0A82]") ; SIGN CANDRABINDU .. ANUSVARA + ("A" . "\u0A83]") ; SIGN VISARGA + ("V" . "[\u0A85-\u0A94\u0AE0-\u0AE1]") ; independent vowel + ("C" . "[\u0A95-\u0AB9]") ; consonant + ("R" . "\u0AB0") ; RA + ("n" . "\u0ABC") ; NUKTA + ("v" . "[\u0ABE-\u0ACC\u0AE2-\u0AE3]") ; vowel sign + ("H" . "\u0ACD") ; VIRAMA + ("N" . "\u200C") ; ZWNJ + ("J" . "\u200D") ; ZWJ + ("X" . "[\u0A80-\u0AFF]")))) ; all coverage + (indian-compose-regexp + (concat + ;; syllables with an independent vowel, or + "\\(?:RH\\)?Vn?\\(?:J?HR\\)?v*n?a?A?\\|" + ;; consonant-based syllables, or + "Cn?\\(?:J?HJ?Cn?\\)*\\(?:H[NJ]?|v*n?a?A?\\)\\|" + ;; special consonant form, or + "JHR\\|" + ;; any other singleton characters + "X") + table)) + "Regexp matching a composable sequence of Gujarati characters.") + +(defconst oriya-composable-pattern + (let ((table + '(("a" . "\u0B01") ; SIGN CANDRABINDU + ("A" . "[\u0B02-\u0B03]") ; SIGN ANUSVARA .. VISARGA + ("V" . "[\u0B05-\u0B14\u0B60-\u0B61]") ; independent vowel + ("C" . "[\u0B15-\u0B39\u0B5C-\u0B5D\u0B71]") ; consonant + ("B" . "[\u0B15-\u0B17\u0B1B-\u0B1D\u0B1F-\u0B21\u0B23-\u0B24\u0B27-\u0B30\u0B32-\u0B35\u0B38-\u0B39]") ; consonant with below form + ("n" . "\u0B3C") ; NUKTA + ("v" . "[\u0B3E-\u0B44\u0B56-\u0B57\u0B62-\u0B63]") ; vowel sign + ("H" . "\u0B4D") ; VIRAMA + ("N" . "\u200C") ; ZWNJ + ("J" . "\u200D") ; ZWJ + ("X" . "[\u0B00-\u0B7F]")))) ; all coverage + (indian-compose-regexp + (concat + ;; syllables with an independent vowel, or + "\\(?:RH\\)?Vn?\\(?:J?HB\\)?v*n?a?A?\\|" + ;; consonant-based syllables, or + "Cn?\\(?:J?HJ?Cn?\\)*\\(?:H[NJ]?|v*n?a?A?\\)\\|" + ;; special consonant form, or + "JHB\\|" + ;; any other singleton characters + "X") + table)) + "Regexp matching a composable sequence of Oriya characters.") + (defconst tamil-composable-pattern - (concat - "\\([à®…-à®”]\\)\\|" - "[ஂஃ]\\|" ;; vowel modifier considered independent - "\\(\\(?:\\(?:கà¯à®·\\)\\|[க-ஹ]\\)[à¯à®¾-ௌ]?\\)\\|" - "\\(à®·à¯à®°à¯€\\)") + (let ((table + '(("a" . "\u0B82") ; SIGN ANUSVARA + ("V" . "[\u0B85-\u0B94]") ; independent vowel + ("C" . "[\u0B95-\u0BB9]") ; consonant + ("v" . "[\u0BBE-\u0BC8\u0BD7]") ; vowel sign + ("H" . "\u0BCD") ; VIRAMA + ("N" . "\u200C") ; ZWNJ + ("J" . "\u200D") ; ZWJ + ("X" . "[\u0B80-\u0BFF]")))) ; all coverage + (indian-compose-regexp + (concat + ;; consonant-based syllables, or + "C\\(?:J?HJ?C\\)*\\(?:H[NJ]?|v*a?\\)\\|" + ;; syllables with an independent vowel, or + "Vv*a?\\|" + ;; any other singleton characters + "X") + table)) "Regexp matching a composable sequence of Tamil characters.") +(defconst telugu-composable-pattern + (let ((table + '(("a" . "[\u0C01-\u0C03]") ; SIGN CANDRABINDU .. VISARGA + ("V" . "[\u0C05-\u0C14\u0C60-\u0C61]") ; independent vowel + ("C" . "[\u0C15-\u0C39\u0C58-\u0C59]") ; consonant + ("v" . "[\u0C3E-\u0C4C\u0C55-\u0C56\u0C62-\u0C63]") ; vowel sign + ("H" . "\u0BCD") ; VIRAMA + ("N" . "\u200C") ; ZWNJ + ("J" . "\u200D") ; ZWJ + ("X" . "[\u0C00-\u0C7F]")))) ; all coverage + (indian-compose-regexp + (concat + ;; consonant-based syllables, or + "C\\(?:J?HJ?C\\)*\\(?:H[NJ]?|v*a?\\)\\|" + ;; syllables with an independent vowel, or + "V\\(?:J?HC\\)?v*a?\\|" + ;; special consonant form, or + "JHC\\|" + ;; any other singleton characters + "X") + table)) + "Regexp matching a composable sequence of Telugu characters.") + (defconst kannada-composable-pattern - (concat - "\\([ಂ-ಔೠಌ]\\)\\|[ಃ]" - "\\|\\(" - "\\(?:\\(?:[ಕ-ಹ]à³\\)?\\(?:[ಕ-ಹ]à³\\)?\\(?:[ಕ-ಹ]à³\\)?[ಕ-ಹ]à³\\)?" - "[ಕ-ಹ]\\(?:à³\\|[ಾ-à³à³•à³ƒ]?\\)?" - "\\)") + (let ((table + '(("A" . "[\u0C82-\u0C83]") ; SIGN ANUSVARA .. VISARGA + ("V" . "[\u0C85-\u0C94\u0CE0-\u0CE1]") ; independent vowel + ("C" . "[\u0C95-\u0CB9\u0CDE]") ; consonant + ("B" . "\u0CB0") ; RA + ("n" . "\u0CBC") ; NUKTA + ("v" . "[\u0CBE-\u0CCC\u0CD5-\u0CD6\u0CE2-\u0CE3]") ; vowel sign + ("H" . "\u0CCD") ; VIRAMA + ("N" . "\u200C") ; ZWNJ + ("J" . "\u200D") ; ZWJ + ("X" . "[\u0C80-\u0CFF]")))) ; all coverage + (indian-compose-regexp + (concat + ;; syllables with an independent vowel, or + "\\(?:RH\\)?Vn?\\(?:J?HC\\)?v?A?\\|" + ;; consonant-based syllables, or + "Cn?\\(?:J?HJ?Cn?\\)*\\(?:H[NJ]?|v*n?A?\\)\\|" + ;; special consonant form, or + "JHB\\|" + ;; any other singleton characters + "X") + table)) "Regexp matching a composable sequence of Kannada characters.") (defconst malayalam-composable-pattern (let ((table - '(("V" . "[\u0D05-\u0D14\u0D60-\u0D61]") ; independent vowel + '(("A" . "[\u0D02-\u0D03]") ; SIGN ANUSVARA .. VISARGA + ("V" . "[\u0D05-\u0D14\u0D60-\u0D61]") ; independent vowel ("C" . "[\u0D15-\u0D39]") ; consonant - ("m" . "[\u0D46-\u0D48\u0D4A-\u0D4C]") ; prebase matra - ("p" . "[\u0D3E-\u0D44\u0D57]") ; postbase matra - ("b" . "[\u0D62-\u0D63]") ; belowbase matra - ("a" . "[\u0D02-\u0D03]") ; abovebase sign - ("H" . "\u0D4D") ; virama sign + ("Y" . "[\u0D2F-\u0D30\u0D32\u0D35]") ; YA, RA, LA, VA + ("v" . "[\u0D3E-\u0D48\u0D57\u0D62-\u0D63]") ; postbase matra ("N" . "\u200C") ; ZWNJ ("J" . "\u200D") ; ZWJ ("X" . "[\u0D00-\u0D7F]")))) ; all coverage (indian-compose-regexp (concat + ;; consonant-based syllables, or + "\\(?:CJ?HJ?C\\)*\\(?:H[NJ]?\\|v?A?\\)\\|" ;; syllables with an independent vowel, or - "V\\(?:J?HC\\)?m?b?p?a?\\|" - ;; consonant-based syllables, or - "\\(?:CJ?HJ?\\)\\{0,4\\}C\\(?:H[NJ]?\\|m?b?p?a?\\)\\|" + "V\\(?:J?HY\\)?v*?A?\\|" ;; special consonant form, or - "JHC\\|" + "JHY\\|" ;; any other singleton characters "X") table)) @@ -213,13 +369,13 @@ (let ((script-regexp-alist `((devanagari . ,devanagari-composable-pattern) - (bengali . "[\x980-\x9FF\x200C\x200D]+") - (gurmukhi . "[\xA00-\xA7F\x200C\x200D]+") - (gujarati . "[\xA80-\xAFF\x200C\x200D]+") - (oriya . "[\xB00-\xB7F\x200C\x200D]+") - (tamil . "[\xB80-\xBFF\x200C\x200D]+") - (telugu . "[\xC00-\xC7F\x200C\x200D]+") - (kannada . "[\xC80-\xCFF\x200C\x200D]+") + (bengali . ,bengali-composable-pattern) + (gurmukhi . ,gurmukhi-composable-pattern) + (gujarati . ,gujarati-composable-pattern) + (oriya . ,oriya-composable-pattern) + (tamil . ,tamil-composable-pattern) + (telugu . ,telugu-composable-pattern) + (kannada . ,kannada-composable-pattern) (malayalam . ,malayalam-composable-pattern)))) (map-char-table #'(lambda (key val) diff -r 86c85c80cd84 -r 5a619d0a9158 lisp/language/sinhala.el --- a/lisp/language/sinhala.el Mon Mar 29 14:00:56 2010 +0000 +++ b/lisp/language/sinhala.el Thu Apr 01 14:34:20 2010 +0000 @@ -33,7 +33,17 @@ (set-char-table-range composition-function-table '(#xD80 . #xDFF) - (list (vector "[\xD80-\xDFF\x200C\x200D]+" 0 'font-shape-gstring))) + (list (vector + ;; C:consonant, H:HALANT, J:ZWJ, v:vowel sign, + ;; V:independent vowel, a:ANUSVARA .. VISARGA + (concat + ;; C(HJC)*v*H?a?, or + "[\u0D9A-\u0DC6]\\(?:\u0DCA\u200D[\u0D9A-\u0DC6]\\)*[\u0DCF-\u0DDF\u0DF2-\u0DF3]*\u0DCA?[\u0D82-\u0D83]?\\|" + ;; Va?, or + "[\u0D85-\u0D96][\u0D82-\u0D83]?\\|" + ;; any other singleton characters + "[\u0D80-\u0DFF]") + 0 'font-shape-gstring))) ;; arch-tag: 87b9ad3b-5090-422f-b942-eb85b9d52e7c ;; sinhala.el ends here diff -r 86c85c80cd84 -r 5a619d0a9158 lisp/mail/sendmail.el --- a/lisp/mail/sendmail.el Mon Mar 29 14:00:56 2010 +0000 +++ b/lisp/mail/sendmail.el Thu Apr 01 14:34:20 2010 +0000 @@ -417,9 +417,11 @@ ;;;###autoload (defcustom mail-default-directory (purecopy "~/") - "Directory for mail buffers. -Value of `default-directory' for mail buffers. -This directory is used for auto-save files of mail buffers." + "Value of `default-directory' for Mail mode buffers. +This directory is used for auto-save files of Mail mode buffers. + +Note that Message mode does not use this variable; it auto-saves +in `message-auto-save-directory'." :type '(directory :tag "Directory") :group 'sendmail :version "22.1") diff -r 86c85c80cd84 -r 5a619d0a9158 lisp/progmodes/js.el --- a/lisp/progmodes/js.el Mon Mar 29 14:00:56 2010 +0000 +++ b/lisp/progmodes/js.el Thu Apr 01 14:34:20 2010 +0000 @@ -436,6 +436,13 @@ :type 'integer :group 'js) +(defcustom js-auto-indent-flag t + "Whether to automatically indent when typing punctuation characters. +If non-nil, the characters {}();,: also indent the current line +in Javascript mode." + :type 'boolean + :group 'js) + (defcustom js-flat-functions nil "Treat nested functions as top-level functions in `js-mode'. This applies to function movement, marking, and so on." @@ -483,6 +490,9 @@ (defvar js-mode-map (let ((keymap (make-sparse-keymap))) + (mapc (lambda (key) + (define-key keymap key #'js-insert-and-indent)) + '("{" "}" "(" ")" ":" ";" ",")) (define-key keymap [(control ?c) (meta ?:)] #'js-eval) (define-key keymap [(control ?c) (control ?j)] #'js-set-js-context) (define-key keymap [(control meta ?x)] #'js-eval-defun) @@ -498,6 +508,21 @@ keymap) "Keymap for `js-mode'.") +(defun js-insert-and-indent (key) + "Run the command bound to KEY, and indent if necessary. +Indentation does not take place if point is in a string or +comment." + (interactive (list (this-command-keys))) + (call-interactively (lookup-key (current-global-map) key)) + (let ((syntax (save-restriction (widen) (syntax-ppss)))) + (when (or (and (not (nth 8 syntax)) + js-auto-indent-flag) + (and (nth 4 syntax) + (eq (current-column) + (1+ (current-indentation))))) + (indent-according-to-mode)))) + + ;;; Syntax table and parsing (defvar js-mode-syntax-table diff -r 86c85c80cd84 -r 5a619d0a9158 lisp/replace.el --- a/lisp/replace.el Mon Mar 29 14:00:56 2010 +0000 +++ b/lisp/replace.el Thu Apr 01 14:34:20 2010 +0000 @@ -1005,21 +1005,6 @@ :group 'matching :version "22.1") -(defun occur-accumulate-lines (count &optional keep-props) - (save-excursion - (let ((forwardp (> count 0)) - result beg end) - (while (not (or (zerop count) - (if forwardp - (eobp) - (bobp)))) - (setq count (+ count (if forwardp -1 1))) - (setq beg (line-beginning-position) - end (line-end-position)) - (push (occur-engine-line beg end keep-props) result) - (forward-line (if forwardp 1 -1))) - (nreverse result)))) - (defun occur-read-primary-args () (list (read-regexp "List lines matching regexp" (car regexp-history)) @@ -1028,7 +1013,7 @@ (defun occur-rename-buffer (&optional unique-p interactive-p) "Rename the current *Occur* buffer to *Occur: original-buffer-name*. -Here `original-buffer-name' is the buffer name were Occur was originally run. +Here `original-buffer-name' is the buffer name where Occur was originally run. When given the prefix argument, or called non-interactively, the renaming will not clobber the existing buffer(s) of that name, but use `generate-new-buffer-name' instead. You can add this to `occur-hook' @@ -1173,12 +1158,6 @@ (set-buffer-modified-p nil) (run-hooks 'occur-hook))))))) -(defun occur-engine-add-prefix (lines) - (mapcar - #'(lambda (line) - (concat " :" line "\n")) - lines)) - (defun occur-engine (regexp buffers out-buf nlines case-fold-search title-face prefix-face match-face keep-props) (with-current-buffer out-buf @@ -1189,12 +1168,15 @@ (when (buffer-live-p buf) (let ((matches 0) ;; count of matched lines (lines 1) ;; line count + (prev-after-lines nil) ;; context lines of prev match + (prev-lines nil) ;; line number of prev match endpt (matchbeg 0) (origpt nil) (begpt nil) (endpt nil) (marker nil) (curstring "") + (ret nil) (inhibit-field-text-motion t) (headerpt (with-current-buffer out-buf (point)))) (with-current-buffer buf @@ -1271,14 +1253,17 @@ ;; The simple display style out-line ;; The complex multi-line display style. - (occur-context-lines out-line nlines keep-props) - ))) + (setq ret (occur-context-lines + out-line nlines keep-props begpt endpt + lines prev-lines prev-after-lines)) + ;; Set first elem of the returned list to `data', + ;; and the second elem to `prev-after-lines'. + (setq prev-after-lines (nth 1 ret)) + (nth 0 ret)))) ;; Actually insert the match display data (with-current-buffer out-buf (let ((beg (point)) - (end (progn (insert data) (point)))) - (unless (= nlines 0) - (insert "-------\n"))))) + (end (progn (insert data) (point))))))) (goto-char endpt)) (if endpt (progn @@ -1289,7 +1274,13 @@ (if (and (bolp) (eolp)) 1 0))) ;; On to the next match... (forward-line 1)) - (goto-char (point-max)))))) + (goto-char (point-max))) + (setq prev-lines (1- lines))) + ;; Flush remaining context after-lines. + (when prev-after-lines + (with-current-buffer out-buf + (insert (apply #'concat (occur-engine-add-prefix + prev-after-lines))))))) (when (not (zerop matches)) ;; is the count zero? (setq globalcount (+ globalcount matches)) (with-current-buffer out-buf @@ -1342,21 +1333,86 @@ str) (buffer-substring-no-properties beg end))) +(defun occur-engine-add-prefix (lines) + (mapcar + #'(lambda (line) + (concat " :" line "\n")) + lines)) + +(defun occur-accumulate-lines (count &optional keep-props pt) + (save-excursion + (when pt + (goto-char pt)) + (let ((forwardp (> count 0)) + result beg end moved) + (while (not (or (zerop count) + (if forwardp + (eobp) + (and (bobp) (not moved))))) + (setq count (+ count (if forwardp -1 1))) + (setq beg (line-beginning-position) + end (line-end-position)) + (push (occur-engine-line beg end keep-props) result) + (setq moved (= 0 (forward-line (if forwardp 1 -1))))) + (nreverse result)))) + ;; Generate context display for occur. ;; OUT-LINE is the line where the match is. ;; NLINES and KEEP-PROPS are args to occur-engine. +;; LINES is line count of the current match, +;; PREV-LINES is line count of the previous match, +;; PREV-AFTER-LINES is a list of after-context lines of the previous match. ;; Generate a list of lines, add prefixes to all but OUT-LINE, ;; then concatenate them all together. -(defun occur-context-lines (out-line nlines keep-props) - (apply #'concat - (nconc - (occur-engine-add-prefix - (nreverse (cdr (occur-accumulate-lines - (- (1+ (abs nlines))) keep-props)))) - (list out-line) - (if (> nlines 0) - (occur-engine-add-prefix - (cdr (occur-accumulate-lines (1+ nlines) keep-props))))))) +(defun occur-context-lines (out-line nlines keep-props begpt endpt + lines prev-lines prev-after-lines) + ;; Find after- and before-context lines of the current match. + (let ((before-lines + (nreverse (cdr (occur-accumulate-lines + (- (1+ (abs nlines))) keep-props begpt)))) + (after-lines + (cdr (occur-accumulate-lines + (1+ nlines) keep-props endpt))) + separator) + + ;; Combine after-lines of the previous match + ;; with before-lines of the current match. + + (when prev-after-lines + ;; Don't overlap prev after-lines with current before-lines. + (if (>= (+ prev-lines (length prev-after-lines)) + (- lines (length before-lines))) + (setq prev-after-lines + (butlast prev-after-lines + (- (length prev-after-lines) + (- lines prev-lines (length before-lines) 1)))) + ;; Separate non-overlapping context lines with a dashed line. + (setq separator "-------\n"))) + + (when prev-lines + ;; Don't overlap current before-lines with previous match line. + (if (<= (- lines (length before-lines)) + prev-lines) + (setq before-lines + (nthcdr (- (length before-lines) + (- lines prev-lines 1)) + before-lines)) + ;; Separate non-overlapping before-context lines. + (unless (> nlines 0) + (setq separator "-------\n")))) + + (list + ;; Return a list where the first element is the output line. + (apply #'concat + (append + (and prev-after-lines + (occur-engine-add-prefix prev-after-lines)) + (and separator (list separator)) + (occur-engine-add-prefix before-lines) + (list out-line))) + ;; And the second element is the list of context after-lines. + (if (> nlines 0) after-lines)))) + ;; It would be nice to use \\[...], but there is no reasonable way ;; to make that display both SPC and Y. diff -r 86c85c80cd84 -r 5a619d0a9158 lisp/simple.el --- a/lisp/simple.el Mon Mar 29 14:00:56 2010 +0000 +++ b/lisp/simple.el Thu Apr 01 14:34:20 2010 +0000 @@ -3468,17 +3468,18 @@ (interactive (list (read-buffer "Append to buffer: " (other-buffer (current-buffer) t)) (region-beginning) (region-end))) - (let ((oldbuf (current-buffer))) - (let* ((append-to (get-buffer-create buffer)) - (windows (get-buffer-window-list append-to t t)) - point) + (let* ((oldbuf (current-buffer)) + (append-to (get-buffer-create buffer)) + (windows (get-buffer-window-list append-to t t)) + point) + (save-excursion (with-current-buffer append-to - (setq point (point)) - (barf-if-buffer-read-only) - (insert-buffer-substring oldbuf start end) - (dolist (window windows) - (when (= (window-point window) point) - (set-window-point window (point)))))))) + (setq point (point)) + (barf-if-buffer-read-only) + (insert-buffer-substring oldbuf start end) + (dolist (window windows) + (when (= (window-point window) point) + (set-window-point window (point)))))))) (defun prepend-to-buffer (buffer start end) "Prepend to specified buffer the text of the region. @@ -4002,9 +4003,10 @@ (insert (if use-hard-newlines hard-newline "\n"))) (line-move arg nil nil try-vscroll)) (if (called-interactively-p 'interactive) - (condition-case nil + (condition-case err (line-move arg nil nil try-vscroll) - ((beginning-of-buffer end-of-buffer) (ding))) + ((beginning-of-buffer end-of-buffer) + (signal (car err) (cdr err)))) (line-move arg nil nil try-vscroll))) nil) @@ -4032,9 +4034,10 @@ (interactive "^p\np") (or arg (setq arg 1)) (if (called-interactively-p 'interactive) - (condition-case nil + (condition-case err (line-move (- arg) nil nil try-vscroll) - ((beginning-of-buffer end-of-buffer) (ding))) + ((beginning-of-buffer end-of-buffer) + (signal (car err) (cdr err)))) (line-move (- arg) nil nil try-vscroll)) nil) @@ -5489,12 +5492,12 @@ or go back to just one window (by deleting all but the selected window)." (interactive) (cond ((eq last-command 'mode-exited) nil) + ((region-active-p) + (deactivate-mark)) ((> (minibuffer-depth) 0) (abort-recursive-edit)) (current-prefix-arg nil) - ((region-active-p) - (deactivate-mark)) ((> (recursion-depth) 0) (exit-recursive-edit)) (buffer-quit-function diff -r 86c85c80cd84 -r 5a619d0a9158 lisp/subr.el --- a/lisp/subr.el Mon Mar 29 14:00:56 2010 +0000 +++ b/lisp/subr.el Thu Apr 01 14:34:20 2010 +0000 @@ -3421,51 +3421,59 @@ ;; digits of precision, it doesn't really matter here. On the other ;; hand, it greatly simplifies the code. -(defsubst progress-reporter-update (reporter value) +(defsubst progress-reporter-update (reporter &optional value) "Report progress of an operation in the echo area. -However, if the change since last echo area update is too small -or not enough time has passed, then do nothing (see -`make-progress-reporter' for details). - -First parameter, REPORTER, should be the result of a call to -`make-progress-reporter'. Second, VALUE, determines the actual -progress of operation; it must be between MIN-VALUE and MAX-VALUE -as passed to `make-progress-reporter'. - -This function is very inexpensive, you may not bother how often -you call it." - (when (>= value (car reporter)) +REPORTER should be the result of a call to `make-progress-reporter'. + +If REPORTER is a numerical progress reporter---i.e. if it was + made using non-nil MIN-VALUE and MAX-VALUE arguments to + `make-progress-reporter'---then VALUE should be a number between + MIN-VALUE and MAX-VALUE. + +If REPORTER is a non-numerical reporter, VALUE should be nil. + +This function is relatively inexpensive. If the change since +last update is too small or insufficient time has passed, it does +nothing." + (when (or (not (numberp value)) ; For pulsing reporter + (>= value (car reporter))) ; For numerical reporter (progress-reporter-do-update reporter value))) -(defun make-progress-reporter (message min-value max-value - &optional current-value - min-change min-time) - "Return progress reporter object to be used with `progress-reporter-update'. - -MESSAGE is shown in the echo area. When at least 1% of operation -is complete, the exact percentage will be appended to the -MESSAGE. When you call `progress-reporter-done', word \"done\" -is printed after the MESSAGE. You can change MESSAGE of an -existing progress reporter with `progress-reporter-force-update'. - -MIN-VALUE and MAX-VALUE designate starting (0% complete) and -final (100% complete) states of operation. The latter should be -larger; if this is not the case, then simply negate all values. -Optional CURRENT-VALUE specifies the progress by the moment you -call this function. You should omit it or set it to nil in most -cases since it defaults to MIN-VALUE. - -Optional MIN-CHANGE determines the minimal change in percents to -report (default is 1%.) Optional MIN-TIME specifies the minimal -time before echo area updates (default is 0.2 seconds.) If -`float-time' function is not present, then time is not tracked -at all. If OS is not capable of measuring fractions of seconds, -then this parameter is effectively rounded up." - +(defun make-progress-reporter (message &optional min-value max-value + current-value min-change min-time) + "Return progress reporter object for use with `progress-reporter-update'. + +MESSAGE is shown in the echo area, with a status indicator +appended to the end. When you call `progress-reporter-done', the +word \"done\" is printed after the MESSAGE. You can change the +MESSAGE of an existing progress reporter by calling +`progress-reporter-force-update'. + +MIN-VALUE and MAX-VALUE, if non-nil, are starting (0% complete) +and final (100% complete) states of operation; the latter should +be larger. In this case, the status message shows the percentage +progress. + +If MIN-VALUE and/or MAX-VALUE is omitted or nil, the status +message shows a \"spinning\", non-numeric indicator. + +Optional CURRENT-VALUE is the initial progress; the default is +MIN-VALUE. +Optional MIN-CHANGE is the minimal change in percents to report; +the default is 1%. +CURRENT-VALUE and MIN-CHANGE do not have any effect if MIN-VALUE +and/or MAX-VALUE are nil. + +Optional MIN-TIME specifies the minimum interval time between +echo area updates (default is 0.2 seconds.) If the function +`float-time' is not present, time is not tracked at all. If the +OS is not capable of measuring fractions of seconds, this +parameter is effectively rounded up." (unless min-time (setq min-time 0.2)) (let ((reporter - (cons min-value ;; Force a call to `message' now + ;; Force a call to `message' now + (cons (or min-value 0) (vector (if (and (fboundp 'float-time) (>= min-time 0.02)) (float-time) nil) @@ -3477,12 +3485,11 @@ (progress-reporter-update reporter (or current-value min-value)) reporter)) -(defun progress-reporter-force-update (reporter value &optional new-message) +(defun progress-reporter-force-update (reporter &optional value new-message) "Report progress of an operation in the echo area unconditionally. -First two parameters are the same as for -`progress-reporter-update'. Optional NEW-MESSAGE allows you to -change the displayed message." +The first two arguments are the same as in `progress-reporter-update'. +NEW-MESSAGE, if non-nil, sets a new message for the reporter." (let ((parameters (cdr reporter))) (when new-message (aset parameters 3 new-message)) @@ -3490,15 +3497,15 @@ (aset parameters 0 (float-time))) (progress-reporter-do-update reporter value))) +(defvar progress-reporter--pulse-characters ["-" "\\" "|" "/"] + "Characters to use for pulsing progress reporters.") + (defun progress-reporter-do-update (reporter value) (let* ((parameters (cdr reporter)) + (update-time (aref parameters 0)) (min-value (aref parameters 1)) (max-value (aref parameters 2)) - (one-percent (/ (- max-value min-value) 100.0)) - (percentage (if (= max-value min-value) - 0 - (truncate (/ (- value min-value) one-percent)))) - (update-time (aref parameters 0)) + (text (aref parameters 3)) (current-time (float-time)) (enough-time-passed ;; See if enough time has passed since the last update. @@ -3506,26 +3513,41 @@ (when (>= current-time update-time) ;; Calculate time for the next update (aset parameters 0 (+ update-time (aref parameters 5))))))) - ;; - ;; Calculate NEXT-UPDATE-VALUE. If we are not going to print - ;; message this time because not enough time has passed, then use - ;; 1 instead of MIN-CHANGE. This makes delays between echo area - ;; updates closer to MIN-TIME. - (setcar reporter - (min (+ min-value (* (+ percentage - (if enough-time-passed - (aref parameters 4) ;; MIN-CHANGE - 1)) - one-percent)) - max-value)) - (when (integerp value) - (setcar reporter (ceiling (car reporter)))) - ;; - ;; Only print message if enough time has passed - (when enough-time-passed - (if (> percentage 0) - (message "%s%d%%" (aref parameters 3) percentage) - (message "%s" (aref parameters 3)))))) + (cond ((and min-value max-value) + ;; Numerical indicator + (let* ((one-percent (/ (- max-value min-value) 100.0)) + (percentage (if (= max-value min-value) + 0 + (truncate (/ (- value min-value) + one-percent))))) + ;; Calculate NEXT-UPDATE-VALUE. If we are not printing + ;; message because not enough time has passed, use 1 + ;; instead of MIN-CHANGE. This makes delays between echo + ;; area updates closer to MIN-TIME. + (setcar reporter + (min (+ min-value (* (+ percentage + (if enough-time-passed + ;; MIN-CHANGE + (aref parameters 4) + 1)) + one-percent)) + max-value)) + (when (integerp value) + (setcar reporter (ceiling (car reporter)))) + ;; Only print message if enough time has passed + (when enough-time-passed + (if (> percentage 0) + (message "%s%d%%" text percentage) + (message "%s" text))))) + ;; Pulsing indicator + (enough-time-passed + (let ((index (mod (1+ (car reporter)) 4)) + (message-log-max nil)) + (setcar reporter index) + (message "%s %s" + text + (aref progress-reporter--pulse-characters + index))))))) (defun progress-reporter-done (reporter) "Print reporter's message followed by word \"done\" in echo area." @@ -3573,11 +3595,11 @@ ("^[-_+ ]cvs$" . -3) ; treat "1.2.3-CVS" as alpha release ("^[-_+ ]?b\\(eta\\)?$" . -2) ("^[-_+ ]?\\(pre\\|rc\\)$" . -1)) - "*Specify association between non-numeric version part and a priority. + "*Specify association between non-numeric version and its priority. This association is used to handle version string like \"1.0pre2\", \"0.9alpha1\", etc. It's used by `version-to-list' (which see) to convert the -non-numeric part to an integer. For example: +non-numeric part of a version string to an integer. For example: String Version Integer List Version \"1.0pre2\" (1 0 -1 2) @@ -3595,15 +3617,15 @@ Where: REGEXP regexp used to match non-numeric part of a version string. - It should begin with a `^' anchor and end with a `$' to + It should begin with the `^' anchor and end with a `$' to prevent false hits. Letter-case is ignored while matching REGEXP. -PRIORITY negative integer which indicate the non-numeric priority.") +PRIORITY a negative integer specifying non-numeric priority of REGEXP.") (defun version-to-list (ver) - "Convert version string VER into an integer list. + "Convert version string VER into a list of integers. The version syntax is given by the following EBNF: @@ -3617,17 +3639,17 @@ The NUMBER part is optional if SEPARATOR is a match for an element in `version-regexp-alist'. -As an example of valid version syntax: +Examples of valid version syntax: 1.0pre2 1.0.7.5 22.8beta3 0.9alpha1 6.9.30Beta -As an example of invalid version syntax: +Examples of invalid version syntax: 1.0prepre2 1.0..7.5 22.8X3 alpha3.2 .5 -As an example of version convertion: - - String Version Integer List Version +Examples of version conversion: + + Version String Version as a List of Integers \"1.0.7.5\" (1 0 7 5) \"1.0pre2\" (1 0 -1 2) \"1.0PRE2\" (1 0 -1 2) @@ -3673,12 +3695,12 @@ (defun version-list-< (l1 l2) - "Return t if integer list L1 is lesser than L2. - -Note that integer list (1) is equal to (1 0), (1 0 0), (1 0 0 0), -etc. That is, the trailing zeroes are irrelevant. Also, integer -list (1) is greater than (1 -1) which is greater than (1 -2) -which is greater than (1 -3)." + "Return t if L1, a list specification of a version, is lower than L2. + +Note that a version specified by the list (1) is equal to (1 0), +\(1 0 0), (1 0 0 0), etc. That is, the trailing zeros are insignificant. +Also, a version given by the list (1) is higher than (1 -1), which in +turn is higher than (1 -2), which is higher than (1 -3)." (while (and l1 l2 (= (car l1) (car l2))) (setq l1 (cdr l1) l2 (cdr l2))) @@ -3694,12 +3716,12 @@ (defun version-list-= (l1 l2) - "Return t if integer list L1 is equal to L2. - -Note that integer list (1) is equal to (1 0), (1 0 0), (1 0 0 0), -etc. That is, the trailing zeroes are irrelevant. Also, integer -list (1) is greater than (1 -1) which is greater than (1 -2) -which is greater than (1 -3)." + "Return t if L1, a list specification of a version, is equal to L2. + +Note that a version specified by the list (1) is equal to (1 0), +\(1 0 0), (1 0 0 0), etc. That is, the trailing zeros are insignificant. +Also, a version given by the list (1) is higher than (1 -1), which in +turn is higher than (1 -2), which is higher than (1 -3)." (while (and l1 l2 (= (car l1) (car l2))) (setq l1 (cdr l1) l2 (cdr l2))) @@ -3715,7 +3737,7 @@ (defun version-list-<= (l1 l2) - "Return t if integer list L1 is lesser than or equal to L2. + "Return t if L1, a list specification of a version, is lower or equal to L2. Note that integer list (1) is equal to (1 0), (1 0 0), (1 0 0 0), etc. That is, the trailing zeroes are irrelevant. Also, integer @@ -3735,9 +3757,9 @@ (t (<= 0 (version-list-not-zero l2))))) (defun version-list-not-zero (lst) - "Return the first non-zero element of integer list LST. - -If all LST elements are zeroes or LST is nil, return zero." + "Return the first non-zero element of LST, which is a list of integers. + +If all LST elements are zeros or LST is nil, return zero." (while (and lst (zerop (car lst))) (setq lst (cdr lst))) (if lst @@ -3747,31 +3769,31 @@ (defun version< (v1 v2) - "Return t if version V1 is lesser than V2. + "Return t if version V1 is lower (older) than V2. Note that version string \"1\" is equal to \"1.0\", \"1.0.0\", \"1.0.0.0\", -etc. That is, the trailing \".0\"s are irrelevant. Also, version string \"1\" -is greater than \"1pre\" which is greater than \"1beta\" which is greater than -\"1alpha\"." +etc. That is, the trailing \".0\"s are insignificant. Also, version +string \"1\" is higher (newer) than \"1pre\", which is higher than \"1beta\", +which is higher than \"1alpha\"." (version-list-< (version-to-list v1) (version-to-list v2))) (defun version<= (v1 v2) - "Return t if version V1 is lesser than or equal to V2. + "Return t if version V1 is lower (older) than or equal to V2. Note that version string \"1\" is equal to \"1.0\", \"1.0.0\", \"1.0.0.0\", -etc. That is, the trailing \".0\"s are irrelevant. Also, version string \"1\" -is greater than \"1pre\" which is greater than \"1beta\" which is greater than -\"1alpha\"." +etc. That is, the trailing \".0\"s are insignificant.. Also, version +string \"1\" is higher (newer) than \"1pre\", which is higher than \"1beta\", +which is higher than \"1alpha\"." (version-list-<= (version-to-list v1) (version-to-list v2))) (defun version= (v1 v2) "Return t if version V1 is equal to V2. Note that version string \"1\" is equal to \"1.0\", \"1.0.0\", \"1.0.0.0\", -etc. That is, the trailing \".0\"s are irrelevant. Also, version string \"1\" -is greater than \"1pre\" which is greater than \"1beta\" which is greater than -\"1alpha\"." +etc. That is, the trailing \".0\"s are insignificant.. Also, version +string \"1\" is higher (newer) than \"1pre\", which is higher than \"1beta\", +which is higher than \"1alpha\"." (version-list-= (version-to-list v1) (version-to-list v2))) diff -r 86c85c80cd84 -r 5a619d0a9158 lisp/textmodes/artist.el --- a/lisp/textmodes/artist.el Mon Mar 29 14:00:56 2010 +0000 +++ b/lisp/textmodes/artist.el Thu Apr 01 14:34:20 2010 +0000 @@ -1319,7 +1319,7 @@ Variables - This is a brief overview of the different varaibles. For more info, + This is a brief overview of the different variables. For more info, see the documentation for the variables (type \\[describe-variable] <variable> RET). artist-rubber-banding Interactively do rubber-banding or not diff -r 86c85c80cd84 -r 5a619d0a9158 lisp/tmm.el --- a/lisp/tmm.el Mon Mar 29 14:00:56 2010 +0000 +++ b/lisp/tmm.el Thu Apr 01 14:34:20 2010 +0000 @@ -170,7 +170,11 @@ (mapc (lambda (elt) (if (stringp elt) (setq gl-str elt) - (and (listp elt) (tmm-get-keymap elt not-menu)))) + (cond + ((listp elt) (tmm-get-keymap elt not-menu)) + ((vectorp elt) + (dotimes (i (length elt)) + (tmm-get-keymap (cons i (aref elt i)) not-menu)))))) menu) ;; Choose an element of tmm-km-list; put it in choice. (if (and not-menu (= 1 (length tmm-km-list))) diff -r 86c85c80cd84 -r 5a619d0a9158 lisp/vc.el --- a/lisp/vc.el Mon Mar 29 14:00:56 2010 +0000 +++ b/lisp/vc.el Thu Apr 01 14:34:20 2010 +0000 @@ -1618,9 +1618,10 @@ ;;;###autoload (defun vc-root-diff (historic &optional not-urgent) - "Display diffs between file revisions. -Normally this compares the currently selected fileset with their -working revisions. With a prefix argument HISTORIC, it reads two revision + "Display diffs between VC-controlled whole tree revisions. +Normally, this compares the tree corresponding to the current +fileset with the working revision. +With a prefix argument HISTORIC, prompt for two revision designators specifying which revisions to compare. The optional argument NOT-URGENT non-nil means it is ok to say no to @@ -1941,7 +1942,12 @@ ;;;###autoload (defun vc-print-log (&optional working-revision limit) "List the change log of the current fileset in a window. -If WORKING-REVISION is non-nil, leave the point at that revision." +If WORKING-REVISION is non-nil, leave point at that revision. +If LIMIT is non-nil, it should be a number specifying the maximum +number of revisions to show; the default is `vc-log-show-limit'. + +When called interactively with a prefix argument, prompt for +WORKING-REVISION and LIMIT." (interactive (cond (current-prefix-arg @@ -1965,7 +1971,10 @@ ;;;###autoload (defun vc-print-root-log (&optional limit) - "List the change log of for the current VC controlled tree in a window." + "List the change log for the current VC controlled tree in a window. +If LIMIT is non-nil, it should be a number specifying the maximum +number of revisions to show; the default is `vc-log-show-limit'. +When called interactively with a prefix argument, prompt for LIMIT." (interactive (cond (current-prefix-arg diff -r 86c85c80cd84 -r 5a619d0a9158 src/.gdbinit --- a/src/.gdbinit Mon Mar 29 14:00:56 2010 +0000 +++ b/src/.gdbinit Thu Apr 01 14:34:20 2010 +0000 @@ -271,6 +271,9 @@ end end printf "\n" + if ($it->bidi_p) + printf "BIDI: base_stop=%d prev_stop=%d level=%d\n", $it->base_level_stop, $it->prev_stop, $it->bidi_it.resolved_level + end if ($it->region_beg_charpos >= 0) printf "reg=%d-%d ", $it->region_beg_charpos, $it->region_end_charpos end @@ -447,6 +450,36 @@ Pretty print window structure w. end +define pbiditype + if ($arg0 == 0) + printf "UNDEF" + end + if ($arg0 == 1) + printf "L" + end + if ($arg0 == 2) + printf "R" + end + if ($arg0 == 3) + printf "EN" + end + if ($arg0 == 4) + printf "AN" + end + if ($arg0 == 5) + printf "BN" + end + if ($arg0 == 6) + printf "B" + end + if ($arg0 < 0 || $arg0 > 6) + printf "%d??", $arg0 + end +end +document pbiditype +Print textual description of bidi type given as first argument. +end + define pgx set $g = $arg0 # CHAR_GLYPH @@ -475,6 +508,11 @@ else printf " pos=%d", $g->charpos end + # For characters, print their resolved level and bidi type + if ($g->type == 0) + printf " blev=%d,btyp=", $g->resolved_level + pbiditype $g->bidi_type + end printf " w=%d a+d=%d+%d", $g->pixel_width, $g->ascent, $g->descent # If not DEFAULT_FACE_ID if ($g->face_id != 0) @@ -575,6 +613,28 @@ Pretty print all glyphs in it->glyph_row. end +define prowlims + printf "start=%d,end=%d,reversed=%d,cont=%d,at_zv=%d\n", $arg0->start.pos.charpos, $arg0->end.pos.charpos, $arg0->reversed_p, $arg0->continued_p, $arg0->ends_at_zv_p +end +document prowlims +Print important attributes of a glyph_row structure. +Takes one argument, a pointer to a glyph_row structure. +end + +define pmtxrows + set $mtx = $arg0 + set $gl = $mtx->rows + set $glend = $mtx->rows + $mtx->nrows + while ($gl < $glend) + prowlims $gl + set $gl = $gl + 1 + end +end +document pmtxrows +Print data about glyph rows in a glyph matrix. +Takes one argument, a pointer to a glyph_matrix structure. +end + define xtype xgettype $ output $type diff -r 86c85c80cd84 -r 5a619d0a9158 src/ChangeLog --- a/src/ChangeLog Mon Mar 29 14:00:56 2010 +0000 +++ b/src/ChangeLog Thu Apr 01 14:34:20 2010 +0000 @@ -1,3 +1,238 @@ +2010-04-01 Eli Zaretskii <eliz@gnu.org> + + * xdisp.c (set_cursor_from_row): Fix cursor positioning when the + string with `cursor' property comes from an `after-string' + overlay. (Bug#5816) + +2010-04-01 Glenn Morris <rgm@gnu.org> + + * Makefile.in (LIBTIFF, LIBJPEG, LIBPNG, LIBGIF, LIBXPM, XFT_LIBS): + Define as Makefile variables. + (LIBX): Use above variables rather than directly using autoconf. + +2010-03-31 Dan Nicolaescu <dann@ics.uci.edu> + + Clean up BSD_SYSTEM use. + * xterm.c: + * process.c: + * emacs.c: Use HAVE_SYS_IOCTL_H instead of BSD_SYSTEM as a guard + for including <sys/ioctl.h>. + * sysdep.c (wait_without_blocking): Remove BSD_SYSTEM case, this + code is only used for MSDOS. + +2010-03-31 Juri Linkov <juri@jurta.org> + + * image.c: Add `Qextension_data'. + (syms_of_image): Initialize and staticpro `Qextension_data'. + (Fimage_metadata): Rename from `Fimage_extension_data'. + (gif_load): Put GIF extension data to the property + `Qextension_data'. + +2010-03-31 Chong Yidong <cyd@stupidchicken.com> + + * nsfns.m (ns_set_doc_edited): Remove unused arg OLDVAL. + * nsterm.h: Fix prototype. + +2010-03-31 Eli Zaretskii <eliz@gnu.org> + + * xdisp.c (highlight_trailing_whitespace): Support highlight of + trailing whitespace in right-to-left rows. + +2010-03-31 Stefan Monnier <monnier@iro.umontreal.ca> + + Get rid of the direct_output optimizations. + * keyboard.c (nonundocount): Remove extern declaration. + (command_loop_1): Remove brittle optimisation for cheap and + common operations. + * xdisp.c (redisplay_internal): Don't bother checking + redisplay_performed_directly_p any more. + * sysdep.c (init_sys_modes): Don't call direct_output_forward_char + any more. + * dispnew.c (redisplay_performed_directly_p) + (direct_output_for_insert, direct_output_forward_char): + * dispextern.h (redisplay_performed_directly_p) + (direct_output_for_insert, direct_output_forward_char): Remove. + * cmds.c (nonundocount): Make it static. + +2010-03-31 Bernhard Herzog <bh@intevation.de> (tiny change) + + * menu.c (Fx_popup_menu): Use last_event_timestamp (Bug#4930). + +2010-03-31 Jan Djärv <jan.h.d@swipnet.se> + + * xdisp.c (note_mouse_highlight): Don't do highlight if pointer is + invisible (Bug#5766). + +2010-03-31 Adrian Robert <adrian.b.robert@gmail.com> + + * xdisp.c (x_consider_frame_title, update_window_cursor): + Remove HAVE_NS conditionals. + (prepare_menu_bars)[HAVE_NS]: Call ns_set_doc_edited. + + * nsfns.m (x_implicitly_set_name): If frame-title-format is t, use + filename for the title. + (ns_set_doc_edited): Do nothing if the selected window is a + minibuffer window. + + * nsterm.h: Add prototypes for ns_set_name_as_filename and + ns_set_doc_edited. + + * nsterm.m: Remove unneeded prototype. + +2010-03-31 Glenn Morris <rgm@gnu.org> + + * Makefile.in (SOME_MACHINE_OBJECTS): Ensure dbus stuff is always + in the DOC file. (Bug#5336) + +2010-03-31 Chong Yidong <cyd@stupidchicken.com> + + * xdisp.c (pos_visible_p): Revert 2008-01-25 change (Bug#5730). + +2010-03-31 Stefan Monnier <monnier@iro.umontreal.ca> + + * window.c (keys_of_window): Remove redundant/overridden bindings. + +2010-03-30 Eli Zaretskii <eliz@gnu.org> + + * xdisp.c (BUFFER_POS_REACHED_P, move_it_in_display_line_to): + Restore original behavior when the iterator is not bidi_p. + +2010-03-30 Dan Nicolaescu <dann@ics.uci.edu> + + * xdisp.c (syms_of_xdisp): Use intern_c_string instead of intern. + +2010-03-30 Eli Zaretskii <eliz@gnu.org> + + * bidi.c (bidi_cache_iterator_state): Invalidate the cache if we + are outside the range of cached character positions. + +2010-03-30 Juanma Barranquero <lekktu@gmail.com> + + * makefile.w32-in ($(BLD)/bidi.$(O)): Add dependency on w32gui.h. + +2010-03-30 Eli Zaretskii <eliz@gnu.org> + + Initial support for bidirectional editing. + + * Makefile.in (obj): Include bidi.o. + (bidi.o): New target. + + * makefile.w32-in (OBJ1): Add $(BLD)/bidi.$(O). + ($(BLD)/bidi.$(O)): New target. + + * bidi.c: New file. + + * buffer.h (struct buffer): New members bidi_display_reordering + and bidi_paragraph_direction. + + * buffer.c (init_buffer_once): Initialize bidi_display_reordering + and bidi_paragraph_direction. + (syms_of_buffer): Declare Lisp variables bidi-display-reordering + and bidi-paragraph-direction. + (Fbuffer_swap_text): Swap the values of + bidi_display_reordering and bidi_paragraph_direction. + + * dispextern.h (BIDI_MAXLEVEL, BIDI_AT_BASE_LEVEL): New macros. + (bidi_type_t, bidi_dir_t): New types. + (bidi_saved_info, bidi_stack, bidi_it): New structures. + (struct it): New members bidi_p, bidi_it, paragraph_embedding, + prev_stop, base_level_stop, and eol_pos. + (bidi_init_it, bidi_get_next_char_visually): New prototypes. + (IT_STACK_SIZE): Enlarge to 5. + (struct glyph_row): New member reversed_p. + <string_buffer_position>: Update prototype. + (PRODUCE_GLYPHS): Set the reversed_p flag in the iterator's + glyph_row if bidi_it.paragraph_dir == R2L. + (struct glyph): New members resolved_level and bidi_type. + + * dispnew.c (direct_output_forward_char): Give up if we need bidi + processing or buffer's direction is right-to-left. + (prepare_desired_row): Preserve the reversed_p flag. + (row_equal_p): Compare the reversed_p attributes as well. + + * xdisp.c (init_iterator): Initialize it->bidi_p. Call + bidi_init_it and set it->paragraph_embedding from the current + buffer's value of bidi_paragraph_direction. + (reseat_1): Initialize bidi_it.first_elt. + (set_iterator_to_next, next_element_from_buffer): Use the value of + paragraph_embedding to determine the paragraph direction. + (set_iterator_to_next): Under bidi reordering, call + bidi_get_next_char_visually. Call bidi_paragraph_init if the + new_paragraph flag is set in the bidi iterator. + (next_element_from_buffer): If bidi_it.first_elt is set, + initialize paragraph direction and find the first character to + display in the visual order. If reseated to a middle of a line, + prime the bidi iterator starting at the line's beginning. Handle + the situation where we overstepped stop_charpos due to + non-linearity of the bidi iteration. Likewise for when we back up + beyond the previous stop_charpos. When moving across stop_charpos, + record it in prev_stop. + (display_line): Set row->end and it->start for the next row to the + next character in logical order. Always extend reversed_p rows to + the end of line, even if they end at ZV. Copy the reversed_p flag + to the next glyph row. Keep calling set_cursor_from_row for + bidi-reordered rows even if we already have a possible candidate + for cursor position. Set row_end after all the row's glyphs have + been produced, by looping over the glyphs. Record the position + after EOL in it->eol_pos, and use it to set end_pos of the last + row produced for a continued line. + <Qright_to_left, Qleft_to_right>: New variables. + (syms_of_xdisp): Initialize and staticpro them. + (string_buffer_position_lim): New function. + (string_buffer_position): Most of code moved to + string_buffer_position_lim. Last argument and return value are + now EMACS_INT; all callers changed. + (set_cursor_from_row): Rewritten to support bidirectional text and + reversed glyph rows. + (text_outside_line_unchanged_p, try_window_id): Disable + optimizations if we are reordering bidirectional text and the + paragraph direction can be affected by the change. + (append_glyph, append_composite_glyph) + (produce_image_glyph, append_stretch_glyph): Set the + resolved_level and bidi_type members of each glyph. + (append_glyph): If the glyph row is reversed, prepend the glyph + rather than appending it. + (handle_stop_backwards): New function. + (reseat_1, pop_it, push_it): Set prev_stop and base_level_stop. + (reseat): call handle_stop_backwards to recompute prev_stop and + base_level_stop for the new position. + (handle_invisible_prop): Under bidi iteration, skip invisible text + using bidi_get_next_char_visually. If we are `reseat'ed, init the + paragraph direction. Update IT->prev_stop after skipping + invisible text. + (move_it_in_display_line_to): New variables prev_method + and prev_pos. Compare for strict equality in + BUFFER_POS_REACHED_P. + (try_cursor_movement): Examine all the candidate rows that occlude + point, to return the best match. If rows are bidi-reordered + and point moved backwards, back up to the row that is not a + continuation line, and start looking for a suitable row from + there. + + * term.c (append_glyph): Reverse glyphs by pre-pending them, + rather than appending, if the glyph_row's reversed_p flag is set. + Set the resolved_level and bidi_type members of each glyph. + + * .gdbinit (pbiditype): New command. + (pgx): Use it to display bidi level and type of the glyph. + (pitx): Display some bidi information about the iterator. + (prowlims, pmtxrows): New commands. + +2010-03-30 Dan Nicolaescu <dann@ics.uci.edu> + + Remove all uses of C_DEBUG_SWITCH and LIBS_DEBUG. + * s/usg5-4.h (LIBS_DEBUG): + * s/irix6-5.h (C_DEBUG_SWITCH): + * s/gnu-linux.h (LIBS_DEBUG): + * s/darwin.h (LIBS_DEBUG): + * s/bsd-common.h (LIBS_DEBUG): + * s/aix4-2.h (LIBS_DEBUG, C_DEBUG_SWITCH): + * m/iris4d.h (LIBS_DEBUG): + * m/hp800.h (LIBS_DEBUG): Remove definitions. + + * Makefile.in (LIBES): Remove reference to LIBS_DEBUG. + (LIBS_DEBUG): Remove definition. + 2010-03-27 Chong Yidong <cyd@stupidchicken.com> * process.c (Fmake_network_process): Don't apply Bug#5173 fix for diff -r 86c85c80cd84 -r 5a619d0a9158 src/Makefile.in --- a/src/Makefile.in Mon Mar 29 14:00:56 2010 +0000 +++ b/src/Makefile.in Thu Apr 01 14:34:20 2010 +0000 @@ -68,6 +68,13 @@ OTHER_FILES = @OTHER_FILES@ +LIBTIFF=@LIBTIFF@ +LIBJPEG=@LIBJPEG@ +LIBPNG=@LIBPNG@ +LIBGIF=@LIBGIF@ +LIBXPM=@LIBXPM@ +XFT_LIBS=@XFT_LIBS@ + # ========================== start of cpp stuff ======================= /* From here on, comments must be done in C syntax. */ @@ -127,11 +134,6 @@ #define LIB_STANDARD #endif -/* Unless inhibited or changed, use -lg to link for debugging. */ -#ifndef LIBS_DEBUG -#define LIBS_DEBUG -lg -#endif - /* Some s/SYSTEM.h files define this to request special libraries. */ #ifndef LIBS_SYSTEM #define LIBS_SYSTEM @@ -374,7 +376,7 @@ /* LD_SWITCH_X_DEFAULT comes after everything else that specifies options for where to find X libraries, but before those libraries. */ X11_LDFLAGS = LD_SWITCH_X_SITE LD_SWITCH_X_DEFAULT -LIBX= $(LIBXMENU) $(X11_LDFLAGS) $(LIBXT) @LIBTIFF@ @LIBJPEG@ @LIBPNG@ @LIBGIF@ @LIBXPM@ LIB_X11_LIB LIBX11_SYSTEM @XFT_LIBS@ +LIBX= $(LIBXMENU) $(X11_LDFLAGS) $(LIBXT) $(LIBTIFF) $(LIBJPEG) $(LIBPNG) $(LIBGIF) $(LIBXPM) LIB_X11_LIB LIBX11_SYSTEM $(XFT_LIBS) #else /* not HAVE_X11 */ LIBX= $(LIBXMENU) LD_SWITCH_X_SITE #endif /* not HAVE_X11 */ @@ -501,7 +503,7 @@ /* lastfile must follow all files whose initialized data areas should be dumped as pure by dump-emacs. */ obj= dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \ - charset.o coding.o category.o ccl.o character.o chartab.o \ + charset.o coding.o category.o ccl.o character.o chartab.o bidi.o \ cm.o term.o terminal.o xfaces.o $(XOBJ) $(GTK_OBJ) $(DBUS_OBJ) \ emacs.o keyboard.o macros.o keymap.o sysdep.o \ buffer.o filelock.o insdel.o marker.o \ @@ -520,7 +522,7 @@ in case they are needed there. */ SOME_MACHINE_OBJECTS = dosfns.o msdos.o \ xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \ - fontset.o \ + fontset.o dbusbind.o \ nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o \ w32.o w32console.o w32fns.o w32heap.o w32inevt.o \ w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o $(FONT_DRIVERS) @@ -850,7 +852,7 @@ LIBES = $(LOADLIBES) $(LIBS) $(LIBX) $(LIBSOUND) $(RSVG_LIBS) $(DBUS_LIBS) \ @LIBGPM@ @LIBRESOLV@ LIBS_SYSTEM LIBS_MACHINE LIBS_TERMCAP \ - LIBS_DEBUG $(GETLOADAVG_LIBS) ${GCONF_LIBS} \ + $(GETLOADAVG_LIBS) ${GCONF_LIBS} \ @FREETYPE_LIBS@ @FONTCONFIG_LIBS@ @LIBOTF_LIBS@ @M17N_FLT_LIBS@ \ $(GNULIB_VAR) LIB_MATH LIB_STANDARD $(GNULIB_VAR) @@ -987,6 +989,7 @@ atimer.o: atimer.c atimer.h syssignal.h systime.h lisp.h blockinput.h \ $(config_h) +bidi.o: bidi.c buffer.h character.h dispextern.h lisp.h $(config_h) buffer.o: buffer.c buffer.h region-cache.h commands.h window.h \ $(INTERVALS_H) blockinput.h atimer.h systime.h character.h \ indent.h keyboard.h coding.h keymap.h frame.h lisp.h $(config_h) diff -r 86c85c80cd84 -r 5a619d0a9158 src/bidi.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/bidi.c Thu Apr 01 14:34:20 2010 +0000 @@ -0,0 +1,2032 @@ +/* Low-level bidirectional buffer-scanning functions for GNU Emacs. + Copyright (C) 2000, 2001, 2004, 2005, 2009, 2010 + Free Software Foundation, Inc. + +This file is part of GNU Emacs. + +GNU Emacs is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GNU Emacs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ + +/* Written by Eli Zaretskii <eliz@gnu.org>. + + A sequential implementation of the Unicode Bidirectional algorithm, + as per UAX#9, a part of the Unicode Standard. + + Unlike the reference and most other implementations, this one is + designed to be called once for every character in the buffer. + + The main entry point is bidi_get_next_char_visually. Each time it + is called, it finds the next character in the visual order, and + returns its information in a special structure. The caller is then + expected to process this character for display or any other + purposes, and call bidi_get_next_char_visually for the next + character. See the comments in bidi_get_next_char_visually for + more details about its algorithm that finds the next visual-order + character by resolving their levels on the fly. + + If you want to understand the code, you will have to read it + together with the relevant portions of UAX#9. The comments include + references to UAX#9 rules, for that very reason. + + A note about references to UAX#9 rules: if the reference says + something like "X9/Retaining", it means that you need to refer to + rule X9 and to its modifications decribed in the "Implementation + Notes" section of UAX#9, under "Retaining Format Codes". */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> + +#ifdef HAVE_STRING_H +#include <string.h> +#endif + +#include <setjmp.h> + +#include "lisp.h" +#include "buffer.h" +#include "character.h" +#include "dispextern.h" + +static int bidi_initialized = 0; + +static Lisp_Object bidi_type_table; + +/* FIXME: Remove these when bidi_explicit_dir_char uses a lookup table. */ +#define LRM_CHAR 0x200E +#define RLM_CHAR 0x200F +#define LRE_CHAR 0x202A +#define RLE_CHAR 0x202B +#define PDF_CHAR 0x202C +#define LRO_CHAR 0x202D +#define RLO_CHAR 0x202E + +#define BIDI_EOB -1 +#define BIDI_BOB -2 /* FIXME: Is this needed? */ + +/* Local data structures. (Look in dispextern.h for the rest.) */ + +/* What we need to know about the current paragraph. */ +struct bidi_paragraph_info { + int start_bytepos; /* byte position where it begins */ + int end_bytepos; /* byte position where it ends */ + int embedding_level; /* its basic embedding level */ + bidi_dir_t base_dir; /* its base direction */ +}; + +/* Data type for describing the bidirectional character categories. */ +typedef enum { + UNKNOWN_BC, + NEUTRAL, + WEAK, + STRONG +} bidi_category_t; + +int bidi_ignore_explicit_marks_for_paragraph_level = 1; + +static Lisp_Object fallback_paragraph_start_re, fallback_paragraph_separate_re; +static Lisp_Object Qparagraph_start, Qparagraph_separate; + +static void +bidi_initialize () +{ + /* FIXME: This should come from the Unicode Database. */ + struct { + int from, to; + bidi_type_t type; + } bidi_type[] = + { { 0x0000, 0x0008, WEAK_BN }, + { 0x0009, 0x0000, NEUTRAL_S }, + { 0x000A, 0x0000, NEUTRAL_B }, + { 0x000B, 0x0000, NEUTRAL_S }, + { 0x000C, 0x0000, NEUTRAL_WS }, + { 0x000D, 0x0000, NEUTRAL_B }, + { 0x000E, 0x001B, WEAK_BN }, + { 0x001C, 0x001E, NEUTRAL_B }, + { 0x001F, 0x0000, NEUTRAL_S }, + { 0x0020, 0x0000, NEUTRAL_WS }, + { 0x0021, 0x0022, NEUTRAL_ON }, + { 0x0023, 0x0025, WEAK_ET }, + { 0x0026, 0x002A, NEUTRAL_ON }, + { 0x002B, 0x0000, WEAK_ES }, + { 0x002C, 0x0000, WEAK_CS }, + { 0x002D, 0x0000, WEAK_ES }, + { 0x002E, 0x002F, WEAK_CS }, + { 0x0030, 0x0039, WEAK_EN }, + { 0x003A, 0x0000, WEAK_CS }, + { 0x003B, 0x0040, NEUTRAL_ON }, + { 0x005B, 0x0060, NEUTRAL_ON }, + { 0x007B, 0x007E, NEUTRAL_ON }, + { 0x007F, 0x0084, WEAK_BN }, + { 0x0085, 0x0000, NEUTRAL_B }, + { 0x0086, 0x009F, WEAK_BN }, + { 0x00A0, 0x0000, WEAK_CS }, + { 0x00A1, 0x0000, NEUTRAL_ON }, + { 0x00A2, 0x00A5, WEAK_ET }, + { 0x00A6, 0x00A9, NEUTRAL_ON }, + { 0x00AB, 0x00AC, NEUTRAL_ON }, + { 0x00AD, 0x0000, WEAK_BN }, + { 0x00AE, 0x00Af, NEUTRAL_ON }, + { 0x00B0, 0x00B1, WEAK_ET }, + { 0x00B2, 0x00B3, WEAK_EN }, + { 0x00B4, 0x0000, NEUTRAL_ON }, + { 0x00B6, 0x00B8, NEUTRAL_ON }, + { 0x00B9, 0x0000, WEAK_EN }, + { 0x00BB, 0x00BF, NEUTRAL_ON }, + { 0x00D7, 0x0000, NEUTRAL_ON }, + { 0x00F7, 0x0000, NEUTRAL_ON }, + { 0x02B9, 0x02BA, NEUTRAL_ON }, + { 0x02C2, 0x02CF, NEUTRAL_ON }, + { 0x02D2, 0x02DF, NEUTRAL_ON }, + { 0x02E5, 0x02ED, NEUTRAL_ON }, + { 0x0300, 0x036F, WEAK_NSM }, + { 0x0374, 0x0375, NEUTRAL_ON }, + { 0x037E, 0x0385, NEUTRAL_ON }, + { 0x0387, 0x0000, NEUTRAL_ON }, + { 0x03F6, 0x0000, NEUTRAL_ON }, + { 0x0483, 0x0489, WEAK_NSM }, + { 0x058A, 0x0000, NEUTRAL_ON }, + { 0x0591, 0x05BD, WEAK_NSM }, + { 0x05BE, 0x0000, STRONG_R }, + { 0x05BF, 0x0000, WEAK_NSM }, + { 0x05C0, 0x0000, STRONG_R }, + { 0x05C1, 0x05C2, WEAK_NSM }, + { 0x05C3, 0x0000, STRONG_R }, + { 0x05C4, 0x05C5, WEAK_NSM }, + { 0x05C6, 0x0000, STRONG_R }, + { 0x05C7, 0x0000, WEAK_NSM }, + { 0x05D0, 0x05F4, STRONG_R }, + { 0x060C, 0x0000, WEAK_CS }, + { 0x061B, 0x064A, STRONG_AL }, + { 0x064B, 0x0655, WEAK_NSM }, + { 0x0660, 0x0669, WEAK_AN }, + { 0x066A, 0x0000, WEAK_ET }, + { 0x066B, 0x066C, WEAK_AN }, + { 0x066D, 0x066F, STRONG_AL }, + { 0x0670, 0x0000, WEAK_NSM }, + { 0x0671, 0x06D5, STRONG_AL }, + { 0x06D6, 0x06DC, WEAK_NSM }, + { 0x06DD, 0x0000, STRONG_AL }, + { 0x06DE, 0x06E4, WEAK_NSM }, + { 0x06E5, 0x06E6, STRONG_AL }, + { 0x06E7, 0x06E8, WEAK_NSM }, + { 0x06E9, 0x0000, NEUTRAL_ON }, + { 0x06EA, 0x06ED, WEAK_NSM }, + { 0x06F0, 0x06F9, WEAK_EN }, + { 0x06FA, 0x070D, STRONG_AL }, + { 0x070F, 0x0000, WEAK_BN }, + { 0x0710, 0x0000, STRONG_AL }, + { 0x0711, 0x0000, WEAK_NSM }, + { 0x0712, 0x072C, STRONG_AL }, + { 0x0730, 0x074A, WEAK_NSM }, + { 0x0780, 0x07A5, STRONG_AL }, + { 0x07A6, 0x07B0, WEAK_NSM }, + { 0x07B1, 0x0000, STRONG_AL }, + { 0x0901, 0x0902, WEAK_NSM }, + { 0x093C, 0x0000, WEAK_NSM }, + { 0x0941, 0x0948, WEAK_NSM }, + { 0x094D, 0x0000, WEAK_NSM }, + { 0x0951, 0x0954, WEAK_NSM }, + { 0x0962, 0x0963, WEAK_NSM }, + { 0x0981, 0x0000, WEAK_NSM }, + { 0x09BC, 0x0000, WEAK_NSM }, + { 0x09C1, 0x09C4, WEAK_NSM }, + { 0x09CD, 0x0000, WEAK_NSM }, + { 0x09E2, 0x09E3, WEAK_NSM }, + { 0x09F2, 0x09F3, WEAK_ET }, + { 0x0A02, 0x0000, WEAK_NSM }, + { 0x0A3C, 0x0000, WEAK_NSM }, + { 0x0A41, 0x0A4D, WEAK_NSM }, + { 0x0A70, 0x0A71, WEAK_NSM }, + { 0x0A81, 0x0A82, WEAK_NSM }, + { 0x0ABC, 0x0000, WEAK_NSM }, + { 0x0AC1, 0x0AC8, WEAK_NSM }, + { 0x0ACD, 0x0000, WEAK_NSM }, + { 0x0B01, 0x0000, WEAK_NSM }, + { 0x0B3C, 0x0000, WEAK_NSM }, + { 0x0B3F, 0x0000, WEAK_NSM }, + { 0x0B41, 0x0B43, WEAK_NSM }, + { 0x0B4D, 0x0B56, WEAK_NSM }, + { 0x0B82, 0x0000, WEAK_NSM }, + { 0x0BC0, 0x0000, WEAK_NSM }, + { 0x0BCD, 0x0000, WEAK_NSM }, + { 0x0C3E, 0x0C40, WEAK_NSM }, + { 0x0C46, 0x0C56, WEAK_NSM }, + { 0x0CBF, 0x0000, WEAK_NSM }, + { 0x0CC6, 0x0000, WEAK_NSM }, + { 0x0CCC, 0x0CCD, WEAK_NSM }, + { 0x0D41, 0x0D43, WEAK_NSM }, + { 0x0D4D, 0x0000, WEAK_NSM }, + { 0x0DCA, 0x0000, WEAK_NSM }, + { 0x0DD2, 0x0DD6, WEAK_NSM }, + { 0x0E31, 0x0000, WEAK_NSM }, + { 0x0E34, 0x0E3A, WEAK_NSM }, + { 0x0E3F, 0x0000, WEAK_ET }, + { 0x0E47, 0x0E4E, WEAK_NSM }, + { 0x0EB1, 0x0000, WEAK_NSM }, + { 0x0EB4, 0x0EBC, WEAK_NSM }, + { 0x0EC8, 0x0ECD, WEAK_NSM }, + { 0x0F18, 0x0F19, WEAK_NSM }, + { 0x0F35, 0x0000, WEAK_NSM }, + { 0x0F37, 0x0000, WEAK_NSM }, + { 0x0F39, 0x0000, WEAK_NSM }, + { 0x0F3A, 0x0F3D, NEUTRAL_ON }, + { 0x0F71, 0x0F7E, WEAK_NSM }, + { 0x0F80, 0x0F84, WEAK_NSM }, + { 0x0F86, 0x0F87, WEAK_NSM }, + { 0x0F90, 0x0FBC, WEAK_NSM }, + { 0x0FC6, 0x0000, WEAK_NSM }, + { 0x102D, 0x1030, WEAK_NSM }, + { 0x1032, 0x1037, WEAK_NSM }, + { 0x1039, 0x0000, WEAK_NSM }, + { 0x1058, 0x1059, WEAK_NSM }, + { 0x1680, 0x0000, NEUTRAL_WS }, + { 0x169B, 0x169C, NEUTRAL_ON }, + { 0x1712, 0x1714, WEAK_NSM }, + { 0x1732, 0x1734, WEAK_NSM }, + { 0x1752, 0x1753, WEAK_NSM }, + { 0x1772, 0x1773, WEAK_NSM }, + { 0x17B7, 0x17BD, WEAK_NSM }, + { 0x17C6, 0x0000, WEAK_NSM }, + { 0x17C9, 0x17D3, WEAK_NSM }, + { 0x17DB, 0x0000, WEAK_ET }, + { 0x1800, 0x180A, NEUTRAL_ON }, + { 0x180B, 0x180D, WEAK_NSM }, + { 0x180E, 0x0000, WEAK_BN }, + { 0x18A9, 0x0000, WEAK_NSM }, + { 0x1FBD, 0x0000, NEUTRAL_ON }, + { 0x1FBF, 0x1FC1, NEUTRAL_ON }, + { 0x1FCD, 0x1FCF, NEUTRAL_ON }, + { 0x1FDD, 0x1FDF, NEUTRAL_ON }, + { 0x1FED, 0x1FEF, NEUTRAL_ON }, + { 0x1FFD, 0x1FFE, NEUTRAL_ON }, + { 0x2000, 0x200A, NEUTRAL_WS }, + { 0x200B, 0x200D, WEAK_BN }, + { 0x200F, 0x0000, STRONG_R }, + { 0x2010, 0x2027, NEUTRAL_ON }, + { 0x2028, 0x0000, NEUTRAL_WS }, + { 0x2029, 0x0000, NEUTRAL_B }, + { 0x202A, 0x0000, LRE }, + { 0x202B, 0x0000, RLE }, + { 0x202C, 0x0000, PDF }, + { 0x202D, 0x0000, LRO }, + { 0x202E, 0x0000, RLO }, + { 0x202F, 0x0000, NEUTRAL_WS }, + { 0x2030, 0x2034, WEAK_ET }, + { 0x2035, 0x2057, NEUTRAL_ON }, + { 0x205F, 0x0000, NEUTRAL_WS }, + { 0x2060, 0x206F, WEAK_BN }, + { 0x2070, 0x0000, WEAK_EN }, + { 0x2074, 0x2079, WEAK_EN }, + { 0x207A, 0x207B, WEAK_ET }, + { 0x207C, 0x207E, NEUTRAL_ON }, + { 0x2080, 0x2089, WEAK_EN }, + { 0x208A, 0x208B, WEAK_ET }, + { 0x208C, 0x208E, NEUTRAL_ON }, + { 0x20A0, 0x20B1, WEAK_ET }, + { 0x20D0, 0x20EA, WEAK_NSM }, + { 0x2100, 0x2101, NEUTRAL_ON }, + { 0x2103, 0x2106, NEUTRAL_ON }, + { 0x2108, 0x2109, NEUTRAL_ON }, + { 0x2114, 0x0000, NEUTRAL_ON }, + { 0x2116, 0x2118, NEUTRAL_ON }, + { 0x211E, 0x2123, NEUTRAL_ON }, + { 0x2125, 0x0000, NEUTRAL_ON }, + { 0x2127, 0x0000, NEUTRAL_ON }, + { 0x2129, 0x0000, NEUTRAL_ON }, + { 0x212E, 0x0000, WEAK_ET }, + { 0x2132, 0x0000, NEUTRAL_ON }, + { 0x213A, 0x0000, NEUTRAL_ON }, + { 0x2140, 0x2144, NEUTRAL_ON }, + { 0x214A, 0x215F, NEUTRAL_ON }, + { 0x2190, 0x2211, NEUTRAL_ON }, + { 0x2212, 0x2213, WEAK_ET }, + { 0x2214, 0x2335, NEUTRAL_ON }, + { 0x237B, 0x2394, NEUTRAL_ON }, + { 0x2396, 0x244A, NEUTRAL_ON }, + { 0x2460, 0x249B, WEAK_EN }, + { 0x24EA, 0x0000, WEAK_EN }, + { 0x24EB, 0x2FFB, NEUTRAL_ON }, + { 0x3000, 0x0000, NEUTRAL_WS }, + { 0x3001, 0x3004, NEUTRAL_ON }, + { 0x3008, 0x3020, NEUTRAL_ON }, + { 0x302A, 0x302F, WEAK_NSM }, + { 0x3030, 0x0000, NEUTRAL_ON }, + { 0x3036, 0x3037, NEUTRAL_ON }, + { 0x303D, 0x303F, NEUTRAL_ON }, + { 0x3099, 0x309A, WEAK_NSM }, + { 0x309B, 0x309C, NEUTRAL_ON }, + { 0x30A0, 0x0000, NEUTRAL_ON }, + { 0x30FB, 0x0000, NEUTRAL_ON }, + { 0x3251, 0x325F, NEUTRAL_ON }, + { 0x32B1, 0x32BF, NEUTRAL_ON }, + { 0xA490, 0xA4C6, NEUTRAL_ON }, + { 0xFB1D, 0x0000, STRONG_R }, + { 0xFB1E, 0x0000, WEAK_NSM }, + { 0xFB1F, 0xFB28, STRONG_R }, + { 0xFB29, 0x0000, WEAK_ET }, + { 0xFB2A, 0xFB4F, STRONG_R }, + { 0xFB50, 0xFD3D, STRONG_AL }, + { 0xFD3E, 0xFD3F, NEUTRAL_ON }, + { 0xFD50, 0xFDFC, STRONG_AL }, + { 0xFE00, 0xFE23, WEAK_NSM }, + { 0xFE30, 0xFE4F, NEUTRAL_ON }, + { 0xFE50, 0x0000, WEAK_CS }, + { 0xFE51, 0x0000, NEUTRAL_ON }, + { 0xFE52, 0x0000, WEAK_CS }, + { 0xFE54, 0x0000, NEUTRAL_ON }, + { 0xFE55, 0x0000, WEAK_CS }, + { 0xFE56, 0xFE5E, NEUTRAL_ON }, + { 0xFE5F, 0x0000, WEAK_ET }, + { 0xFE60, 0xFE61, NEUTRAL_ON }, + { 0xFE62, 0xFE63, WEAK_ET }, + { 0xFE64, 0xFE68, NEUTRAL_ON }, + { 0xFE69, 0xFE6A, WEAK_ET }, + { 0xFE6B, 0x0000, NEUTRAL_ON }, + { 0xFE70, 0xFEFC, STRONG_AL }, + { 0xFEFF, 0x0000, WEAK_BN }, + { 0xFF01, 0xFF02, NEUTRAL_ON }, + { 0xFF03, 0xFF05, WEAK_ET }, + { 0xFF06, 0xFF0A, NEUTRAL_ON }, + { 0xFF0B, 0x0000, WEAK_ET }, + { 0xFF0C, 0x0000, WEAK_CS }, + { 0xFF0D, 0x0000, WEAK_ET }, + { 0xFF0E, 0x0000, WEAK_CS }, + { 0xFF0F, 0x0000, WEAK_ES }, + { 0xFF10, 0xFF19, WEAK_EN }, + { 0xFF1A, 0x0000, WEAK_CS }, + { 0xFF1B, 0xFF20, NEUTRAL_ON }, + { 0xFF3B, 0xFF40, NEUTRAL_ON }, + { 0xFF5B, 0xFF65, NEUTRAL_ON }, + { 0xFFE0, 0xFFE1, WEAK_ET }, + { 0xFFE2, 0xFFE4, NEUTRAL_ON }, + { 0xFFE5, 0xFFE6, WEAK_ET }, + { 0xFFE8, 0xFFEE, NEUTRAL_ON }, + { 0xFFF9, 0xFFFB, WEAK_BN }, + { 0xFFFC, 0xFFFD, NEUTRAL_ON }, + { 0x1D167, 0x1D169, WEAK_NSM }, + { 0x1D173, 0x1D17A, WEAK_BN }, + { 0x1D17B, 0x1D182, WEAK_NSM }, + { 0x1D185, 0x1D18B, WEAK_NSM }, + { 0x1D1AA, 0x1D1AD, WEAK_NSM }, + { 0x1D7CE, 0x1D7FF, WEAK_EN }, + { 0xE0001, 0xE007F, WEAK_BN } }; + int i; + + bidi_type_table = Fmake_char_table (Qnil, make_number (STRONG_L)); + staticpro (&bidi_type_table); + + for (i = 0; i < sizeof bidi_type / sizeof bidi_type[0]; i++) + char_table_set_range (bidi_type_table, bidi_type[i].from, + bidi_type[i].to ? bidi_type[i].to : bidi_type[i].from, + make_number (bidi_type[i].type)); + + fallback_paragraph_start_re = + XSYMBOL (Fintern_soft (build_string ("paragraph-start"), Qnil))->value; + if (!STRINGP (fallback_paragraph_start_re)) + fallback_paragraph_start_re = build_string ("\f\\|[ \t]*$"); + staticpro (&fallback_paragraph_start_re); + Qparagraph_start = intern ("paragraph-start"); + staticpro (&Qparagraph_start); + fallback_paragraph_separate_re = + XSYMBOL (Fintern_soft (build_string ("paragraph-separate"), Qnil))->value; + if (!STRINGP (fallback_paragraph_separate_re)) + fallback_paragraph_separate_re = build_string ("[ \t\f]*$"); + staticpro (&fallback_paragraph_separate_re); + Qparagraph_separate = intern ("paragraph-separate"); + staticpro (&Qparagraph_separate); + bidi_initialized = 1; +} + +/* Return the bidi type of a character CH, subject to the current + directional OVERRIDE. */ +bidi_type_t +bidi_get_type (int ch, bidi_dir_t override) +{ + bidi_type_t default_type; + + if (ch == BIDI_EOB) + return NEUTRAL_B; + if (ch < 0 || ch > MAX_CHAR) + abort (); + + default_type = (bidi_type_t) XINT (CHAR_TABLE_REF (bidi_type_table, ch)); + + if (override == NEUTRAL_DIR) + return default_type; + + switch (default_type) + { + /* Although UAX#9 does not tell, it doesn't make sense to + override NEUTRAL_B and LRM/RLM characters. */ + case NEUTRAL_B: + case LRE: + case LRO: + case RLE: + case RLO: + case PDF: + return default_type; + default: + switch (ch) + { + case LRM_CHAR: + case RLM_CHAR: + return default_type; + default: + if (override == L2R) /* X6 */ + return STRONG_L; + else if (override == R2L) + return STRONG_R; + else + abort (); /* can't happen: handled above */ + } + } +} + +void +bidi_check_type (bidi_type_t type) +{ + if (type < UNKNOWN_BT || type > NEUTRAL_ON) + abort (); +} + +/* Given a bidi TYPE of a character, return its category. */ +bidi_category_t +bidi_get_category (bidi_type_t type) +{ + switch (type) + { + case UNKNOWN_BT: + return UNKNOWN_BC; + case STRONG_L: + case STRONG_R: + case STRONG_AL: + case LRE: + case LRO: + case RLE: + case RLO: + return STRONG; + case PDF: /* ??? really?? */ + case WEAK_EN: + case WEAK_ES: + case WEAK_ET: + case WEAK_AN: + case WEAK_CS: + case WEAK_NSM: + case WEAK_BN: + return WEAK; + case NEUTRAL_B: + case NEUTRAL_S: + case NEUTRAL_WS: + case NEUTRAL_ON: + return NEUTRAL; + default: + abort (); + } +} + +/* Return the mirrored character of C, if any. + + Note: The conditions in UAX#9 clause L4 must be tested by the + caller. */ +/* FIXME: exceedingly temporary! Should consult the Unicode database + of character properties. */ +int +bidi_mirror_char (int c) +{ + static const char mirrored_pairs[] = "()<>[]{}"; + const char *p = c > 0 && c < 128 ? strchr (mirrored_pairs, c) : NULL; + + if (p) + { + size_t i = p - mirrored_pairs; + + return mirrored_pairs [(i ^ 1)]; + } + return c; +} + +/* Copy the bidi iterator from FROM to TO. To save cycles, this only + copies the part of the level stack that is actually in use. */ +static inline void +bidi_copy_it (struct bidi_it *to, struct bidi_it *from) +{ + int i; + + /* Copy everything except the level stack and beyond. */ + memcpy (to, from, ((size_t)&((struct bidi_it *)0)->level_stack[0])); + + /* Copy the active part of the level stack. */ + to->level_stack[0] = from->level_stack[0]; /* level zero is always in use */ + for (i = 1; i <= from->stack_idx; i++) + to->level_stack[i] = from->level_stack[i]; +} + +/* Caching the bidi iterator states. */ + +static struct bidi_it bidi_cache[1000]; /* FIXME: make this dynamically allocated! */ +static int bidi_cache_idx; +static int bidi_cache_last_idx; + +static inline void +bidi_cache_reset (void) +{ + bidi_cache_idx = 0; + bidi_cache_last_idx = -1; +} + +static inline void +bidi_cache_fetch_state (int idx, struct bidi_it *bidi_it) +{ + int current_scan_dir = bidi_it->scan_dir; + + if (idx < 0 || idx >= bidi_cache_idx) + abort (); + + bidi_copy_it (bidi_it, &bidi_cache[idx]); + bidi_it->scan_dir = current_scan_dir; + bidi_cache_last_idx = idx; +} + +/* Find a cached state with a given CHARPOS and resolved embedding + level less or equal to LEVEL. if LEVEL is -1, disregard the + resolved levels in cached states. DIR, if non-zero, means search + in that direction from the last cache hit. */ +static inline int +bidi_cache_search (int charpos, int level, int dir) +{ + int i, i_start; + + if (bidi_cache_idx) + { + if (charpos < bidi_cache[bidi_cache_last_idx].charpos) + dir = -1; + else if (charpos > bidi_cache[bidi_cache_last_idx].charpos) + dir = 1; + if (dir) + i_start = bidi_cache_last_idx; + else + { + dir = -1; + i_start = bidi_cache_idx - 1; + } + + if (dir < 0) + { + /* Linear search for now; FIXME! */ + for (i = i_start; i >= 0; i--) + if (bidi_cache[i].charpos == charpos + && (level == -1 || bidi_cache[i].resolved_level <= level)) + return i; + } + else + { + for (i = i_start; i < bidi_cache_idx; i++) + if (bidi_cache[i].charpos == charpos + && (level == -1 || bidi_cache[i].resolved_level <= level)) + return i; + } + } + + return -1; +} + +/* Find a cached state where the resolved level changes to a value + that is lower than LEVEL, and return its cache slot index. DIR is + the direction to search, starting with the last used cache slot. + BEFORE, if non-zero, means return the index of the slot that is + ``before'' the level change in the search direction. That is, + given the cached levels like this: + + 1122333442211 + AB C + + and assuming we are at the position cached at the slot marked with + C, searching backwards (DIR = -1) for LEVEL = 2 will return the + index of slot B or A, depending whether BEFORE is, respectively, + non-zero or zero. */ +static int +bidi_cache_find_level_change (int level, int dir, int before) +{ + if (bidi_cache_idx) + { + int i = dir ? bidi_cache_last_idx : bidi_cache_idx - 1; + int incr = before ? 1 : 0; + + if (!dir) + dir = -1; + else if (!incr) + i += dir; + + if (dir < 0) + { + while (i >= incr) + { + if (bidi_cache[i - incr].resolved_level >= 0 + && bidi_cache[i - incr].resolved_level < level) + return i; + i--; + } + } + else + { + while (i < bidi_cache_idx - incr) + { + if (bidi_cache[i + incr].resolved_level >= 0 + && bidi_cache[i + incr].resolved_level < level) + return i; + i++; + } + } + } + + return -1; +} + +static inline void +bidi_cache_iterator_state (struct bidi_it *bidi_it, int resolved) +{ + int idx; + + /* We should never cache on backward scans. */ + if (bidi_it->scan_dir == -1) + abort (); + idx = bidi_cache_search (bidi_it->charpos, -1, 1); + + if (idx < 0) + { + idx = bidi_cache_idx; + /* Don't overrun the cache limit. */ + if (idx > sizeof (bidi_cache) / sizeof (bidi_cache[0]) - 1) + abort (); + /* Character positions should correspond to cache positions 1:1. + If we are outside the range of cached positions, the cache is + useless and must be reset. */ + if (idx > 0 && + (bidi_it->charpos > bidi_cache[idx - 1].charpos + 1 + || bidi_it->charpos < bidi_cache[0].charpos)) + { + bidi_cache_reset (); + idx = 0; + } + bidi_copy_it (&bidi_cache[idx], bidi_it); + if (!resolved) + bidi_cache[idx].resolved_level = -1; + bidi_cache[idx].new_paragraph = 0; + } + else + { + /* Copy only the members which could have changed, to avoid + costly copying of the entire struct. */ + bidi_cache[idx].type = bidi_it->type; + bidi_check_type (bidi_it->type); + bidi_cache[idx].type_after_w1 = bidi_it->type_after_w1; + bidi_check_type (bidi_it->type_after_w1); + if (resolved) + bidi_cache[idx].resolved_level = bidi_it->resolved_level; + else + bidi_cache[idx].resolved_level = -1; + bidi_cache[idx].invalid_levels = bidi_it->invalid_levels; + bidi_cache[idx].invalid_rl_levels = bidi_it->invalid_rl_levels; + bidi_cache[idx].next_for_neutral = bidi_it->next_for_neutral; + bidi_cache[idx].next_for_ws = bidi_it->next_for_ws; + bidi_cache[idx].ignore_bn_limit = bidi_it->ignore_bn_limit; + } + + bidi_cache_last_idx = idx; + if (idx >= bidi_cache_idx) + bidi_cache_idx = idx + 1; +} + +static inline bidi_type_t +bidi_cache_find (int charpos, int level, struct bidi_it *bidi_it) +{ + int i = bidi_cache_search (charpos, level, bidi_it->scan_dir); + + if (i >= 0) + { + bidi_dir_t current_scan_dir = bidi_it->scan_dir; + + bidi_copy_it (bidi_it, &bidi_cache[i]); + bidi_cache_last_idx = i; + /* Don't let scan direction from from the cached state override + the current scan direction. */ + bidi_it->scan_dir = current_scan_dir; + return bidi_it->type; + } + + return UNKNOWN_BT; +} + +static inline int +bidi_peek_at_next_level (struct bidi_it *bidi_it) +{ + if (bidi_cache_idx == 0 || bidi_cache_last_idx == -1) + abort (); + return bidi_cache[bidi_cache_last_idx + bidi_it->scan_dir].resolved_level; +} + +/* Check if buffer position CHARPOS/BYTEPOS is the end of a paragraph. + Value is the non-negative length of the paragraph separator + following the buffer position, -1 if position is at the beginning + of a new paragraph, or -2 if position is neither at beginning nor + at end of a paragraph. */ +EMACS_INT +bidi_at_paragraph_end (EMACS_INT charpos, EMACS_INT bytepos) +{ + Lisp_Object sep_re = Fbuffer_local_value (Qparagraph_separate, + Fcurrent_buffer ()); + Lisp_Object start_re = Fbuffer_local_value (Qparagraph_start, + Fcurrent_buffer ()); + EMACS_INT val; + + if (!STRINGP (sep_re)) + sep_re = fallback_paragraph_separate_re; + if (!STRINGP (start_re)) + start_re = fallback_paragraph_start_re; + + val = fast_looking_at (sep_re, charpos, bytepos, ZV, ZV_BYTE, Qnil); + if (val < 0) + { + if (fast_looking_at (start_re, charpos, bytepos, ZV, ZV_BYTE, Qnil) >= 0) + val = -1; + else + val = -2; + } + + return val; +} + +/* Determine the start-of-run (sor) directional type given the two + embedding levels on either side of the run boundary. Also, update + the saved info about previously seen characters, since that info is + generally valid for a single level run. */ +static inline void +bidi_set_sor_type (struct bidi_it *bidi_it, int level_before, int level_after) +{ + int higher_level = level_before > level_after ? level_before : level_after; + + /* The prev_was_pdf gork is required for when we have several PDFs + in a row. In that case, we want to compute the sor type for the + next level run only once: when we see the first PDF. That's + because the sor type depends only on the higher of the two levels + that we find on the two sides of the level boundary (see UAX#9, + clause X10), and so we don't need to know the final embedding + level to which we descend after processing all the PDFs. */ + if (!bidi_it->prev_was_pdf || level_before < level_after) + /* FIXME: should the default sor direction be user selectable? */ + bidi_it->sor = (higher_level & 1) != 0 ? R2L : L2R; + if (level_before > level_after) + bidi_it->prev_was_pdf = 1; + + bidi_it->prev.type = UNKNOWN_BT; + bidi_it->last_strong.type = bidi_it->last_strong.type_after_w1 = + bidi_it->last_strong.orig_type = UNKNOWN_BT; + bidi_it->prev_for_neutral.type = bidi_it->sor == R2L ? STRONG_R : STRONG_L; + bidi_it->prev_for_neutral.charpos = bidi_it->charpos; + bidi_it->prev_for_neutral.bytepos = bidi_it->bytepos; + bidi_it->next_for_neutral.type = bidi_it->next_for_neutral.type_after_w1 = + bidi_it->next_for_neutral.orig_type = UNKNOWN_BT; + bidi_it->ignore_bn_limit = 0; /* meaning it's unknown */ +} + +static void +bidi_line_init (struct bidi_it *bidi_it) +{ + bidi_it->scan_dir = 1; /* FIXME: do we need to have control on this? */ + bidi_it->resolved_level = bidi_it->level_stack[0].level; + bidi_it->level_stack[0].override = NEUTRAL_DIR; /* X1 */ + bidi_it->invalid_levels = 0; + bidi_it->invalid_rl_levels = -1; + bidi_it->next_en_pos = -1; + bidi_it->next_for_ws.type = UNKNOWN_BT; + bidi_set_sor_type (bidi_it, + bidi_it->paragraph_dir == R2L ? 1 : 0, + bidi_it->level_stack[0].level); /* X10 */ + + bidi_cache_reset (); +} + +/* Find the beginning of this paragraph by looking back in the buffer. + Value is the byte position of the paragraph's beginning. */ +static EMACS_INT +bidi_find_paragraph_start (EMACS_INT pos, EMACS_INT pos_byte) +{ + Lisp_Object re = Fbuffer_local_value (Qparagraph_start, Fcurrent_buffer ()); + EMACS_INT limit = ZV, limit_byte = ZV_BYTE; + + if (!STRINGP (re)) + re = fallback_paragraph_start_re; + while (pos_byte > BEGV_BYTE + && fast_looking_at (re, pos, pos_byte, limit, limit_byte, Qnil) < 0) + { + pos = find_next_newline_no_quit (pos - 1, -1); + pos_byte = CHAR_TO_BYTE (pos); + } + return pos_byte; +} + +/* Determine the direction, a.k.a. base embedding level, of the + paragraph we are about to iterate through. If DIR is either L2R or + R2L, just use that. Otherwise, determine the paragraph direction + from the first strong character of the paragraph. + + Note that this gives the paragraph separator the same direction as + the preceding paragraph, even though Emacs generally views the + separartor as not belonging to any paragraph. */ +void +bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it) +{ + EMACS_INT bytepos = bidi_it->bytepos; + + /* Special case for an empty buffer. */ + if (bytepos == BEGV_BYTE && bytepos == ZV_BYTE) + dir = L2R; + /* We should never be called at EOB or before BEGV. */ + else if (bytepos >= ZV_BYTE || bytepos < BEGV_BYTE) + abort (); + + if (dir == L2R) + { + bidi_it->paragraph_dir = L2R; + bidi_it->new_paragraph = 0; + } + else if (dir == R2L) + { + bidi_it->paragraph_dir = R2L; + bidi_it->new_paragraph = 0; + } + else if (dir == NEUTRAL_DIR) /* P2 */ + { + int ch, ch_len; + EMACS_INT pos; + bidi_type_t type; + EMACS_INT sep_len; + + /* If we are inside a paragraph separator, we are just waiting + for the separator to be exhausted; use the previous paragraph + direction. But don't do that if we have been just reseated, + because we need to reinitialize below in that case. */ + if (!bidi_it->first_elt + && bidi_it->charpos < bidi_it->separator_limit) + return; + + /* If we are on a newline, get past it to where the next + paragraph might start. But don't do that at BEGV since then + we are potentially in a new paragraph that doesn't yet + exist. */ + pos = bidi_it->charpos; + if (bytepos > BEGV_BYTE && FETCH_CHAR (bytepos) == '\n') + { + bytepos++; + pos++; + } + + /* We are either at the beginning of a paragraph or in the + middle of it. Find where this paragraph starts. */ + bytepos = bidi_find_paragraph_start (pos, bytepos); + + /* We should always be at the beginning of a new line at this + point. */ + if (!(bytepos == BEGV_BYTE || FETCH_CHAR (bytepos - 1) == '\n')) + abort (); + + bidi_it->separator_limit = -1; + bidi_it->new_paragraph = 0; + ch = FETCH_CHAR (bytepos); + ch_len = CHAR_BYTES (ch); + pos = BYTE_TO_CHAR (bytepos); + type = bidi_get_type (ch, NEUTRAL_DIR); + + for (pos++, bytepos += ch_len; + /* NOTE: UAX#9 says to search only for L, AL, or R types of + characters, and ignore RLE, RLO, LRE, and LRO. However, + I'm not sure it makes sense to omit those 4; should try + with and without that to see the effect. */ + (bidi_get_category (type) != STRONG) + || (bidi_ignore_explicit_marks_for_paragraph_level + && (type == RLE || type == RLO + || type == LRE || type == LRO)); + type = bidi_get_type (ch, NEUTRAL_DIR)) + { + if (type == NEUTRAL_B && bidi_at_paragraph_end (pos, bytepos) >= -1) + break; + if (bytepos >= ZV_BYTE) + { + /* Pretend there's a paragraph separator at end of buffer. */ + type = NEUTRAL_B; + break; + } + FETCH_CHAR_ADVANCE (ch, pos, bytepos); + } + if (type == STRONG_R || type == STRONG_AL) /* P3 */ + bidi_it->paragraph_dir = R2L; + else if (type == STRONG_L) + bidi_it->paragraph_dir = L2R; + } + else + abort (); + + /* Contrary to UAX#9 clause P3, we only default the paragraph + direction to L2R if we have no previous usable paragraph + direction. */ + if (bidi_it->paragraph_dir == NEUTRAL_DIR) + bidi_it->paragraph_dir = L2R; /* P3 and ``higher protocols'' */ + if (bidi_it->paragraph_dir == R2L) + bidi_it->level_stack[0].level = 1; + else + bidi_it->level_stack[0].level = 0; + + bidi_line_init (bidi_it); +} + +/* Do whatever UAX#9 clause X8 says should be done at paragraph's + end. */ +static inline void +bidi_set_paragraph_end (struct bidi_it *bidi_it) +{ + bidi_it->invalid_levels = 0; + bidi_it->invalid_rl_levels = -1; + bidi_it->stack_idx = 0; + bidi_it->resolved_level = bidi_it->level_stack[0].level; +} + +/* Initialize the bidi iterator from buffer position CHARPOS. */ +void +bidi_init_it (EMACS_INT charpos, EMACS_INT bytepos, struct bidi_it *bidi_it) +{ + if (! bidi_initialized) + bidi_initialize (); + bidi_it->charpos = charpos; + bidi_it->bytepos = bytepos; + bidi_it->first_elt = 1; + bidi_set_paragraph_end (bidi_it); + bidi_it->new_paragraph = 1; + bidi_it->separator_limit = -1; + bidi_it->type = NEUTRAL_B; + bidi_it->type_after_w1 = UNKNOWN_BT; + bidi_it->orig_type = UNKNOWN_BT; + bidi_it->prev_was_pdf = 0; + bidi_it->prev.type = bidi_it->prev.type_after_w1 = UNKNOWN_BT; + bidi_it->last_strong.type = bidi_it->last_strong.type_after_w1 = + bidi_it->last_strong.orig_type = UNKNOWN_BT; + bidi_it->next_for_neutral.charpos = -1; + bidi_it->next_for_neutral.type = + bidi_it->next_for_neutral.type_after_w1 = + bidi_it->next_for_neutral.orig_type = UNKNOWN_BT; + bidi_it->prev_for_neutral.charpos = -1; + bidi_it->prev_for_neutral.type = + bidi_it->prev_for_neutral.type_after_w1 = + bidi_it->prev_for_neutral.orig_type = UNKNOWN_BT; + bidi_it->sor = L2R; /* FIXME: should it be user-selectable? */ +} + +/* Push the current embedding level and override status; reset the + current level to LEVEL and the current override status to OVERRIDE. */ +static inline void +bidi_push_embedding_level (struct bidi_it *bidi_it, + int level, bidi_dir_t override) +{ + bidi_it->stack_idx++; + if (bidi_it->stack_idx >= BIDI_MAXLEVEL) + abort (); + bidi_it->level_stack[bidi_it->stack_idx].level = level; + bidi_it->level_stack[bidi_it->stack_idx].override = override; +} + +/* Pop the embedding level and directional override status from the + stack, and return the new level. */ +static inline int +bidi_pop_embedding_level (struct bidi_it *bidi_it) +{ + /* UAX#9 says to ignore invalid PDFs. */ + if (bidi_it->stack_idx > 0) + bidi_it->stack_idx--; + return bidi_it->level_stack[bidi_it->stack_idx].level; +} + +/* Record in SAVED_INFO the information about the current character. */ +static inline void +bidi_remember_char (struct bidi_saved_info *saved_info, + struct bidi_it *bidi_it) +{ + saved_info->charpos = bidi_it->charpos; + saved_info->bytepos = bidi_it->bytepos; + saved_info->type = bidi_it->type; + bidi_check_type (bidi_it->type); + saved_info->type_after_w1 = bidi_it->type_after_w1; + bidi_check_type (bidi_it->type_after_w1); + saved_info->orig_type = bidi_it->orig_type; + bidi_check_type (bidi_it->orig_type); +} + +/* Resolve the type of a neutral character according to the type of + surrounding strong text and the current embedding level. */ +static inline bidi_type_t +bidi_resolve_neutral_1 (bidi_type_t prev_type, bidi_type_t next_type, int lev) +{ + /* N1: European and Arabic numbers are treated as though they were R. */ + if (next_type == WEAK_EN || next_type == WEAK_AN) + next_type = STRONG_R; + if (prev_type == WEAK_EN || prev_type == WEAK_AN) + prev_type = STRONG_R; + + if (next_type == prev_type) /* N1 */ + return next_type; + else if ((lev & 1) == 0) /* N2 */ + return STRONG_L; + else + return STRONG_R; +} + +static inline int +bidi_explicit_dir_char (int c) +{ + /* FIXME: this should be replaced with a lookup table with suitable + bits set, like standard C ctype macros do. */ + return (c == LRE_CHAR || c == LRO_CHAR + || c == RLE_CHAR || c == RLO_CHAR || c == PDF_CHAR); +} + +/* A helper function for bidi_resolve_explicit. It advances to the + next character in logical order and determines the new embedding + level and directional override, but does not take into account + empty embeddings. */ +static int +bidi_resolve_explicit_1 (struct bidi_it *bidi_it) +{ + int curchar; + bidi_type_t type; + int current_level; + int new_level; + bidi_dir_t override; + + if (bidi_it->bytepos < BEGV_BYTE /* after reseat to BEGV? */ + || bidi_it->first_elt) + { + bidi_it->first_elt = 0; + if (bidi_it->charpos < BEGV) + bidi_it->charpos = BEGV; + bidi_it->bytepos = CHAR_TO_BYTE (bidi_it->charpos); + } + else if (bidi_it->bytepos < ZV_BYTE) /* don't move at ZV */ + { + bidi_it->charpos++; + if (bidi_it->ch_len == 0) + abort (); + bidi_it->bytepos += bidi_it->ch_len; + } + + current_level = bidi_it->level_stack[bidi_it->stack_idx].level; /* X1 */ + override = bidi_it->level_stack[bidi_it->stack_idx].override; + new_level = current_level; + + /* in case it is a unibyte character (not yet implemented) */ + /* _fetch_multibyte_char_len = 1; */ + if (bidi_it->bytepos >= ZV_BYTE) + { + curchar = BIDI_EOB; + bidi_it->ch_len = 1; + } + else + { + curchar = FETCH_CHAR (bidi_it->bytepos); + bidi_it->ch_len = CHAR_BYTES (curchar); + } + bidi_it->ch = curchar; + + /* Don't apply directional override here, as all the types we handle + below will not be affected by the override anyway, and we need + the original type unaltered. The override will be applied in + bidi_resolve_weak. */ + type = bidi_get_type (curchar, NEUTRAL_DIR); + bidi_it->orig_type = type; + bidi_check_type (bidi_it->orig_type); + + if (type != PDF) + bidi_it->prev_was_pdf = 0; + + bidi_it->type_after_w1 = UNKNOWN_BT; + + switch (type) + { + case RLE: /* X2 */ + case RLO: /* X4 */ + bidi_it->type_after_w1 = type; + bidi_check_type (bidi_it->type_after_w1); + type = WEAK_BN; /* X9/Retaining */ + if (bidi_it->ignore_bn_limit <= 0) + { + if (current_level <= BIDI_MAXLEVEL - 4) + { + /* Compute the least odd embedding level greater than + the current level. */ + new_level = ((current_level + 1) & ~1) + 1; + if (bidi_it->type_after_w1 == RLE) + override = NEUTRAL_DIR; + else + override = R2L; + if (current_level == BIDI_MAXLEVEL - 4) + bidi_it->invalid_rl_levels = 0; + bidi_push_embedding_level (bidi_it, new_level, override); + } + else + { + bidi_it->invalid_levels++; + /* See the commentary about invalid_rl_levels below. */ + if (bidi_it->invalid_rl_levels < 0) + bidi_it->invalid_rl_levels = 0; + bidi_it->invalid_rl_levels++; + } + } + else if (bidi_it->prev.type_after_w1 == WEAK_EN /* W5/Retaining */ + || bidi_it->next_en_pos > bidi_it->charpos) + type = WEAK_EN; + break; + case LRE: /* X3 */ + case LRO: /* X5 */ + bidi_it->type_after_w1 = type; + bidi_check_type (bidi_it->type_after_w1); + type = WEAK_BN; /* X9/Retaining */ + if (bidi_it->ignore_bn_limit <= 0) + { + if (current_level <= BIDI_MAXLEVEL - 5) + { + /* Compute the least even embedding level greater than + the current level. */ + new_level = ((current_level + 2) & ~1); + if (bidi_it->type_after_w1 == LRE) + override = NEUTRAL_DIR; + else + override = L2R; + bidi_push_embedding_level (bidi_it, new_level, override); + } + else + { + bidi_it->invalid_levels++; + /* invalid_rl_levels counts invalid levels encountered + while the embedding level was already too high for + LRE/LRO, but not for RLE/RLO. That is because + there may be exactly one PDF which we should not + ignore even though invalid_levels is non-zero. + invalid_rl_levels helps to know what PDF is + that. */ + if (bidi_it->invalid_rl_levels >= 0) + bidi_it->invalid_rl_levels++; + } + } + else if (bidi_it->prev.type_after_w1 == WEAK_EN /* W5/Retaining */ + || bidi_it->next_en_pos > bidi_it->charpos) + type = WEAK_EN; + break; + case PDF: /* X7 */ + bidi_it->type_after_w1 = type; + bidi_check_type (bidi_it->type_after_w1); + type = WEAK_BN; /* X9/Retaining */ + if (bidi_it->ignore_bn_limit <= 0) + { + if (!bidi_it->invalid_rl_levels) + { + new_level = bidi_pop_embedding_level (bidi_it); + bidi_it->invalid_rl_levels = -1; + if (bidi_it->invalid_levels) + bidi_it->invalid_levels--; + /* else nothing: UAX#9 says to ignore invalid PDFs */ + } + if (!bidi_it->invalid_levels) + new_level = bidi_pop_embedding_level (bidi_it); + else + { + bidi_it->invalid_levels--; + bidi_it->invalid_rl_levels--; + } + } + else if (bidi_it->prev.type_after_w1 == WEAK_EN /* W5/Retaining */ + || bidi_it->next_en_pos > bidi_it->charpos) + type = WEAK_EN; + break; + default: + /* Nothing. */ + break; + } + + bidi_it->type = type; + bidi_check_type (bidi_it->type); + + return new_level; +} + +/* Given an iterator state in BIDI_IT, advance one character position + in the buffer to the next character (in the logical order), resolve + any explicit embeddings and directional overrides, and return the + embedding level of the character after resolving explicit + directives and ignoring empty embeddings. */ +static int +bidi_resolve_explicit (struct bidi_it *bidi_it) +{ + int prev_level = bidi_it->level_stack[bidi_it->stack_idx].level; + int new_level = bidi_resolve_explicit_1 (bidi_it); + + if (prev_level < new_level + && bidi_it->type == WEAK_BN + && bidi_it->ignore_bn_limit == 0 /* only if not already known */ + && bidi_it->ch != BIDI_EOB /* not already at EOB */ + && bidi_explicit_dir_char (FETCH_CHAR (bidi_it->bytepos + + bidi_it->ch_len))) + { + /* Avoid pushing and popping embedding levels if the level run + is empty, as this breaks level runs where it shouldn't. + UAX#9 removes all the explicit embedding and override codes, + so empty embeddings disappear without a trace. We need to + behave as if we did the same. */ + struct bidi_it saved_it; + int level = prev_level; + + bidi_copy_it (&saved_it, bidi_it); + + while (bidi_explicit_dir_char (FETCH_CHAR (bidi_it->bytepos + + bidi_it->ch_len))) + { + level = bidi_resolve_explicit_1 (bidi_it); + } + + if (level == prev_level) /* empty embedding */ + saved_it.ignore_bn_limit = bidi_it->charpos + 1; + else /* this embedding is non-empty */ + saved_it.ignore_bn_limit = -1; + + bidi_copy_it (bidi_it, &saved_it); + if (bidi_it->ignore_bn_limit > 0) + { + /* We pushed a level, but we shouldn't have. Undo that. */ + if (!bidi_it->invalid_rl_levels) + { + new_level = bidi_pop_embedding_level (bidi_it); + bidi_it->invalid_rl_levels = -1; + if (bidi_it->invalid_levels) + bidi_it->invalid_levels--; + } + if (!bidi_it->invalid_levels) + new_level = bidi_pop_embedding_level (bidi_it); + else + { + bidi_it->invalid_levels--; + bidi_it->invalid_rl_levels--; + } + } + } + + if (bidi_it->type == NEUTRAL_B) /* X8 */ + { + bidi_set_paragraph_end (bidi_it); + /* This is needed by bidi_resolve_weak below, and in L1. */ + bidi_it->type_after_w1 = bidi_it->type; + bidi_check_type (bidi_it->type_after_w1); + } + + return new_level; +} + +/* Advance in the buffer, resolve weak types and return the type of + the next character after weak type resolution. */ +bidi_type_t +bidi_resolve_weak (struct bidi_it *bidi_it) +{ + bidi_type_t type; + bidi_dir_t override; + int prev_level = bidi_it->level_stack[bidi_it->stack_idx].level; + int new_level = bidi_resolve_explicit (bidi_it); + int next_char; + bidi_type_t type_of_next; + struct bidi_it saved_it; + + type = bidi_it->type; + override = bidi_it->level_stack[bidi_it->stack_idx].override; + + if (type == UNKNOWN_BT + || type == LRE + || type == LRO + || type == RLE + || type == RLO + || type == PDF) + abort (); + + if (new_level != prev_level + || bidi_it->type == NEUTRAL_B) + { + /* We've got a new embedding level run, compute the directional + type of sor and initialize per-run variables (UAX#9, clause + X10). */ + bidi_set_sor_type (bidi_it, prev_level, new_level); + } + else if (type == NEUTRAL_S || type == NEUTRAL_WS + || type == WEAK_BN || type == STRONG_AL) + bidi_it->type_after_w1 = type; /* needed in L1 */ + bidi_check_type (bidi_it->type_after_w1); + + /* Level and directional override status are already recorded in + bidi_it, and do not need any change; see X6. */ + if (override == R2L) /* X6 */ + type = STRONG_R; + else if (override == L2R) + type = STRONG_L; + else + { + if (type == WEAK_NSM) /* W1 */ + { + /* Note that we don't need to consider the case where the + prev character has its type overridden by an RLO or LRO: + such characters are outside the current level run, and + thus not relevant to this NSM. Thus, NSM gets the + orig_type of the previous character. */ + if (bidi_it->prev.type != UNKNOWN_BT) + type = bidi_it->prev.orig_type; + else if (bidi_it->sor == R2L) + type = STRONG_R; + else if (bidi_it->sor == L2R) + type = STRONG_L; + else /* shouldn't happen! */ + abort (); + } + if (type == WEAK_EN /* W2 */ + && bidi_it->last_strong.type_after_w1 == STRONG_AL) + type = WEAK_AN; + else if (type == STRONG_AL) /* W3 */ + type = STRONG_R; + else if ((type == WEAK_ES /* W4 */ + && bidi_it->prev.type_after_w1 == WEAK_EN + && bidi_it->prev.orig_type == WEAK_EN) + || (type == WEAK_CS + && ((bidi_it->prev.type_after_w1 == WEAK_EN + && bidi_it->prev.orig_type == WEAK_EN) + || bidi_it->prev.type_after_w1 == WEAK_AN))) + { + next_char = + bidi_it->bytepos + bidi_it->ch_len >= ZV_BYTE + ? BIDI_EOB : FETCH_CHAR (bidi_it->bytepos + bidi_it->ch_len); + type_of_next = bidi_get_type (next_char, override); + + if (type_of_next == WEAK_BN + || bidi_explicit_dir_char (next_char)) + { + bidi_copy_it (&saved_it, bidi_it); + while (bidi_resolve_explicit (bidi_it) == new_level + && bidi_it->type == WEAK_BN) + ; + type_of_next = bidi_it->type; + bidi_copy_it (bidi_it, &saved_it); + } + + /* If the next character is EN, but the last strong-type + character is AL, that next EN will be changed to AN when + we process it in W2 above. So in that case, this ES + should not be changed into EN. */ + if (type == WEAK_ES + && type_of_next == WEAK_EN + && bidi_it->last_strong.type_after_w1 != STRONG_AL) + type = WEAK_EN; + else if (type == WEAK_CS) + { + if (bidi_it->prev.type_after_w1 == WEAK_AN + && (type_of_next == WEAK_AN + /* If the next character is EN, but the last + strong-type character is AL, EN will be later + changed to AN when we process it in W2 above. + So in that case, this ES should not be + changed into EN. */ + || (type_of_next == WEAK_EN + && bidi_it->last_strong.type_after_w1 == STRONG_AL))) + type = WEAK_AN; + else if (bidi_it->prev.type_after_w1 == WEAK_EN + && type_of_next == WEAK_EN + && bidi_it->last_strong.type_after_w1 != STRONG_AL) + type = WEAK_EN; + } + } + else if (type == WEAK_ET /* W5: ET with EN before or after it */ + || type == WEAK_BN) /* W5/Retaining */ + { + if (bidi_it->prev.type_after_w1 == WEAK_EN /* ET/BN w/EN before it */ + || bidi_it->next_en_pos > bidi_it->charpos) + type = WEAK_EN; + else /* W5: ET/BN with EN after it. */ + { + EMACS_INT en_pos = bidi_it->charpos + 1; + + next_char = + bidi_it->bytepos + bidi_it->ch_len >= ZV_BYTE + ? BIDI_EOB : FETCH_CHAR (bidi_it->bytepos + bidi_it->ch_len); + type_of_next = bidi_get_type (next_char, override); + + if (type_of_next == WEAK_ET + || type_of_next == WEAK_BN + || bidi_explicit_dir_char (next_char)) + { + bidi_copy_it (&saved_it, bidi_it); + while (bidi_resolve_explicit (bidi_it) == new_level + && (bidi_it->type == WEAK_BN + || bidi_it->type == WEAK_ET)) + ; + type_of_next = bidi_it->type; + en_pos = bidi_it->charpos; + bidi_copy_it (bidi_it, &saved_it); + } + if (type_of_next == WEAK_EN) + { + /* If the last strong character is AL, the EN we've + found will become AN when we get to it (W2). */ + if (bidi_it->last_strong.type_after_w1 != STRONG_AL) + { + type = WEAK_EN; + /* Remember this EN position, to speed up processing + of the next ETs. */ + bidi_it->next_en_pos = en_pos; + } + else if (type == WEAK_BN) + type = NEUTRAL_ON; /* W6/Retaining */ + } + } + } + } + + if (type == WEAK_ES || type == WEAK_ET || type == WEAK_CS /* W6 */ + || (type == WEAK_BN + && (bidi_it->prev.type_after_w1 == WEAK_CS /* W6/Retaining */ + || bidi_it->prev.type_after_w1 == WEAK_ES + || bidi_it->prev.type_after_w1 == WEAK_ET))) + type = NEUTRAL_ON; + + /* Store the type we've got so far, before we clobber it with strong + types in W7 and while resolving neutral types. But leave alone + the original types that were recorded above, because we will need + them for the L1 clause. */ + if (bidi_it->type_after_w1 == UNKNOWN_BT) + bidi_it->type_after_w1 = type; + bidi_check_type (bidi_it->type_after_w1); + + if (type == WEAK_EN) /* W7 */ + { + if ((bidi_it->last_strong.type_after_w1 == STRONG_L) + || (bidi_it->last_strong.type == UNKNOWN_BT && bidi_it->sor == L2R)) + type = STRONG_L; + } + + bidi_it->type = type; + bidi_check_type (bidi_it->type); + return type; +} + +bidi_type_t +bidi_resolve_neutral (struct bidi_it *bidi_it) +{ + int prev_level = bidi_it->level_stack[bidi_it->stack_idx].level; + bidi_type_t type = bidi_resolve_weak (bidi_it); + int current_level = bidi_it->level_stack[bidi_it->stack_idx].level; + + if (!(type == STRONG_R + || type == STRONG_L + || type == WEAK_BN + || type == WEAK_EN + || type == WEAK_AN + || type == NEUTRAL_B + || type == NEUTRAL_S + || type == NEUTRAL_WS + || type == NEUTRAL_ON)) + abort (); + + if (bidi_get_category (type) == NEUTRAL + || (type == WEAK_BN && prev_level == current_level)) + { + if (bidi_it->next_for_neutral.type != UNKNOWN_BT) + type = bidi_resolve_neutral_1 (bidi_it->prev_for_neutral.type, + bidi_it->next_for_neutral.type, + current_level); + else + { + /* Arrrgh!! The UAX#9 algorithm is too deeply entrenched in + the assumption of batch-style processing; see clauses W4, + W5, and especially N1, which require to look far forward + (as well as back) in the buffer. May the fleas of a + thousand camels infest the armpits of those who design + supposedly general-purpose algorithms by looking at their + own implementations, and fail to consider other possible + implementations! */ + struct bidi_it saved_it; + bidi_type_t next_type; + + if (bidi_it->scan_dir == -1) + abort (); + + bidi_copy_it (&saved_it, bidi_it); + /* Scan the text forward until we find the first non-neutral + character, and then use that to resolve the neutral we + are dealing with now. We also cache the scanned iterator + states, to salvage some of the effort later. */ + bidi_cache_iterator_state (bidi_it, 0); + do { + /* Record the info about the previous character, so that + it will be cached below with this state. */ + if (bidi_it->type_after_w1 != WEAK_BN /* W1/Retaining */ + && bidi_it->type != WEAK_BN) + bidi_remember_char (&bidi_it->prev, bidi_it); + type = bidi_resolve_weak (bidi_it); + /* Paragraph separators have their levels fully resolved + at this point, so cache them as resolved. */ + bidi_cache_iterator_state (bidi_it, type == NEUTRAL_B); + /* FIXME: implement L1 here, by testing for a newline and + resetting the level for any sequence of whitespace + characters adjacent to it. */ + } while (!(type == NEUTRAL_B + || (type != WEAK_BN + && bidi_get_category (type) != NEUTRAL) + /* This is all per level run, so stop when we + reach the end of this level run. */ + || bidi_it->level_stack[bidi_it->stack_idx].level != + current_level)); + + bidi_remember_char (&saved_it.next_for_neutral, bidi_it); + + switch (type) + { + case STRONG_L: + case STRONG_R: + case STRONG_AL: + next_type = type; + break; + case WEAK_EN: + case WEAK_AN: + /* N1: ``European and Arabic numbers are treated as + though they were R.'' */ + next_type = STRONG_R; + saved_it.next_for_neutral.type = STRONG_R; + break; + case WEAK_BN: + if (!bidi_explicit_dir_char (bidi_it->ch)) + abort (); /* can't happen: BNs are skipped */ + /* FALLTHROUGH */ + case NEUTRAL_B: + /* Marched all the way to the end of this level run. + We need to use the eor type, whose information is + stored by bidi_set_sor_type in the prev_for_neutral + member. */ + if (saved_it.type != WEAK_BN + || bidi_get_category (bidi_it->prev.type_after_w1) == NEUTRAL) + { + next_type = bidi_it->prev_for_neutral.type; + saved_it.next_for_neutral.type = next_type; + bidi_check_type (next_type); + } + else + { + /* This is a BN which does not adjoin neutrals. + Leave its type alone. */ + bidi_copy_it (bidi_it, &saved_it); + return bidi_it->type; + } + break; + default: + abort (); + } + type = bidi_resolve_neutral_1 (saved_it.prev_for_neutral.type, + next_type, current_level); + saved_it.type = type; + bidi_check_type (type); + bidi_copy_it (bidi_it, &saved_it); + } + } + return type; +} + +/* Given an iterator state in BIDI_IT, advance one character position + in the buffer to the next character (in the logical order), resolve + the bidi type of that next character, and return that type. */ +bidi_type_t +bidi_type_of_next_char (struct bidi_it *bidi_it) +{ + bidi_type_t type; + + /* This should always be called during a forward scan. */ + if (bidi_it->scan_dir != 1) + abort (); + + /* Reset the limit until which to ignore BNs if we step out of the + area where we found only empty levels. */ + if ((bidi_it->ignore_bn_limit > 0 + && bidi_it->ignore_bn_limit <= bidi_it->charpos) + || (bidi_it->ignore_bn_limit == -1 + && !bidi_explicit_dir_char (bidi_it->ch))) + bidi_it->ignore_bn_limit = 0; + + type = bidi_resolve_neutral (bidi_it); + + return type; +} + +/* Given an iterator state BIDI_IT, advance one character position in + the buffer to the next character (in the logical order), resolve + the embedding and implicit levels of that next character, and + return the resulting level. */ +int +bidi_level_of_next_char (struct bidi_it *bidi_it) +{ + bidi_type_t type; + int level, prev_level = -1; + struct bidi_saved_info next_for_neutral; + + if (bidi_it->scan_dir == 1) + { + /* There's no sense in trying to advance if we hit end of text. */ + if (bidi_it->ch == BIDI_EOB) + return bidi_it->resolved_level; + + /* Record the info about the previous character. */ + if (bidi_it->type_after_w1 != WEAK_BN /* W1/Retaining */ + && bidi_it->type != WEAK_BN) + bidi_remember_char (&bidi_it->prev, bidi_it); + if (bidi_it->type_after_w1 == STRONG_R + || bidi_it->type_after_w1 == STRONG_L + || bidi_it->type_after_w1 == STRONG_AL) + bidi_remember_char (&bidi_it->last_strong, bidi_it); + /* FIXME: it sounds like we don't need both prev and + prev_for_neutral members, but I'm leaving them both for now. */ + if (bidi_it->type == STRONG_R || bidi_it->type == STRONG_L + || bidi_it->type == WEAK_EN || bidi_it->type == WEAK_AN) + bidi_remember_char (&bidi_it->prev_for_neutral, bidi_it); + + /* If we overstepped the characters used for resolving neutrals + and whitespace, invalidate their info in the iterator. */ + if (bidi_it->charpos >= bidi_it->next_for_neutral.charpos) + bidi_it->next_for_neutral.type = UNKNOWN_BT; + if (bidi_it->next_en_pos >= 0 + && bidi_it->charpos >= bidi_it->next_en_pos) + bidi_it->next_en_pos = -1; + if (bidi_it->next_for_ws.type != UNKNOWN_BT + && bidi_it->charpos >= bidi_it->next_for_ws.charpos) + bidi_it->next_for_ws.type = UNKNOWN_BT; + + /* This must be taken before we fill the iterator with the info + about the next char. If we scan backwards, the iterator + state must be already cached, so there's no need to know the + embedding level of the previous character, since we will be + returning to our caller shortly. */ + prev_level = bidi_it->level_stack[bidi_it->stack_idx].level; + } + next_for_neutral = bidi_it->next_for_neutral; + + /* Perhaps it is already cached. */ + type = bidi_cache_find (bidi_it->charpos + bidi_it->scan_dir, -1, bidi_it); + if (type != UNKNOWN_BT) + { + /* Don't lose the information for resolving neutrals! The + cached states could have been cached before their + next_for_neutral member was computed. If we are on our way + forward, we can simply take the info from the previous + state. */ + if (bidi_it->scan_dir == 1 + && bidi_it->next_for_neutral.type == UNKNOWN_BT) + bidi_it->next_for_neutral = next_for_neutral; + + /* If resolved_level is -1, it means this state was cached + before it was completely resolved, so we cannot return + it. */ + if (bidi_it->resolved_level != -1) + return bidi_it->resolved_level; + } + if (bidi_it->scan_dir == -1) + /* If we are going backwards, the iterator state is already cached + from previous scans, and should be fully resolved. */ + abort (); + + if (type == UNKNOWN_BT) + type = bidi_type_of_next_char (bidi_it); + + if (type == NEUTRAL_B) + return bidi_it->resolved_level; + + level = bidi_it->level_stack[bidi_it->stack_idx].level; + if ((bidi_get_category (type) == NEUTRAL /* && type != NEUTRAL_B */) + || (type == WEAK_BN && prev_level == level)) + { + if (bidi_it->next_for_neutral.type == UNKNOWN_BT) + abort (); + + /* If the cached state shows a neutral character, it was not + resolved by bidi_resolve_neutral, so do it now. */ + type = bidi_resolve_neutral_1 (bidi_it->prev_for_neutral.type, + bidi_it->next_for_neutral.type, + level); + } + + if (!(type == STRONG_R + || type == STRONG_L + || type == WEAK_BN + || type == WEAK_EN + || type == WEAK_AN)) + abort (); + bidi_it->type = type; + bidi_check_type (bidi_it->type); + + /* For L1 below, we need to know, for each WS character, whether + it belongs to a sequence of WS characters preceeding a newline + or a TAB or a paragraph separator. */ + if (bidi_it->orig_type == NEUTRAL_WS + && bidi_it->next_for_ws.type == UNKNOWN_BT) + { + int ch; + int clen = bidi_it->ch_len; + EMACS_INT bpos = bidi_it->bytepos; + EMACS_INT cpos = bidi_it->charpos; + bidi_type_t chtype; + + do { + /*_fetch_multibyte_char_len = 1;*/ + ch = bpos + clen >= ZV_BYTE ? BIDI_EOB : FETCH_CHAR (bpos + clen); + bpos += clen; + cpos++; + clen = (ch == BIDI_EOB ? 1 : CHAR_BYTES (ch)); + if (ch == '\n' || ch == BIDI_EOB /* || ch == LINESEP_CHAR */) + chtype = NEUTRAL_B; + else + chtype = bidi_get_type (ch, NEUTRAL_DIR); + } while (chtype == NEUTRAL_WS || chtype == WEAK_BN + || bidi_explicit_dir_char (ch)); /* L1/Retaining */ + bidi_it->next_for_ws.type = chtype; + bidi_check_type (bidi_it->next_for_ws.type); + bidi_it->next_for_ws.charpos = cpos; + bidi_it->next_for_ws.bytepos = bpos; + } + + /* Resolve implicit levels, with a twist: PDFs get the embedding + level of the enbedding they terminate. See below for the + reason. */ + if (bidi_it->orig_type == PDF + /* Don't do this if this formatting code didn't change the + embedding level due to invalid or empty embeddings. */ + && prev_level != level) + { + /* Don't look in UAX#9 for the reason for this: it's our own + private quirk. The reason is that we want the formatting + codes to be delivered so that they bracket the text of their + embedding. For example, given the text + + {RLO}teST{PDF} + + we want it to be displayed as + + {RLO}STet{PDF} + + not as + + STet{RLO}{PDF} + + which will result because we bump up the embedding level as + soon as we see the RLO and pop it as soon as we see the PDF, + so RLO itself has the same embedding level as "teST", and + thus would be normally delivered last, just before the PDF. + The switch below fiddles with the level of PDF so that this + ugly side effect does not happen. + + (This is, of course, only important if the formatting codes + are actually displayed, but Emacs does need to display them + if the user wants to.) */ + level = prev_level; + } + else if (bidi_it->orig_type == NEUTRAL_B /* L1 */ + || bidi_it->orig_type == NEUTRAL_S + || bidi_it->ch == '\n' || bidi_it->ch == BIDI_EOB + /* || bidi_it->ch == LINESEP_CHAR */ + || (bidi_it->orig_type == NEUTRAL_WS + && (bidi_it->next_for_ws.type == NEUTRAL_B + || bidi_it->next_for_ws.type == NEUTRAL_S))) + level = bidi_it->level_stack[0].level; + else if ((level & 1) == 0) /* I1 */ + { + if (type == STRONG_R) + level++; + else if (type == WEAK_EN || type == WEAK_AN) + level += 2; + } + else /* I2 */ + { + if (type == STRONG_L || type == WEAK_EN || type == WEAK_AN) + level++; + } + + bidi_it->resolved_level = level; + return level; +} + +/* Move to the other edge of a level given by LEVEL. If END_FLAG is + non-zero, we are at the end of a level, and we need to prepare to + resume the scan of the lower level. + + If this level's other edge is cached, we simply jump to it, filling + the iterator structure with the iterator state on the other edge. + Otherwise, we walk the buffer until we come back to the same level + as LEVEL. + + Note: we are not talking here about a ``level run'' in the UAX#9 + sense of the term, but rather about a ``level'' which includes + all the levels higher than it. In other words, given the levels + like this: + + 11111112222222333333334443343222222111111112223322111 + A B C + + and assuming we are at point A scanning left to right, this + function moves to point C, whereas the UAX#9 ``level 2 run'' ends + at point B. */ +static void +bidi_find_other_level_edge (struct bidi_it *bidi_it, int level, int end_flag) +{ + int dir = end_flag ? -bidi_it->scan_dir : bidi_it->scan_dir; + int idx; + + /* Try the cache first. */ + if ((idx = bidi_cache_find_level_change (level, dir, end_flag)) >= 0) + bidi_cache_fetch_state (idx, bidi_it); + else + { + int new_level; + + if (end_flag) + abort (); /* if we are at end of level, its edges must be cached */ + + bidi_cache_iterator_state (bidi_it, 1); + do { + new_level = bidi_level_of_next_char (bidi_it); + bidi_cache_iterator_state (bidi_it, 1); + } while (new_level >= level); + } +} + +void +bidi_get_next_char_visually (struct bidi_it *bidi_it) +{ + int old_level, new_level, next_level; + struct bidi_it sentinel; + + if (bidi_it->scan_dir == 0) + { + bidi_it->scan_dir = 1; /* default to logical order */ + } + + /* If we just passed a newline, initialize for the next line. */ + if (!bidi_it->first_elt && bidi_it->orig_type == NEUTRAL_B) + bidi_line_init (bidi_it); + + /* Prepare the sentinel iterator state. */ + if (bidi_cache_idx == 0) + { + bidi_copy_it (&sentinel, bidi_it); + if (bidi_it->first_elt) + { + sentinel.charpos--; /* cached charpos needs to be monotonic */ + sentinel.bytepos--; + sentinel.ch = '\n'; /* doesn't matter, but why not? */ + sentinel.ch_len = 1; + } + } + + old_level = bidi_it->resolved_level; + new_level = bidi_level_of_next_char (bidi_it); + + /* Reordering of resolved levels (clause L2) is implemented by + jumping to the other edge of the level and flipping direction of + scanning the text whenever we find a level change. */ + if (new_level != old_level) + { + int ascending = new_level > old_level; + int level_to_search = ascending ? old_level + 1 : old_level; + int incr = ascending ? 1 : -1; + int expected_next_level = old_level + incr; + + /* If we don't have anything cached yet, we need to cache the + sentinel state, since we'll need it to record where to jump + when the last non-base level is exhausted. */ + if (bidi_cache_idx == 0) + bidi_cache_iterator_state (&sentinel, 1); + /* Jump (or walk) to the other edge of this level. */ + bidi_find_other_level_edge (bidi_it, level_to_search, !ascending); + /* Switch scan direction and peek at the next character in the + new direction. */ + bidi_it->scan_dir = -bidi_it->scan_dir; + + /* The following loop handles the case where the resolved level + jumps by more than one. This is typical for numbers inside a + run of text with left-to-right embedding direction, but can + also happen in other situations. In those cases the decision + where to continue after a level change, and in what direction, + is tricky. For example, given a text like below: + + abcdefgh + 11336622 + + (where the numbers below the text show the resolved levels), + the result of reordering according to UAX#9 should be this: + + efdcghba + + This is implemented by the loop below which flips direction + and jumps to the other edge of the level each time it finds + the new level not to be the expected one. The expected level + is always one more or one less than the previous one. */ + next_level = bidi_peek_at_next_level (bidi_it); + while (next_level != expected_next_level) + { + expected_next_level += incr; + level_to_search += incr; + bidi_find_other_level_edge (bidi_it, level_to_search, !ascending); + bidi_it->scan_dir = -bidi_it->scan_dir; + next_level = bidi_peek_at_next_level (bidi_it); + } + + /* Finally, deliver the next character in the new direction. */ + next_level = bidi_level_of_next_char (bidi_it); + } + + /* Take note when we have just processed the newline that precedes + the end of the paragraph. The next time we are about to be + called, set_iterator_to_next will automatically reinit the + paragraph direction, if needed. We do this at the newline before + the paragraph separator, because the next character might not be + the first character of the next paragraph, due to the bidi + reordering, whereas we _must_ know the paragraph base direction + _before_ we process the paragraph's text, since the base + direction affects the reordering. */ + if (bidi_it->scan_dir == 1 + && bidi_it->orig_type == NEUTRAL_B + && bidi_it->bytepos < ZV_BYTE) + { + EMACS_INT sep_len = + bidi_at_paragraph_end (bidi_it->charpos + 1, + bidi_it->bytepos + bidi_it->ch_len); + if (sep_len >= 0) + { + bidi_it->new_paragraph = 1; + /* Record the buffer position of the last character of the + paragraph separator. */ + bidi_it->separator_limit = bidi_it->charpos + 1 + sep_len; + } + } + + if (bidi_it->scan_dir == 1 && bidi_cache_idx) + { + /* If we are at paragraph's base embedding level and beyond the + last cached position, the cache's job is done and we can + discard it. */ + if (bidi_it->resolved_level == bidi_it->level_stack[0].level + && bidi_it->charpos > bidi_cache[bidi_cache_idx - 1].charpos) + bidi_cache_reset (); + /* But as long as we are caching during forward scan, we must + cache each state, or else the cache integrity will be + compromised: it assumes cached states correspond to buffer + positions 1:1. */ + else + bidi_cache_iterator_state (bidi_it, 1); + } +} + +/* This is meant to be called from within the debugger, whenever you + wish to examine the cache contents. */ +void +bidi_dump_cached_states (void) +{ + int i; + int ndigits = 1; + + if (bidi_cache_idx == 0) + { + fprintf (stderr, "The cache is empty.\n"); + return; + } + fprintf (stderr, "Total of %d state%s in cache:\n", + bidi_cache_idx, bidi_cache_idx == 1 ? "" : "s"); + + for (i = bidi_cache[bidi_cache_idx - 1].charpos; i > 0; i /= 10) + ndigits++; + fputs ("ch ", stderr); + for (i = 0; i < bidi_cache_idx; i++) + fprintf (stderr, "%*c", ndigits, bidi_cache[i].ch); + fputs ("\n", stderr); + fputs ("lvl ", stderr); + for (i = 0; i < bidi_cache_idx; i++) + fprintf (stderr, "%*d", ndigits, bidi_cache[i].resolved_level); + fputs ("\n", stderr); + fputs ("pos ", stderr); + for (i = 0; i < bidi_cache_idx; i++) + fprintf (stderr, "%*d", ndigits, bidi_cache[i].charpos); + fputs ("\n", stderr); +} diff -r 86c85c80cd84 -r 5a619d0a9158 src/buffer.c --- a/src/buffer.c Mon Mar 29 14:00:56 2010 +0000 +++ b/src/buffer.c Thu Apr 01 14:34:20 2010 +0000 @@ -2279,6 +2279,8 @@ swapfield (undo_list, Lisp_Object); swapfield (mark, Lisp_Object); swapfield (enable_multibyte_characters, Lisp_Object); + swapfield (bidi_display_reordering, Lisp_Object); + swapfield (bidi_paragraph_direction, Lisp_Object); /* FIXME: Not sure what we should do with these *_marker fields. Hopefully they're just nil anyway. */ swapfield (pt_marker, Lisp_Object); @@ -5206,7 +5208,9 @@ buffer_defaults.truncate_lines = Qnil; buffer_defaults.word_wrap = Qnil; buffer_defaults.ctl_arrow = Qt; + buffer_defaults.bidi_display_reordering = Qnil; buffer_defaults.direction_reversed = Qnil; + buffer_defaults.bidi_paragraph_direction = Qnil; buffer_defaults.cursor_type = Qt; buffer_defaults.extra_line_spacing = Qnil; buffer_defaults.cursor_in_non_selected_windows = Qt; @@ -5291,7 +5295,9 @@ XSETFASTINT (buffer_local_flags.syntax_table, idx); ++idx; XSETFASTINT (buffer_local_flags.cache_long_line_scans, idx); ++idx; XSETFASTINT (buffer_local_flags.category_table, idx); ++idx; + XSETFASTINT (buffer_local_flags.bidi_display_reordering, idx); ++idx; XSETFASTINT (buffer_local_flags.direction_reversed, idx); ++idx; + XSETFASTINT (buffer_local_flags.bidi_paragraph_direction, idx); ++idx; XSETFASTINT (buffer_local_flags.buffer_file_coding_system, idx); /* Make this one a permanent local. */ buffer_permanent_local_flags[idx++] = 1; @@ -5548,11 +5554,6 @@ doc: /* Default value of `ctl-arrow' for buffers that do not override it. This is the same as (default-value 'ctl-arrow). */); - DEFVAR_LISP_NOPRO ("default-direction-reversed", - &buffer_defaults.direction_reversed, - doc: /* Default value of `direction-reversed' for buffers that do not override it. -This is the same as (default-value 'direction-reversed). */); - DEFVAR_LISP_NOPRO ("default-enable-multibyte-characters", &buffer_defaults.enable_multibyte_characters, doc: /* *Default value of `enable-multibyte-characters' for buffers not overriding it. @@ -5809,11 +5810,29 @@ This variable is never applied to a way of decoding a file while reading it. */); - DEFVAR_PER_BUFFER ("direction-reversed", ¤t_buffer->direction_reversed, - Qnil, - doc: /* *Non-nil means lines in the buffer are displayed right to left. */); - - DEFVAR_PER_BUFFER ("truncate-lines", ¤t_buffer->truncate_lines, Qnil, + DEFVAR_PER_BUFFER ("direction-reversed", + ¤t_buffer->direction_reversed, Qnil, + doc: /* Non-nil means set beginning of lines at the right edge of the window. +See also the variable `bidi-display-reordering'. */); + + DEFVAR_PER_BUFFER ("bidi-display-reordering", + ¤t_buffer->bidi_display_reordering, Qnil, + doc: /* Non-nil means reorder bidirectional text for display in the visual order. +See also the variable `direction-reversed'. */); + + DEFVAR_PER_BUFFER ("bidi-paragraph-direction", + ¤t_buffer->bidi_paragraph_direction, Qnil, + doc: /* *If non-nil, forces directionality of text paragraphs in the buffer. + +If this is nil (the default), the direction of each paragraph is +determined by the first strong directional character of its text. +The values of `right-to-left' and `left-to-right' override that. +Any other value is treated as nil. + +This variable has no effect unless the buffer's value of +\`bidi-display-reordering' is non-nil. */); + + DEFVAR_PER_BUFFER ("truncate-lines", ¤t_buffer->truncate_lines, Qnil, doc: /* *Non-nil means do not display continuation lines. Instead, give each line of text just one screen line. diff -r 86c85c80cd84 -r 5a619d0a9158 src/buffer.h --- a/src/buffer.h Mon Mar 29 14:00:56 2010 +0000 +++ b/src/buffer.h Thu Apr 01 14:34:20 2010 +0000 @@ -662,8 +662,16 @@ Lisp_Object word_wrap; /* Non-nil means display ctl chars with uparrow. */ Lisp_Object ctl_arrow; - /* Non-nil means display text from right to left. */ + /* Non-nil means reorder bidirectional text for display in the + visual order. */ + Lisp_Object bidi_display_reordering; + /* Non-nil means set beginning of lines at the right edge of + windows. */ Lisp_Object direction_reversed; + /* If non-nil, specifies which direction of text to force in all the + paragraphs of the buffer. Nil means determine paragraph + direction dynamically for each paragraph. */ + Lisp_Object bidi_paragraph_direction; /* Non-nil means do selective display; see doc string in syms_of_buffer (buffer.c) for details. */ Lisp_Object selective_display; diff -r 86c85c80cd84 -r 5a619d0a9158 src/cmds.c --- a/src/cmds.c Mon Mar 29 14:00:56 2010 +0000 +++ b/src/cmds.c Thu Apr 01 14:34:20 2010 +0000 @@ -317,7 +317,7 @@ return value; } -int nonundocount; +static int nonundocount; /* Note that there's code in command_loop_1 which typically avoids calling this. */ diff -r 86c85c80cd84 -r 5a619d0a9158 src/dispextern.h --- a/src/dispextern.h Mon Mar 29 14:00:56 2010 +0000 +++ b/src/dispextern.h Thu Apr 01 14:34:20 2010 +0000 @@ -370,6 +370,16 @@ /* Non-zero means don't display cursor here. */ unsigned avoid_cursor_p : 1; + /* Resolved bidirectional level of this character [0..63]. */ + unsigned resolved_level : 5; + + /* Resolved bidirectional type of this character, see enum + bidi_type_t below. Note that according to UAX#9, only some + values (STRONG_L, STRONG_R, WEAK_AN, WEAK_EN, WEAK_BN, and + NEUTRAL_B) can appear in the resolved type, so we only reserve + space for those that can. */ + unsigned bidi_type : 3; + #define FACE_ID_BITS 20 /* Face of the glyph. This is a realized face ID, @@ -739,14 +749,18 @@ /* First position in this row. This is the text position, including overlay position information etc, where the display of this row started, and can thus be less the position of the first glyph - (e.g. due to invisible text or horizontal scrolling). */ + (e.g. due to invisible text or horizontal scrolling). BIDI Note: + This is the smallest character position in the row, but not + necessarily the character that is the leftmost on the display. */ struct display_pos start; /* Text position at the end of this row. This is the position after the last glyph on this row. It can be greater than the last glyph position + 1, due to truncation, invisible text etc. In an up-to-date display, this should always be equal to the start - position of the next row. */ + position of the next row. BIDI Note: this is the character whose + buffer position is the largest, but not necessarily the rightmost + one on the display. */ struct display_pos end; /* Non-zero means the overlay arrow bitmap is on this line. @@ -872,6 +886,10 @@ the bottom line of the window, but not end of the buffer. */ unsigned indicate_bottom_line_p : 1; + /* Non-zero means the row was reversed to display text in a + right-to-left paragraph. */ + unsigned reversed_p : 1; + /* Continuation lines width at the start of the row. */ int continuation_lines_width; @@ -924,12 +942,18 @@ (MATRIX_ROW ((MATRIX), (ROW))->used[TEXT_AREA]) /* Return the character/ byte position at which the display of ROW - starts. */ + starts. BIDI Note: this is the smallest character/byte position + among characters in ROW, i.e. the first logical-order character + displayed by ROW, which is not necessarily the smallest horizontal + position. */ #define MATRIX_ROW_START_CHARPOS(ROW) ((ROW)->start.pos.charpos) #define MATRIX_ROW_START_BYTEPOS(ROW) ((ROW)->start.pos.bytepos) -/* Return the character/ byte position at which ROW ends. */ +/* Return the character/ byte position at which ROW ends. BIDI Note: + this is the largest character/byte position among characters in + ROW, i.e. the last logical-order character displayed by ROW, which + is not necessarily the largest horizontal position. */ #define MATRIX_ROW_END_CHARPOS(ROW) ((ROW)->end.pos.charpos) #define MATRIX_ROW_END_BYTEPOS(ROW) ((ROW)->end.pos.bytepos) @@ -1078,17 +1102,9 @@ extern int display_completed; -/* Non-zero means redisplay has been performed directly (see also - direct_output_for_insert and direct_output_forward_char), so that - no further updating has to be performed. The function - redisplay_internal checks this flag, and does nothing but reset it - to zero if it is non-zero. */ - -extern int redisplay_performed_directly_p; - /* A temporary storage area, including a row of glyphs. Initialized in xdisp.c. Used for various purposes, as an example see - direct_output_for_insert. */ + get_overlay_arrow_glyph_row. */ extern struct glyph_row scratch_glyph_row; @@ -1702,7 +1718,93 @@ extern int face_change_count; - +/* For reordering of bidirectional text. */ +#define BIDI_MAXLEVEL 64 + +/* Data type for describing the bidirectional character types. The + first 7 must be at the beginning, because they are the only values + valid in the `bidi_type' member of `struct glyph'; we only reserve + 3 bits for it, so we cannot use there values larger than 7. */ +typedef enum { + UNKNOWN_BT = 0, + STRONG_L, /* strong left-to-right */ + STRONG_R, /* strong right-to-left */ + WEAK_EN, /* european number */ + WEAK_AN, /* arabic number */ + WEAK_BN, /* boundary neutral */ + NEUTRAL_B, /* paragraph separator */ + STRONG_AL, /* arabic right-to-left letter */ + LRE, /* left-to-right embedding */ + LRO, /* left-to-right override */ + RLE, /* right-to-left embedding */ + RLO, /* right-to-left override */ + PDF, /* pop directional format */ + WEAK_ES, /* european number separator */ + WEAK_ET, /* european number terminator */ + WEAK_CS, /* common separator */ + WEAK_NSM, /* non-spacing mark */ + NEUTRAL_S, /* segment separator */ + NEUTRAL_WS, /* whitespace */ + NEUTRAL_ON /* other neutrals */ +} bidi_type_t; + +/* The basic directionality data type. */ +typedef enum { NEUTRAL_DIR, L2R, R2L } bidi_dir_t; + +/* Data type for storing information about characters we need to + remember. */ +struct bidi_saved_info { + int bytepos, charpos; /* character's buffer position */ + bidi_type_t type; /* character's resolved bidi type */ + bidi_type_t type_after_w1; /* original type of the character, after W1 */ + bidi_type_t orig_type; /* type as we found it in the buffer */ +}; + +/* Data type for keeping track of saved embedding levels and override + status information. */ +struct bidi_stack { + int level; + bidi_dir_t override; +}; + +/* Data type for iterating over bidi text. */ +struct bidi_it { + EMACS_INT bytepos; /* iterator's position in buffer */ + EMACS_INT charpos; + int ch; /* character itself */ + int ch_len; /* length of its multibyte sequence */ + bidi_type_t type; /* bidi type of this character, after + resolving weak and neutral types */ + bidi_type_t type_after_w1; /* original type, after overrides and W1 */ + bidi_type_t orig_type; /* original type, as found in the buffer */ + int resolved_level; /* final resolved level of this character */ + int invalid_levels; /* how many PDFs to ignore */ + int invalid_rl_levels; /* how many PDFs from RLE/RLO to ignore */ + int prev_was_pdf; /* if non-zero, previous char was PDF */ + struct bidi_saved_info prev; /* info about previous character */ + struct bidi_saved_info last_strong; /* last-seen strong directional char */ + struct bidi_saved_info next_for_neutral; /* surrounding characters for... */ + struct bidi_saved_info prev_for_neutral; /* ...resolving neutrals */ + struct bidi_saved_info next_for_ws; /* character after sequence of ws */ + EMACS_INT next_en_pos; /* position of next EN char for ET */ + EMACS_INT ignore_bn_limit; /* position until which to ignore BNs */ + bidi_dir_t sor; /* direction of start-of-run in effect */ + int scan_dir; /* direction of text scan */ + int stack_idx; /* index of current data on the stack */ + /* Note: Everything from here on is not copied/saved when the bidi + iterator state is saved, pushed, or popped. So only put here + stuff that is not part of the bidi iterator's state! */ + struct bidi_stack level_stack[BIDI_MAXLEVEL]; /* stack of embedding levels */ + int first_elt; /* if non-zero, examine current char first */ + bidi_dir_t paragraph_dir; /* current paragraph direction */ + int new_paragraph; /* if non-zero, we expect a new paragraph */ + EMACS_INT separator_limit; /* where paragraph separator should end */ +}; + +/* Value is non-zero when the bidi iterator is at base paragraph + embedding level. */ +#define BIDI_AT_BASE_LEVEL(BIDI_IT) \ + ((BIDI_IT).resolved_level == (BIDI_IT).level_stack[0].level) /*********************************************************************** @@ -1854,7 +1956,7 @@ NUM_IT_METHODS }; -#define IT_STACK_SIZE 4 +#define IT_STACK_SIZE 5 /* Iterator for composition (both for static and automatic). */ struct composition_it @@ -1902,6 +2004,14 @@ text, overlay strings, end of text etc., which see. */ EMACS_INT stop_charpos; + /* Previous stop position, i.e. the last one before the current + iterator position in `current'. */ + EMACS_INT prev_stop; + + /* Last stop position iterated across whose bidi embedding level is + equal to the current paragraph's base embedding level. */ + EMACS_INT base_level_stop; + /* Maximum string or buffer position + 1. ZV when iterating over current_buffer. */ EMACS_INT end_charpos; @@ -2008,6 +2118,8 @@ int string_nchars; EMACS_INT end_charpos; EMACS_INT stop_charpos; + EMACS_INT prev_stop; + EMACS_INT base_level_stop; struct composition_it cmp_it; int face_id; @@ -2207,6 +2319,14 @@ incremented/reset by display_line, move_it_to etc. */ int continuation_lines_width; + /* Buffer position that ends the buffer text line being iterated. + This is normally the position after the newline at EOL. If this + is the last line of the buffer and it doesn't have a newline, + value is ZV/ZV_BYTE. Set and used only if IT->bidi_p, for + setting the end position of glyph rows produced for continuation + lines, see display_line. */ + struct text_pos eol_pos; + /* Current y-position. Automatically incremented by the height of glyph_row in move_it_to and display_line. */ int current_y; @@ -2233,6 +2353,14 @@ /* Face of the right fringe glyph. */ unsigned right_user_fringe_face_id : FACE_ID_BITS; + + /* Non-zero means we need to reorder bidirectional text for display + in the visual order. */ + int bidi_p; + + /* For iterating over bidirectional text. */ + struct bidi_it bidi_it; + bidi_dir_t paragraph_embedding; }; @@ -2263,6 +2391,13 @@ #define PRODUCE_GLYPHS(IT) \ do { \ extern int inhibit_free_realized_faces; \ + if ((IT)->glyph_row != NULL && (IT)->bidi_p) \ + { \ + if ((IT)->bidi_it.paragraph_dir == R2L) \ + (IT)->glyph_row->reversed_p = 1; \ + else \ + (IT)->glyph_row->reversed_p = 0; \ + } \ if (FRAME_RIF ((IT)->f) != NULL) \ FRAME_RIF ((IT)->f)->produce_glyphs ((IT)); \ else \ @@ -2704,12 +2839,20 @@ Function Prototypes ***********************************************************************/ +/* Defined in bidi.c */ + +extern void bidi_init_it P_ ((EMACS_INT, EMACS_INT, struct bidi_it *)); +extern void bidi_get_next_char_visually P_ ((struct bidi_it *)); +extern void bidi_paragraph_init P_ ((bidi_dir_t, struct bidi_it *)); +extern int bidi_mirror_char P_ ((int)); + /* Defined in xdisp.c */ struct glyph_row *row_containing_pos P_ ((struct window *, int, struct glyph_row *, struct glyph_row *, int)); -int string_buffer_position P_ ((struct window *, Lisp_Object, int)); +EMACS_INT string_buffer_position P_ ((struct window *, Lisp_Object, + EMACS_INT)); int line_bottom_y P_ ((struct it *)); int display_prop_intangible_p P_ ((Lisp_Object)); void resize_echo_area_exactly P_ ((void)); @@ -3021,8 +3164,6 @@ extern void cancel_line P_ ((int, struct frame *)); extern void init_desired_glyphs P_ ((struct frame *)); extern int scroll_frame_lines P_ ((struct frame *, int, int, int, int)); -extern int direct_output_for_insert P_ ((int)); -extern int direct_output_forward_char P_ ((int)); extern int update_frame P_ ((struct frame *, int, int)); extern int scrolling P_ ((struct frame *)); extern void bitch_at_user P_ ((void)); @@ -3049,8 +3190,6 @@ void redraw_frame P_ ((struct frame *)); void redraw_garbaged_frames P_ ((void)); int scroll_cost P_ ((struct frame *, int, int, int)); -int direct_output_for_insert P_ ((int)); -int direct_output_forward_char P_ ((int)); int update_frame P_ ((struct frame *, int, int)); void update_single_window P_ ((struct window *, int)); int scrolling P_ ((struct frame *)); diff -r 86c85c80cd84 -r 5a619d0a9158 src/dispnew.c --- a/src/dispnew.c Mon Mar 29 14:00:56 2010 +0000 +++ b/src/dispnew.c Thu Apr 01 14:34:20 2010 +0000 @@ -302,12 +302,6 @@ struct glyph space_glyph; -/* Non-zero means update has been performed directly, so that there's - no need for redisplay_internal to do much work. Set by - direct_output_for_insert. */ - -int redisplay_performed_directly_p; - /* Counts of allocated structures. These counts serve to diagnose memory leaks and double frees. */ @@ -1388,8 +1382,11 @@ { if (!row->enabled_p) { + unsigned rp = row->reversed_p; + clear_glyph_row (row); row->enabled_p = 1; + row->reversed_p = rp; } } @@ -1540,6 +1537,7 @@ || a->overlapped_p != b->overlapped_p || (MATRIX_ROW_CONTINUATION_LINE_P (a) != MATRIX_ROW_CONTINUATION_LINE_P (b)) + || a->reversed_p != b->reversed_p /* Different partially visible characters on left margin. */ || a->x != b->x /* Different height. */ @@ -3452,395 +3450,6 @@ /*********************************************************************** - Direct Operations - ***********************************************************************/ - -/* Try to update display and current glyph matrix directly. - - This function is called after a character G has been inserted into - current_buffer. It tries to update the current glyph matrix and - perform appropriate screen output to reflect the insertion. If it - succeeds, the global flag redisplay_performed_directly_p will be - set to 1, and thereby prevent the more costly general redisplay - from running (see redisplay_internal). - - This function is not called for `hairy' character insertions. - In particular, it is not called when after or before change - functions exist, like they are used by font-lock. See keyboard.c - for details where this function is called. */ - -int -direct_output_for_insert (g) - int g; -{ - register struct frame *f = SELECTED_FRAME (); - struct window *w = XWINDOW (selected_window); - struct it it, it2; - struct glyph_row *glyph_row; - struct glyph *glyphs, *glyph, *end; - int n; - /* Non-null means that redisplay of W is based on window matrices. */ - int window_redisplay_p = FRAME_WINDOW_P (f); - /* Non-null means we are in overwrite mode. */ - int overwrite_p = !NILP (current_buffer->overwrite_mode); - int added_width; - struct text_pos pos; - int delta, delta_bytes; - - /* Not done directly. */ - redisplay_performed_directly_p = 0; - - /* Quickly give up for some common cases. */ - if (cursor_in_echo_area - /* Give up if fonts have changed. */ - || fonts_changed_p - /* Give up if face attributes have been changed. */ - || face_change_count - /* Give up if cursor position not really known. */ - || !display_completed - /* Give up if buffer appears in two places. */ - || buffer_shared > 1 - /* Give up if currently displaying a message instead of the - minibuffer contents. */ - || (EQ (selected_window, minibuf_window) - && EQ (minibuf_window, echo_area_window)) - /* Give up for hscrolled mini-buffer because display of the prompt - is handled specially there (see display_line). */ - || (MINI_WINDOW_P (w) && XFASTINT (w->hscroll)) - /* Give up if overwriting in the middle of a line. */ - || (overwrite_p - && PT != ZV - && FETCH_BYTE (PT) != '\n') - /* Give up for tabs and line ends. */ - || g == '\t' - || g == '\n' - || g == '\r' - || (g == ' ' && !NILP (current_buffer->word_wrap)) - /* Give up if unable to display the cursor in the window. */ - || w->cursor.vpos < 0 - /* Give up if we are showing a message or just cleared the message - because we might need to resize the echo area window. */ - || !NILP (echo_area_buffer[0]) - || !NILP (echo_area_buffer[1]) - || (glyph_row = MATRIX_ROW (w->current_matrix, w->cursor.vpos), - /* Can't do it in a continued line because continuation - lines would change. */ - (glyph_row->continued_p - || glyph_row->exact_window_width_line_p - /* Can't use this method if the line overlaps others or is - overlapped by others because these other lines would - have to be redisplayed. */ - || glyph_row->overlapping_p - || glyph_row->overlapped_p)) - /* Can't do it for partial width windows on terminal frames - because we can't clear to eol in such a window. */ - || (!window_redisplay_p && !WINDOW_FULL_WIDTH_P (w))) - return 0; - - /* If we can't insert glyphs, we can use this method only - at the end of a line. */ - if (!FRAME_CHAR_INS_DEL_OK (f)) - if (PT != ZV && FETCH_BYTE (PT_BYTE) != '\n') - return 0; - - /* Set up a display iterator structure for W. Glyphs will be - produced in scratch_glyph_row. Current position is W's cursor - position. */ - clear_glyph_row (&scratch_glyph_row); - SET_TEXT_POS (pos, PT, PT_BYTE); - DEC_TEXT_POS (pos, !NILP (current_buffer->enable_multibyte_characters)); - init_iterator (&it, w, CHARPOS (pos), BYTEPOS (pos), &scratch_glyph_row, - DEFAULT_FACE_ID); - - glyph_row = MATRIX_ROW (w->current_matrix, w->cursor.vpos); - if (glyph_row->mouse_face_p) - return 0; - - /* Give up if highlighting trailing whitespace and we have trailing - whitespace in glyph_row. We would have to remove the trailing - whitespace face in that case. */ - if (!NILP (Vshow_trailing_whitespace) - && glyph_row->used[TEXT_AREA]) - { - struct glyph *last; - - last = glyph_row->glyphs[TEXT_AREA] + glyph_row->used[TEXT_AREA] - 1; - if (last->type == STRETCH_GLYPH - || (last->type == CHAR_GLYPH - && last->u.ch == ' ')) - return 0; - } - - /* Give up if there are overlay strings at pos. This would fail - if the overlay string has newlines in it. */ - if (STRINGP (it.string)) - return 0; - - it.hpos = w->cursor.hpos; - it.vpos = w->cursor.vpos; - it.current_x = w->cursor.x + it.first_visible_x; - it.current_y = w->cursor.y; - it.end_charpos = PT; - it.stop_charpos = min (PT, it.stop_charpos); - it.stop_charpos = max (IT_CHARPOS (it), it.stop_charpos); - - /* More than one display element may be returned for PT - 1 if - (i) it's a control character which is translated into `\003' or - `^C', or (ii) it has a display table entry, or (iii) it's a - combination of both. */ - delta = delta_bytes = 0; - while (get_next_display_element (&it)) - { - PRODUCE_GLYPHS (&it); - - /* Give up if glyph doesn't fit completely on the line. */ - if (it.current_x >= it.last_visible_x) - return 0; - - /* Give up if new glyph has different ascent or descent than - the original row, or if it is not a character glyph. */ - if (glyph_row->ascent != it.ascent - || glyph_row->height != it.ascent + it.descent - || glyph_row->phys_ascent != it.phys_ascent - || glyph_row->phys_height != it.phys_ascent + it.phys_descent - || it.what != IT_CHARACTER) - return 0; - - delta += 1; - delta_bytes += it.len; - set_iterator_to_next (&it, 1); - } - - /* Give up if we hit the right edge of the window. We would have - to insert truncation or continuation glyphs. */ - added_width = it.current_x - (w->cursor.x + it.first_visible_x); - if (glyph_row->pixel_width + added_width >= it.last_visible_x) - return 0; - - /* Give up if there is a \t following in the line. */ - it2 = it; - it2.end_charpos = ZV; - it2.stop_charpos = min (it2.stop_charpos, ZV); - while (get_next_display_element (&it2) - && !ITERATOR_AT_END_OF_LINE_P (&it2)) - { - if (it2.c == '\t') - return 0; - set_iterator_to_next (&it2, 1); - } - - /* Number of new glyphs produced. */ - n = it.glyph_row->used[TEXT_AREA]; - - /* Start and end of glyphs in original row. */ - glyphs = glyph_row->glyphs[TEXT_AREA] + w->cursor.hpos; - end = glyph_row->glyphs[1 + TEXT_AREA]; - - /* Make room for new glyphs, then insert them. */ - xassert (end - glyphs - n >= 0); - safe_bcopy ((char *) glyphs, (char *) (glyphs + n), - (end - glyphs - n) * sizeof (*end)); - bcopy (it.glyph_row->glyphs[TEXT_AREA], glyphs, n * sizeof *glyphs); - glyph_row->used[TEXT_AREA] = min (glyph_row->used[TEXT_AREA] + n, - end - glyph_row->glyphs[TEXT_AREA]); - - /* Compute new line width. */ - glyph = glyph_row->glyphs[TEXT_AREA]; - end = glyph + glyph_row->used[TEXT_AREA]; - glyph_row->pixel_width = glyph_row->x; - while (glyph < end) - { - glyph_row->pixel_width += glyph->pixel_width; - ++glyph; - } - - /* Increment buffer positions for glyphs following the newly - inserted ones. */ - for (glyph = glyphs + n; glyph < end; ++glyph) - if (glyph->charpos > 0 && BUFFERP (glyph->object)) - glyph->charpos += delta; - - if (MATRIX_ROW_END_CHARPOS (glyph_row) > 0) - { - MATRIX_ROW_END_CHARPOS (glyph_row) += delta; - MATRIX_ROW_END_BYTEPOS (glyph_row) += delta_bytes; - } - - /* Adjust positions in lines following the one we are in. */ - increment_matrix_positions (w->current_matrix, - w->cursor.vpos + 1, - w->current_matrix->nrows, - delta, delta_bytes); - - glyph_row->contains_overlapping_glyphs_p - |= it.glyph_row->contains_overlapping_glyphs_p; - - glyph_row->displays_text_p = 1; - w->window_end_vpos = make_number (max (w->cursor.vpos, - XFASTINT (w->window_end_vpos))); - - if (!NILP (Vshow_trailing_whitespace)) - highlight_trailing_whitespace (it.f, glyph_row); - - /* Write glyphs. If at end of row, we can simply call write_glyphs. - In the middle, we have to insert glyphs. Note that this is now - implemented for X frames. The implementation uses updated_window - and updated_row. */ - updated_row = glyph_row; - updated_area = TEXT_AREA; - update_begin (f); - if (FRAME_RIF (f)) - { - FRAME_RIF (f)->update_window_begin_hook (w); - - if (glyphs == end - n - /* In front of a space added by append_space. */ - || (glyphs == end - n - 1 - && (end - n)->charpos <= 0)) - FRAME_RIF (f)->write_glyphs (glyphs, n); - else - FRAME_RIF (f)->insert_glyphs (glyphs, n); - } - else - { - if (glyphs == end - n) - write_glyphs (f, glyphs, n); - else - insert_glyphs (f, glyphs, n); - } - - w->cursor.hpos += n; - w->cursor.x = it.current_x - it.first_visible_x; - xassert (w->cursor.hpos >= 0 - && w->cursor.hpos < w->desired_matrix->matrix_w); - - /* How to set the cursor differs depending on whether we are - using a frame matrix or a window matrix. Note that when - a frame matrix is used, cursor_to expects frame coordinates, - and the X and Y parameters are not used. */ - if (window_redisplay_p) - FRAME_RIF (f)->cursor_to (w->cursor.vpos, w->cursor.hpos, - w->cursor.y, w->cursor.x); - else - { - int x, y; - x = (WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos) - + (INTEGERP (w->left_margin_cols) - ? XFASTINT (w->left_margin_cols) - : 0)); - y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos); - cursor_to (f, y, x); - } - -#ifdef HAVE_WINDOW_SYSTEM - update_window_fringes (w, 0); -#endif - - if (FRAME_RIF (f)) - FRAME_RIF (f)->update_window_end_hook (w, 1, 0); - update_end (f); - updated_row = NULL; - if (FRAME_TERMCAP_P (f)) - fflush (FRAME_TTY (f)->output); - - TRACE ((stderr, "direct output for insert\n")); - mark_window_display_accurate (it.window, 1); - redisplay_performed_directly_p = 1; - return 1; -} - - -/* Perform a direct display update for moving PT by N positions - left or right. N < 0 means a movement backwards. This function - is currently only called for N == 1 or N == -1. */ - -int -direct_output_forward_char (n) - int n; -{ - struct frame *f = SELECTED_FRAME (); - struct window *w = XWINDOW (selected_window); - struct glyph_row *row; - - /* Give up if point moved out of or into a composition. */ - if (check_point_in_composition (current_buffer, XINT (w->last_point), - current_buffer, PT)) - return 0; - - /* Give up if face attributes have been changed. */ - if (face_change_count) - return 0; - - /* Give up if current matrix is not up to date or we are - displaying a message. */ - if (!display_completed || cursor_in_echo_area) - return 0; - - /* Give up if the buffer's direction is reversed. */ - if (!NILP (XBUFFER (w->buffer)->direction_reversed)) - return 0; - - /* Can't use direct output if highlighting a region. */ - if (!NILP (Vtransient_mark_mode) && !NILP (current_buffer->mark_active)) - return 0; - - /* Can't use direct output if highlighting trailing whitespace. */ - if (!NILP (Vshow_trailing_whitespace)) - return 0; - - /* Give up if we are showing a message or just cleared the message - because we might need to resize the echo area window. */ - if (!NILP (echo_area_buffer[0]) || !NILP (echo_area_buffer[1])) - return 0; - - /* Give up if currently displaying a message instead of the - minibuffer contents. */ - if (XWINDOW (minibuf_window) == w - && EQ (minibuf_window, echo_area_window)) - return 0; - - /* Give up if we don't know where the cursor is. */ - if (w->cursor.vpos < 0) - return 0; - - row = MATRIX_ROW (w->current_matrix, w->cursor.vpos); - - /* Give up if PT is outside of the last known cursor row. */ - if (PT <= MATRIX_ROW_START_CHARPOS (row) - || PT >= MATRIX_ROW_END_CHARPOS (row)) - return 0; - - set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0); - - w->last_cursor = w->cursor; - XSETFASTINT (w->last_point, PT); - - xassert (w->cursor.hpos >= 0 - && w->cursor.hpos < w->desired_matrix->matrix_w); - - if (FRAME_WINDOW_P (f)) - FRAME_RIF (f)->cursor_to (w->cursor.vpos, w->cursor.hpos, - w->cursor.y, w->cursor.x); - else - { - int x, y; - x = (WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos) - + (INTEGERP (w->left_margin_cols) - ? XFASTINT (w->left_margin_cols) - : 0)); - y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos); - cursor_to (f, y, x); - } - - if (FRAME_TERMCAP_P (f)) - fflush (FRAME_TTY (f)->output); - redisplay_performed_directly_p = 1; - return 1; -} - - - -/*********************************************************************** Frame Update ***********************************************************************/ diff -r 86c85c80cd84 -r 5a619d0a9158 src/emacs.c --- a/src/emacs.c Mon Mar 29 14:00:56 2010 +0000 +++ b/src/emacs.c Thu Apr 01 14:34:20 2010 +0000 @@ -32,7 +32,7 @@ #include <unistd.h> #endif -#ifdef BSD_SYSTEM +#ifdef HAVE_SYS_IOCTL_H #include <sys/ioctl.h> #endif diff -r 86c85c80cd84 -r 5a619d0a9158 src/image.c --- a/src/image.c Mon Mar 29 14:00:56 2010 +0000 +++ b/src/image.c Thu Apr 01 14:34:20 2010 +0000 @@ -604,7 +604,7 @@ extern Lisp_Object QCwidth, QCheight, QCforeground, QCbackground, QCfile; extern Lisp_Object QCdata, QCtype; extern Lisp_Object Qcenter; -Lisp_Object QCascent, QCmargin, QCrelief, Qcount; +Lisp_Object QCascent, QCmargin, QCrelief, Qcount, Qextension_data; Lisp_Object QCconversion, QCcolor_symbols, QCheuristic_mask; Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask; @@ -1011,8 +1011,8 @@ return mask; } -DEFUN ("image-extension-data", Fimage_extension_data, Simage_extension_data, 1, 2, 0, - doc: /* Return extension data for image SPEC. +DEFUN ("image-metadata", Fimage_metadata, Simage_metadata, 1, 2, 0, + doc: /* Return metadata for image SPEC. FRAME is the frame on which the image will be displayed. FRAME nil or omitted means use the selected frame. */) (spec, frame) @@ -7169,7 +7169,7 @@ struct frame *f; struct image *img; { - /* IMG->data.ptr_val may contain extension data. */ + /* IMG->data.ptr_val may contain metadata with extension data. */ img->data.lisp_val = Qnil; x_clear_image (f, img); } @@ -7488,8 +7488,8 @@ } } - /* Save GIF image extension data for `image-extension-data'. - Format is (count IMAGES FUNCTION "BYTES" ...). */ + /* Save GIF image extension data for `image-metadata'. + Format is (count IMAGES extension-data (FUNCTION "BYTES" ...)). */ img->data.lisp_val = Qnil; if (gif->SavedImages[ino].ExtensionBlockCount > 0) { @@ -7499,7 +7499,9 @@ img->data.lisp_val = Fcons (make_unibyte_string (ext->Bytes, ext->ByteCount), Fcons (make_number (ext->Function), img->data.lisp_val)); - img->data.lisp_val = Fnreverse (img->data.lisp_val); + img->data.lisp_val = Fcons (Qextension_data, + Fcons (Fnreverse (img->data.lisp_val), + Qnil)); } if (gif->ImageCount > 1) img->data.lisp_val = Fcons (Qcount, @@ -8403,6 +8405,8 @@ Qcount = intern_c_string ("count"); staticpro (&Qcount); + Qextension_data = intern_c_string ("extension-data"); + staticpro (&Qextension_data); QCascent = intern_c_string (":ascent"); staticpro (&QCascent); @@ -8498,7 +8502,7 @@ defsubr (&Simage_refresh); defsubr (&Simage_size); defsubr (&Simage_mask_p); - defsubr (&Simage_extension_data); + defsubr (&Simage_metadata); #if GLYPH_DEBUG defsubr (&Simagep); diff -r 86c85c80cd84 -r 5a619d0a9158 src/keyboard.c --- a/src/keyboard.c Mon Mar 29 14:00:56 2010 +0000 +++ b/src/keyboard.c Thu Apr 01 14:34:20 2010 +0000 @@ -1520,8 +1520,6 @@ } #endif -extern int nonundocount; /* Declared in cmds.c. */ - Lisp_Object command_loop_1 () { @@ -1744,149 +1742,8 @@ } else { - if (NILP (current_kboard->Vprefix_arg)) - { - /* In case we jump to directly_done. */ - Vcurrent_prefix_arg = current_kboard->Vprefix_arg; - - /* Recognize some common commands in common situations and - do them directly. */ - if (EQ (Vthis_command, Qforward_char) && PT < ZV - && NILP (Vthis_command_keys_shift_translated) - && !CONSP (Vtransient_mark_mode)) - { - struct Lisp_Char_Table *dp - = window_display_table (XWINDOW (selected_window)); - lose = FETCH_CHAR (PT_BYTE); - SET_PT (PT + 1); - if (! NILP (Vpost_command_hook)) - /* Put this before calling adjust_point_for_property - so it will only get called once in any case. */ - goto directly_done; - if (current_buffer == prev_buffer - && last_point_position != PT - && NILP (Vdisable_point_adjustment) - && NILP (Vglobal_disable_point_adjustment)) - adjust_point_for_property (last_point_position, 0); - already_adjusted = 1; - if (PT == last_point_position + 1 - && (dp - ? (VECTORP (DISP_CHAR_VECTOR (dp, lose)) - ? XVECTOR (DISP_CHAR_VECTOR (dp, lose))->size == 1 - : (NILP (DISP_CHAR_VECTOR (dp, lose)) - && (lose >= 0x20 && lose < 0x7f))) - : (lose >= 0x20 && lose < 0x7f)) - /* To extract the case of continuation on - wide-column characters. */ - && ASCII_BYTE_P (lose) - && (XFASTINT (XWINDOW (selected_window)->last_modified) - >= MODIFF) - && (XFASTINT (XWINDOW (selected_window)->last_overlay_modified) - >= OVERLAY_MODIFF) - && (XFASTINT (XWINDOW (selected_window)->last_point) - == PT - 1) - && !windows_or_buffers_changed - && EQ (current_buffer->selective_display, Qnil) - && !detect_input_pending () - && NILP (XWINDOW (selected_window)->column_number_displayed) - && NILP (Vexecuting_kbd_macro)) - direct_output_forward_char (1); - goto directly_done; - } - else if (EQ (Vthis_command, Qbackward_char) && PT > BEGV - && NILP (Vthis_command_keys_shift_translated) - && !CONSP (Vtransient_mark_mode)) - { - struct Lisp_Char_Table *dp - = window_display_table (XWINDOW (selected_window)); - SET_PT (PT - 1); - lose = FETCH_CHAR (PT_BYTE); - if (! NILP (Vpost_command_hook)) - goto directly_done; - if (current_buffer == prev_buffer - && last_point_position != PT - && NILP (Vdisable_point_adjustment) - && NILP (Vglobal_disable_point_adjustment)) - adjust_point_for_property (last_point_position, 0); - already_adjusted = 1; - if (PT == last_point_position - 1 - && (dp - ? (VECTORP (DISP_CHAR_VECTOR (dp, lose)) - ? XVECTOR (DISP_CHAR_VECTOR (dp, lose))->size == 1 - : (NILP (DISP_CHAR_VECTOR (dp, lose)) - && (lose >= 0x20 && lose < 0x7f))) - : (lose >= 0x20 && lose < 0x7f)) - && (XFASTINT (XWINDOW (selected_window)->last_modified) - >= MODIFF) - && (XFASTINT (XWINDOW (selected_window)->last_overlay_modified) - >= OVERLAY_MODIFF) - && (XFASTINT (XWINDOW (selected_window)->last_point) - == PT + 1) - && !windows_or_buffers_changed - && EQ (current_buffer->selective_display, Qnil) - && !detect_input_pending () - && NILP (XWINDOW (selected_window)->column_number_displayed) - && NILP (Vexecuting_kbd_macro)) - direct_output_forward_char (-1); - goto directly_done; - } - else if (EQ (Vthis_command, Qself_insert_command) - /* Try this optimization only on char keystrokes. */ - && NATNUMP (last_command_event) - && CHAR_VALID_P (XFASTINT (last_command_event), 0)) - { - unsigned int c - = translate_char (Vtranslation_table_for_input, - XFASTINT (last_command_event)); - int value; - if (NILP (Vexecuting_kbd_macro) - && !EQ (minibuf_window, selected_window)) - { - if (!nonundocount || nonundocount >= 20) - { - Fundo_boundary (); - nonundocount = 0; - } - nonundocount++; - } - - lose = ((XFASTINT (XWINDOW (selected_window)->last_modified) - < MODIFF) - || (XFASTINT (XWINDOW (selected_window)->last_overlay_modified) - < OVERLAY_MODIFF) - || (XFASTINT (XWINDOW (selected_window)->last_point) - != PT) - || MODIFF <= SAVE_MODIFF - || windows_or_buffers_changed - || !EQ (current_buffer->selective_display, Qnil) - || detect_input_pending () - || !NILP (XWINDOW (selected_window)->column_number_displayed) - || !NILP (Vexecuting_kbd_macro)); - - value = internal_self_insert (c, 0); - - if (value == 2) - nonundocount = 0; - - frame_make_pointer_invisible (); - - if (! NILP (Vpost_command_hook)) - /* Put this before calling adjust_point_for_property - so it will only get called once in any case. */ - goto directly_done; - - /* VALUE == 1 when AFTER-CHANGE functions are - installed which is the case most of the time - because FONT-LOCK installs one. */ - if (!lose && !value) - direct_output_for_insert (c); - goto directly_done; - } - } - /* Here for a command that isn't executed directly */ - { #ifdef HAVE_WINDOW_SYSTEM int scount = SPECPDL_INDEX (); @@ -1898,7 +1755,6 @@ } #endif - nonundocount = 0; if (NILP (current_kboard->Vprefix_arg)) /* FIXME: Why? --Stef */ Fundo_boundary (); Fcommand_execute (Vthis_command, Qnil, Qnil, Qnil); @@ -1913,8 +1769,6 @@ unbind_to (scount, Qnil); #endif } - } - directly_done: ; current_kboard->Vlast_prefix_arg = Vcurrent_prefix_arg; /* Note that the value cell will never directly contain nil diff -r 86c85c80cd84 -r 5a619d0a9158 src/m/hp800.h --- a/src/m/hp800.h Mon Mar 29 14:00:56 2010 +0000 +++ b/src/m/hp800.h Thu Apr 01 14:34:20 2010 +0000 @@ -93,8 +93,6 @@ #define UNEXEC unexhp9k800.o -#define LIBS_DEBUG - /* Include the file bsdtty.h, since this machine has job control. */ #define NEED_BSDTTY diff -r 86c85c80cd84 -r 5a619d0a9158 src/m/iris4d.h --- a/src/m/iris4d.h Mon Mar 29 14:00:56 2010 +0000 +++ b/src/m/iris4d.h Thu Apr 01 14:34:20 2010 +0000 @@ -53,8 +53,6 @@ #define DATA_START 0x10000000 #define DATA_SEG_BITS 0x10000000 -#define LIBS_DEBUG - /* Use terminfo instead of termcap. */ #define TERMINFO diff -r 86c85c80cd84 -r 5a619d0a9158 src/makefile.w32-in --- a/src/makefile.w32-in Mon Mar 29 14:00:56 2010 +0000 +++ b/src/makefile.w32-in Thu Apr 01 14:34:20 2010 +0000 @@ -115,6 +115,7 @@ $(BLD)/vm-limit.$(O) \ $(BLD)/region-cache.$(O) \ $(BLD)/strftime.$(O) \ + $(BLD)/bidi.$(O) \ $(BLD)/charset.$(O) \ $(BLD)/character.$(O) \ $(BLD)/chartab.$(O) \ @@ -338,6 +339,15 @@ $(SRC)/syssignal.h \ $(SRC)/systime.h +$(BLD)/bidi.$(O) : \ + $(SRC)/bidi.c \ + $(CONFIG_H) \ + $(SRC)/lisp.h \ + $(SRC)/buffer.h \ + $(SRC)/character.h \ + $(SRC)/dispextern.h \ + $(SRC)/w32gui.h + $(BLD)/buffer.$(O) : \ $(SRC)/buffer.c \ $(CONFIG_H) \ diff -r 86c85c80cd84 -r 5a619d0a9158 src/menu.c --- a/src/menu.c Mon Mar 29 14:00:56 2010 +0000 +++ b/src/menu.c Thu Apr 01 14:34:20 2010 +0000 @@ -61,6 +61,10 @@ #define HAVE_BOXES 1 #endif +/* The timestamp of the last input event Emacs received from the X server. */ +/* Defined in keyboard.c. */ +extern unsigned long last_event_timestamp; + extern Lisp_Object QCtoggle, QCradio; Lisp_Object menu_items; @@ -1073,7 +1077,6 @@ int keymaps = 0; int for_click = 0; int specpdl_count = SPECPDL_INDEX (); - Lisp_Object timestamp = Qnil; struct gcpro gcpro1; if (NILP (position)) @@ -1107,10 +1110,9 @@ for_click = 1; tem = Fcar (Fcdr (position)); /* EVENT_START (position) */ window = Fcar (tem); /* POSN_WINDOW (tem) */ - tem = Fcdr (Fcdr (tem)); - x = Fcar (Fcar (tem)); - y = Fcdr (Fcar (tem)); - timestamp = Fcar (Fcdr (tem)); + tem = Fcar (Fcdr (Fcdr (tem))); /* POSN_WINDOW_POSN (tem) */ + x = Fcar (tem); + y = Fcdr (tem); } /* If a click happens in an external tool bar or a detached @@ -1318,9 +1320,13 @@ selection = ns_menu_show (f, xpos, ypos, for_click, keymaps, title, &error_name); #else /* MSDOS and X11 */ + /* Assume last_event_timestamp is the timestamp of the button event. + Is this assumption ever violated? We can't use the timestamp + stored within POSITION because there the top bits from the actual + timestamp may be truncated away (Bug#4930). */ selection = xmenu_show (f, xpos, ypos, for_click, keymaps, title, &error_name, - INTEGERP (timestamp) ? XUINT (timestamp) : 0); + last_event_timestamp); #endif UNBLOCK_INPUT; diff -r 86c85c80cd84 -r 5a619d0a9158 src/nsfns.m --- a/src/nsfns.m Mon Mar 29 14:00:56 2010 +0000 +++ b/src/nsfns.m Thu Apr 01 14:34:20 2010 +0000 @@ -81,6 +81,7 @@ extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth; extern Lisp_Object Qunsplittable, Qmenu_bar_lines, Qbuffer_predicate, Qtitle; extern Lisp_Object Qnone; +extern Lisp_Object Vframe_title_format; Lisp_Object Qbuffered; Lisp_Object Qfontsize; @@ -583,6 +584,8 @@ NSTRACE (x_implicitly_set_name); if (FRAME_ICONIFIED_P (f)) ns_set_name_iconic (f, arg, 0); + else if (FRAME_NS_P (f) && EQ (Vframe_title_format, Qt)) + ns_set_name_as_filename (f); else ns_set_name (f, arg, 0); } @@ -627,14 +630,14 @@ BLOCK_INPUT; pool = [[NSAutoreleasePool alloc] init]; - name =XBUFFER (buf)->filename; + name = XBUFFER (buf)->filename; if (NILP (name) || FRAME_ICONIFIED_P (f)) name =XBUFFER (buf)->name; if (FRAME_ICONIFIED_P (f) && !NILP (f->icon_name)) name = f->icon_name; if (NILP (name)) - name = build_string([ns_app_name UTF8String]); + name = build_string ([ns_app_name UTF8String]); else CHECK_STRING (name); @@ -683,15 +686,18 @@ void -ns_set_doc_edited (struct frame *f, Lisp_Object arg, Lisp_Object oldval) +ns_set_doc_edited (struct frame *f, Lisp_Object arg) { NSView *view = FRAME_NS_VIEW (f); NSAutoreleasePool *pool; - BLOCK_INPUT; - pool = [[NSAutoreleasePool alloc] init]; - [[view window] setDocumentEdited: !NILP (arg)]; - [pool release]; - UNBLOCK_INPUT; + if (!MINI_WINDOW_P (XWINDOW (f->selected_window))) + { + BLOCK_INPUT; + pool = [[NSAutoreleasePool alloc] init]; + [[view window] setDocumentEdited: !NILP (arg)]; + [pool release]; + UNBLOCK_INPUT; + } } diff -r 86c85c80cd84 -r 5a619d0a9158 src/nsterm.h --- a/src/nsterm.h Mon Mar 29 14:00:56 2010 +0000 +++ b/src/nsterm.h Thu Apr 01 14:34:20 2010 +0000 @@ -708,6 +708,8 @@ extern int ns_lisp_to_cursor_type (); extern Lisp_Object ns_cursor_type_to_lisp (int arg); extern Lisp_Object Qnone; +extern void ns_set_name_as_filename (struct frame *f); +extern void ns_set_doc_edited (struct frame *f, Lisp_Object arg); extern int ns_defined_color (struct frame *f, char *name, XColor *color_def, int alloc, diff -r 86c85c80cd84 -r 5a619d0a9158 src/nsterm.m --- a/src/nsterm.m Mon Mar 29 14:00:56 2010 +0000 +++ b/src/nsterm.m Thu Apr 01 14:34:20 2010 +0000 @@ -4173,8 +4173,6 @@ ns_send_appdefined (-2); } -extern void update_window_cursor (struct window *w, int on); - - (void)fd_handler: (NSTimer *) fdEntry /* -------------------------------------------------------------------------- Check data waiting on file descriptors and terminate if so diff -r 86c85c80cd84 -r 5a619d0a9158 src/process.c --- a/src/process.c Mon Mar 29 14:00:56 2010 +0000 +++ b/src/process.c Thu Apr 01 14:34:20 2010 +0000 @@ -69,12 +69,12 @@ #endif #endif /* HAVE_SOCKETS */ -#if defined(BSD_SYSTEM) +#if defined(HAVE_SYS_IOCTL_H) #include <sys/ioctl.h> #if !defined (O_NDELAY) && defined (HAVE_PTYS) && !defined(USG5) #include <fcntl.h> #endif /* HAVE_PTYS and no O_NDELAY */ -#endif /* BSD_SYSTEM */ +#endif /* HAVE_SYS_IOCTL_H */ #ifdef NEED_BSDTTY #include <bsdtty.h> diff -r 86c85c80cd84 -r 5a619d0a9158 src/s/aix4-2.h --- a/src/s/aix4-2.h Mon Mar 29 14:00:56 2010 +0000 +++ b/src/s/aix4-2.h Thu Apr 01 14:34:20 2010 +0000 @@ -87,10 +87,6 @@ #define LINKER cc #endif -/* Prevent -lg from being used for debugging. Not needed. */ - -#define LIBS_DEBUG - /* No need to specify -lc when linking. */ #define LIB_STANDARD @@ -130,16 +126,6 @@ It is just a guess which versions of AIX need this definition. */ #undef HAVE_STRING_H -/* For AIX, it turns out compiling emacs under AIX 3.2.4 REQUIRES "cc -g" - because "cc -O" crashes. Under AIX 3.2.5, "cc -O" is required because - "cc -g" crashes. Go figure. --floppy@merlin.mit.edu */ -/* The above isn't generally true. If it occurs with some compiler - release, seek a fixed version, be it XLC or GCC. The XLC version - isn't tied to the OS version on AIX any more than elsewhere. XLC - (the IBM compiler) can use -g with -O. (-O3 is also a possibility - for the optimization level.) -- fx, after David Edelsohn. */ -#define C_DEBUG_SWITCH -g -O - /* Perry Smith <pedz@ddivt1.austin.ibm.com> says these are correct. */ #define SIGNALS_VIA_CHARACTERS #define MAIL_USE_LOCKF diff -r 86c85c80cd84 -r 5a619d0a9158 src/s/bsd-common.h --- a/src/s/bsd-common.h Mon Mar 29 14:00:56 2010 +0000 +++ b/src/s/bsd-common.h Thu Apr 01 14:34:20 2010 +0000 @@ -46,8 +46,6 @@ #define HAVE_TERMIOS #define NO_TERMIO -#define LIBS_DEBUG - #define SYSV_SYSTEM_DIR /* POSIX-style pgrp behavior. */ diff -r 86c85c80cd84 -r 5a619d0a9158 src/s/darwin.h --- a/src/s/darwin.h Mon Mar 29 14:00:56 2010 +0000 +++ b/src/s/darwin.h Thu Apr 01 14:34:20 2010 +0000 @@ -189,9 +189,6 @@ /* Link this program just by running cc. */ #define ORDINARY_LINK -/* We don't have a g library, so override the -lg LIBS_DEBUG switch. */ -#define LIBS_DEBUG - /* Adding -lm confuses the dynamic linker, so omit it. */ #define LIB_MATH diff -r 86c85c80cd84 -r 5a619d0a9158 src/s/gnu-linux.h --- a/src/s/gnu-linux.h Mon Mar 29 14:00:56 2010 +0000 +++ b/src/s/gnu-linux.h Thu Apr 01 14:34:20 2010 +0000 @@ -194,19 +194,10 @@ #define POSIX /* affects getpagesize.h and systty.h */ #define POSIX_SIGNALS -/* Best not to include -lg, unless it is last on the command line */ -#define LIBS_DEBUG #undef LIB_GCC #define LIB_GCC #define LIB_STANDARD -lgcc -lc -lgcc /usr/lib/crtn.o -/* Don't use -g in test compiles in configure. - This is so we will use the same shared libs for that linking - that are used when linking temacs. */ -#ifdef THIS_IS_CONFIGURE -#define C_DEBUG_SWITCH -#endif - /* _BSD_SOURCE is redundant, at least in glibc2, since we define _GNU_SOURCE. Left in in case it's relevant to libc5 systems and anyone's still using Emacs on those. --fx 2002-12-14 */ diff -r 86c85c80cd84 -r 5a619d0a9158 src/s/irix6-5.h --- a/src/s/irix6-5.h Mon Mar 29 14:00:56 2010 +0000 +++ b/src/s/irix6-5.h Thu Apr 01 14:34:20 2010 +0000 @@ -101,19 +101,6 @@ #define _LP64 /* lisp.h takes care of the rest */ #endif /* _MIPS_SZLONG */ -/* The only supported 32-bit configuration of GCC under IRIX6.x produces - n32 MIPS ABI binaries and also supports -g. */ -#ifdef __GNUC__ -#define C_DEBUG_SWITCH -g -#else -/* Optimize, inaccurate debugging, increase limit on size of what's - optimized. - - This should also be applicable other than on Irix 6.5, but I don't - know for which compiler versions. -- fx */ -#define C_DEBUG_SWITCH -g3 -O -OPT:Olimit=3500 -#endif - #undef SA_RESTART #undef TIOCSIGSEND /* defined in usg5-4.h */ diff -r 86c85c80cd84 -r 5a619d0a9158 src/s/sol2-6.h --- a/src/s/sol2-6.h Mon Mar 29 14:00:56 2010 +0000 +++ b/src/s/sol2-6.h Thu Apr 01 14:34:20 2010 +0000 @@ -48,11 +48,6 @@ #define LIBS_TERMCAP -ltermcap #endif -#ifndef __GNUC__ -/* eggert thinks all versions of SunPro C allowed this. */ -#define C_DEBUG_SWITCH -g -O -#endif /* GCC */ - /* This is the same definition as in usg5-4.h, but with sigblock/sigunblock rather than sighold/sigrelse, which appear to be BSD4.1 specific and won't work if POSIX_SIGNALS is defined. It may also be appropriate for SVR4.x diff -r 86c85c80cd84 -r 5a619d0a9158 src/s/usg5-4.h --- a/src/s/usg5-4.h Mon Mar 29 14:00:56 2010 +0000 +++ b/src/s/usg5-4.h Thu Apr 01 14:34:20 2010 +0000 @@ -103,10 +103,6 @@ #define LIB_STANDARD -/* there are no -lg libraries on this system, and no libPW */ - -#define LIBS_DEBUG - /* Undump with ELF */ #undef COFF diff -r 86c85c80cd84 -r 5a619d0a9158 src/sysdep.c --- a/src/sysdep.c Mon Mar 29 14:00:56 2010 +0000 +++ b/src/sysdep.c Thu Apr 01 14:34:20 2010 +0000 @@ -384,11 +384,7 @@ wait_without_blocking () { -#ifdef BSD_SYSTEM - wait3 (0, WNOHANG | WUNTRACED, 0); -#else croak ("wait_without_blocking"); -#endif synch_process_alive = 0; } @@ -1401,9 +1397,8 @@ if (tty_out->term_initted && no_redraw_on_reenter) { - /* XXX This seems wrong on multi-tty. */ - if (display_completed) - direct_output_forward_char (0); + /* We used to call "direct_output_forward_char(0)" here, + but it's not clear why, since it may not do anything anyway. */ } else { diff -r 86c85c80cd84 -r 5a619d0a9158 src/term.c --- a/src/term.c Mon Mar 29 14:00:56 2010 +0000 +++ b/src/term.c Thu Apr 01 14:34:20 2010 +0000 @@ -1540,6 +1540,26 @@ + it->glyph_row->used[it->area]); end = it->glyph_row->glyphs[1 + it->area]; + /* If the glyph row is reversed, we need to prepend the glyph rather + than append it. */ + if (it->glyph_row->reversed_p && it->area == TEXT_AREA) + { + struct glyph *g; + int move_by = it->pixel_width; + + /* Make room for the new glyphs. */ + if (move_by > end - glyph) /* don't overstep end of this area */ + move_by = end - glyph; + for (g = glyph - 1; g >= it->glyph_row->glyphs[it->area]; g--) + g[move_by] = *g; + glyph = it->glyph_row->glyphs[it->area]; + end = glyph + move_by; + } + + /* BIDI Note: we put the glyphs of a "multi-pixel" character left to + right, even in the REVERSED_P case, since (a) all of its u.ch are + identical, and (b) the PADDING_P flag needs to be set for the + leftmost one, because we write to the terminal left-to-right. */ for (i = 0; i < it->pixel_width && glyph < end; ++i) @@ -1551,6 +1571,18 @@ glyph->padding_p = i > 0; glyph->charpos = CHARPOS (it->position); glyph->object = it->object; + if (it->bidi_p) + { + glyph->resolved_level = it->bidi_it.resolved_level; + if ((it->bidi_it.type & 7) != it->bidi_it.type) + abort (); + glyph->bidi_type = it->bidi_it.type; + } + else + { + glyph->resolved_level = 0; + glyph->bidi_type = UNKNOWN_BT; + } ++it->glyph_row->used[it->area]; ++glyph; diff -r 86c85c80cd84 -r 5a619d0a9158 src/window.c --- a/src/window.c Mon Mar 29 14:00:56 2010 +0000 +++ b/src/window.c Thu Apr 01 14:34:20 2010 +0000 @@ -7380,9 +7380,6 @@ initial_define_key (global_map, Ctl ('V'), "scroll-up"); initial_define_key (meta_map, Ctl ('V'), "scroll-other-window"); initial_define_key (meta_map, 'v', "scroll-down"); - - initial_define_key (global_map, Ctl('L'), "recenter"); - initial_define_key (meta_map, 'r', "move-to-window-line"); } /* arch-tag: 90a9c576-0590-48f1-a5f1-6c96a0452d9f diff -r 86c85c80cd84 -r 5a619d0a9158 src/window.h --- a/src/window.h Mon Mar 29 14:00:56 2010 +0000 +++ b/src/window.h Thu Apr 01 14:34:20 2010 +0000 @@ -117,7 +117,10 @@ /* The buffer displayed in this window */ /* Of the fields vchild, hchild and buffer, only one is non-nil. */ Lisp_Object buffer; - /* A marker pointing to where in the text to start displaying */ + /* A marker pointing to where in the text to start displaying. + BIDI Note: This is the _logical-order_ start, i.e. the smallest + buffer position visible in the window, not necessarily the + character displayed in the top left corner of the window. */ Lisp_Object start; /* A marker pointing to where in the text point is in this window, used only when the window is not selected. diff -r 86c85c80cd84 -r 5a619d0a9158 src/xdisp.c --- a/src/xdisp.c Mon Mar 29 14:00:56 2010 +0000 +++ b/src/xdisp.c Thu Apr 01 14:34:20 2010 +0000 @@ -32,9 +32,7 @@ decides it's time to do it. This is done either automatically for you as part of the interpreter's command loop or as the result of calling Lisp functions like `sit-for'. The C function `redisplay' - in xdisp.c is the only entry into the inner redisplay code. (Or, - let's say almost---see the description of direct update - operations, below.) + in xdisp.c is the only entry into the inner redisplay code. The following diagram shows how redisplay code is invoked. As you can see, Lisp calls redisplay and vice versa. Under window systems @@ -46,12 +44,6 @@ change the interpreter's state. If you don't follow these rules, you will encounter bugs which are very hard to explain. - (Direct functions, see below) - direct_output_for_insert, - direct_forward_char (dispnew.c) - +---------------------------------+ - | | - | V +--------------+ redisplay +----------------+ | Lisp machine |---------------->| Redisplay code |<--+ +--------------+ (xdisp.c) +----------------+ | @@ -85,28 +77,11 @@ then compared to find a cheap way to update the display, e.g. by reusing part of the display by scrolling lines. - - Direct operations. - You will find a lot of redisplay optimizations when you start looking at the innards of redisplay. The overall goal of all these optimizations is to make redisplay fast because it is done frequently. - Two optimizations are not found in xdisp.c. These are the direct - operations mentioned above. As the name suggests they follow a - different principle than the rest of redisplay. Instead of - building a desired matrix and then comparing it with the current - display, they perform their actions directly on the display and on - the current matrix. - - One direct operation updates the display after one character has - been entered. The other one moves the cursor by one position - forward or backward. You find these functions under the names - `direct_output_for_insert' and `direct_output_forward_char' in - dispnew.c. - - Desired matrices. Desired matrices are always built per Emacs window. The function @@ -249,6 +224,7 @@ Lisp_Object Qgrow_only; Lisp_Object Qinhibit_eval_during_redisplay; Lisp_Object Qbuffer_position, Qposition, Qobject; +Lisp_Object Qright_to_left, Qleft_to_right; /* Cursor shapes */ Lisp_Object Qbar, Qhbar, Qbox, Qhollow; @@ -904,6 +880,7 @@ static int store_mode_line_noprop P_ ((const unsigned char *, int, int)); static void x_consider_frame_title P_ ((Lisp_Object)); static void handle_stop P_ ((struct it *)); +static void handle_stop_backwards P_ ((struct it *, EMACS_INT)); static int tool_bar_lines_needed P_ ((struct frame *, int *)); static int single_display_spec_intangible_p P_ ((Lisp_Object)); static void ensure_echo_area_buffers P_ ((void)); @@ -1375,33 +1352,7 @@ visible_p = 1; if (visible_p) { - if (it_method == GET_FROM_BUFFER) - { - Lisp_Object window, prop; - - XSETWINDOW (window, w); - prop = Fget_char_property (make_number (charpos), - Qinvisible, window); - - /* If charpos coincides with invisible text covered with an - ellipsis, use the first glyph of the ellipsis to compute - the pixel positions. */ - if (TEXT_PROP_MEANS_INVISIBLE (prop) == 2) - { - struct glyph_row *row = it.glyph_row; - struct glyph *glyph = row->glyphs[TEXT_AREA]; - struct glyph *end = glyph + row->used[TEXT_AREA]; - int x = row->x; - - for (; glyph < end - && (!BUFFERP (glyph->object) - || glyph->charpos < charpos); - glyph++) - x += glyph->pixel_width; - top_x = x; - } - } - else if (it_method == GET_FROM_DISPLAY_VECTOR) + if (it_method == GET_FROM_DISPLAY_VECTOR) { /* We stopped on the last glyph of a display vector. Try and recompute. Hack alert! */ @@ -2654,6 +2605,9 @@ /* Are multibyte characters enabled in current_buffer? */ it->multibyte_p = !NILP (current_buffer->enable_multibyte_characters); + /* Do we need to reorder bidirectional text? */ + it->bidi_p = !NILP (current_buffer->bidi_display_reordering); + /* Non-zero if we should highlight the region. */ highlight_region_p = (!NILP (Vtransient_mark_mode) @@ -2744,6 +2698,10 @@ it->glyph_row = row; it->area = TEXT_AREA; + /* Forget any previous info about this row being reversed. */ + if (it->glyph_row) + it->glyph_row->reversed_p = 0; + /* Get the dimensions of the display area. The display area consists of the visible window area plus a horizontally scrolled part to the left of the window. All x-values are relative to the @@ -2799,6 +2757,21 @@ it->start_of_box_run_p = 1; } + /* If we are to reorder bidirectional text, init the bidi + iterator. */ + if (it->bidi_p) + { + /* Note the paragraph direction that this buffer wants to + use. */ + if (EQ (current_buffer->bidi_paragraph_direction, Qleft_to_right)) + it->paragraph_embedding = L2R; + else if (EQ (current_buffer->bidi_paragraph_direction, Qright_to_left)) + it->paragraph_embedding = R2L; + else + it->paragraph_embedding = NEUTRAL_DIR; + bidi_init_it (charpos, bytepos, &it->bidi_it); + } + /* If a buffer position was specified, set the iterator there, getting overlays and face properties from that position. */ if (charpos >= BUF_BEG (current_buffer)) @@ -3764,18 +3737,18 @@ else { int invis_p; - EMACS_INT newpos, next_stop, start_charpos; + EMACS_INT newpos, next_stop, start_charpos, tem; Lisp_Object pos, prop, overlay; /* First of all, is there invisible text at this position? */ - start_charpos = IT_CHARPOS (*it); - pos = make_number (IT_CHARPOS (*it)); + tem = start_charpos = IT_CHARPOS (*it); + pos = make_number (tem); prop = get_char_property_and_overlay (pos, Qinvisible, it->window, &overlay); invis_p = TEXT_PROP_MEANS_INVISIBLE (prop); /* If we are on invisible text, skip over it. */ - if (invis_p && IT_CHARPOS (*it) < it->end_charpos) + if (invis_p && start_charpos < it->end_charpos) { /* Record whether we have to display an ellipsis for the invisible text. */ @@ -3788,17 +3761,16 @@ do { /* Try to skip some invisible text. Return value is the - position reached which can be equal to IT's position - if there is nothing invisible here. This skips both + position reached which can be equal to where we start + if there is nothing invisible there. This skips both over invisible text properties and overlays with invisible property. */ - newpos = skip_invisible (IT_CHARPOS (*it), - &next_stop, ZV, it->window); + newpos = skip_invisible (tem, &next_stop, ZV, it->window); /* If we skipped nothing at all we weren't at invisible text in the first place. If everything to the end of the buffer was skipped, end the loop. */ - if (newpos == IT_CHARPOS (*it) || newpos >= ZV) + if (newpos == tem || newpos >= ZV) invis_p = 0; else { @@ -3816,7 +3788,7 @@ /* If we ended up on invisible text, proceed to skip starting with next_stop. */ if (invis_p) - IT_CHARPOS (*it) = next_stop; + tem = next_stop; /* If there are adjacent invisible texts, don't lose the second one's ellipsis. */ @@ -3826,8 +3798,47 @@ while (invis_p); /* The position newpos is now either ZV or on visible text. */ - IT_CHARPOS (*it) = newpos; - IT_BYTEPOS (*it) = CHAR_TO_BYTE (newpos); + if (it->bidi_p && newpos < ZV) + { + /* With bidi iteration, the region of invisible text + could start and/or end in the middle of a non-base + embedding level. Therefore, we need to skip + invisible text using the bidi iterator, starting at + IT's current position, until we find ourselves + outside the invisible text. Skipping invisible text + _after_ bidi iteration avoids affecting the visual + order of the displayed text when invisible properties + are added or removed. */ + if (it->bidi_it.first_elt) + { + /* If we were `reseat'ed to a new paragraph, + determine the paragraph base direction. We need + to do it now because next_element_from_buffer may + not have a chance to do it, if we are going to + skip any text at the beginning, which resets the + FIRST_ELT flag. */ + bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it); + } + do + { + bidi_get_next_char_visually (&it->bidi_it); + } + while (it->stop_charpos <= it->bidi_it.charpos + && it->bidi_it.charpos < newpos); + IT_CHARPOS (*it) = it->bidi_it.charpos; + IT_BYTEPOS (*it) = it->bidi_it.bytepos; + /* If we overstepped NEWPOS, record its position in the + iterator, so that we skip invisible text if later the + bidi iteration lands us in the invisible region + again. */ + if (IT_CHARPOS (*it) >= newpos) + it->prev_stop = newpos; + } + else + { + IT_CHARPOS (*it) = newpos; + IT_BYTEPOS (*it) = CHAR_TO_BYTE (newpos); + } /* If there are before-strings at the start of invisible text, and the text is invisible because of a text @@ -3836,7 +3847,7 @@ overlay property instead of a text property, this is already handled in the overlay code.) */ if (NILP (overlay) - && get_overlay_strings (it, start_charpos)) + && get_overlay_strings (it, it->stop_charpos)) { handled = HANDLED_RECOMPUTE_PROPS; it->stack[it->sp - 1].display_ellipsis_p = display_ellipsis_p; @@ -3857,7 +3868,7 @@ first invisible character. */ if (!STRINGP (it->object)) { - it->position.charpos = IT_CHARPOS (*it) - 1; + it->position.charpos = newpos - 1; it->position.bytepos = CHAR_TO_BYTE (it->position.charpos); } it->ellipsis_p = 1; @@ -4571,43 +4582,46 @@ return 0; } - -/* Determine which buffer position in W's buffer STRING comes from. - AROUND_CHARPOS is an approximate position where it could come from. - Value is the buffer position or 0 if it couldn't be determined. +/* Look for STRING in overlays and text properties in W's buffer, + between character positions FROM and TO (excluding TO). + BACK_P non-zero means look back (in this case, TO is supposed to be + less than FROM). + Value is the first character position where STRING was found, or + zero if it wasn't found before hitting TO. W's buffer must be current. - This function is necessary because we don't record buffer positions - in glyphs generated from strings (to keep struct glyph small). This function may only use code that doesn't eval because it is called asynchronously from note_mouse_highlight. */ -int -string_buffer_position (w, string, around_charpos) +static EMACS_INT +string_buffer_position_lim (w, string, from, to, back_p) struct window *w; Lisp_Object string; - int around_charpos; + EMACS_INT from, to; + int back_p; { Lisp_Object limit, prop, pos; - const int MAX_DISTANCE = 1000; int found = 0; - pos = make_number (around_charpos); - limit = make_number (min (XINT (pos) + MAX_DISTANCE, ZV)); - while (!found && !EQ (pos, limit)) - { - prop = Fget_char_property (pos, Qdisplay, Qnil); - if (!NILP (prop) && display_prop_string_p (prop, string)) - found = 1; - else - pos = Fnext_single_char_property_change (pos, Qdisplay, Qnil, limit); - } - - if (!found) - { - pos = make_number (around_charpos); - limit = make_number (max (XINT (pos) - MAX_DISTANCE, BEGV)); + pos = make_number (from); + + if (!back_p) /* looking forward */ + { + limit = make_number (min (to, ZV)); + while (!found && !EQ (pos, limit)) + { + prop = Fget_char_property (pos, Qdisplay, Qnil); + if (!NILP (prop) && display_prop_string_p (prop, string)) + found = 1; + else + pos = Fnext_single_char_property_change (pos, Qdisplay, Qnil, + limit); + } + } + else /* looking back */ + { + limit = make_number (max (to, BEGV)); while (!found && !EQ (pos, limit)) { prop = Fget_char_property (pos, Qdisplay, Qnil); @@ -4622,6 +4636,35 @@ return found ? XINT (pos) : 0; } +/* Determine which buffer position in W's buffer STRING comes from. + AROUND_CHARPOS is an approximate position where it could come from. + Value is the buffer position or 0 if it couldn't be determined. + + W's buffer must be current. + + This function is necessary because we don't record buffer positions + in glyphs generated from strings (to keep struct glyph small). + This function may only use code that doesn't eval because it is + called asynchronously from note_mouse_highlight. */ + +EMACS_INT +string_buffer_position (w, string, around_charpos) + struct window *w; + Lisp_Object string; + EMACS_INT around_charpos; +{ + Lisp_Object limit, prop, pos; + const int MAX_DISTANCE = 1000; + EMACS_INT found = string_buffer_position_lim (w, string, around_charpos, + around_charpos + MAX_DISTANCE, + 0); + + if (!found) + found = string_buffer_position_lim (w, string, around_charpos, + around_charpos - MAX_DISTANCE, 1); + return found; +} + /*********************************************************************** @@ -5088,6 +5131,8 @@ p = it->stack + it->sp; p->stop_charpos = it->stop_charpos; + p->prev_stop = it->prev_stop; + p->base_level_stop = it->base_level_stop; p->cmp_it = it->cmp_it; xassert (it->face_id >= 0); p->face_id = it->face_id; @@ -5138,6 +5183,8 @@ --it->sp; p = it->stack + it->sp; it->stop_charpos = p->stop_charpos; + it->prev_stop = p->prev_stop; + it->base_level_stop = p->base_level_stop; it->cmp_it = p->cmp_it; it->face_id = p->face_id; it->current = p->current; @@ -5315,8 +5362,8 @@ if (IT_CHARPOS (*it) <= BEGV) break; - /* If selective > 0, then lines indented more than that values - are invisible. */ + /* If selective > 0, then lines indented more than its value are + invisible. */ if (it->selective > 0 && indented_beyond_p (IT_CHARPOS (*it), IT_BYTEPOS (*it), (double) it->selective)) /* iftc */ @@ -5473,7 +5520,30 @@ if (force_p || CHARPOS (pos) > it->stop_charpos || CHARPOS (pos) < original_pos) - handle_stop (it); + { + if (it->bidi_p) + { + /* For bidi iteration, we need to prime prev_stop and + base_level_stop with our best estimations. */ + if (CHARPOS (pos) < it->prev_stop) + { + handle_stop_backwards (it, BEGV); + if (CHARPOS (pos) < it->base_level_stop) + it->base_level_stop = 0; + } + else if (CHARPOS (pos) > it->stop_charpos + && it->stop_charpos >= BEGV) + handle_stop_backwards (it, it->stop_charpos); + else /* force_p */ + handle_stop (it); + } + else + { + handle_stop (it); + it->prev_stop = it->base_level_stop = 0; + } + + } CHECK_IT (it); } @@ -5510,9 +5580,14 @@ it->sp = 0; it->string_from_display_prop_p = 0; it->face_before_selective_p = 0; + if (it->bidi_p) + it->bidi_it.first_elt = 1; if (set_stop_p) - it->stop_charpos = CHARPOS (pos); + { + it->stop_charpos = CHARPOS (pos); + it->base_level_stop = CHARPOS (pos); + } } @@ -5624,7 +5699,7 @@ /*********************************************************************** Iteration - ***********************************************************************/ +***********************************************************************/ /* Map enum it_method value to corresponding next_element_from_* function. */ @@ -5676,6 +5751,13 @@ if (it->what == IT_CHARACTER) { + /* UAX#9, L4: "A character is depicted by a mirrored glyph if + and only if (a) the resolved directionality of that character + is R..." */ + /* FIXME: Do we need an exception for characters from display + tables? */ + if (it->bidi_p && it->bidi_it.type == STRONG_R) + it->c = bidi_mirror_char (it->c); /* Map via display table or translate control characters. IT->c, IT->len etc. have been set to the next character by the function call above. If we have a display table, and it @@ -5690,7 +5772,7 @@ Lisp_Object dv; struct charset *unibyte = CHARSET_FROM_ID (charset_unibyte); enum { char_is_other = 0, char_is_nbsp, char_is_soft_hyphen } - nbsp_or_shy = char_is_other; + nbsp_or_shy = char_is_other; int decoded = it->c; if (it->dp @@ -5908,12 +5990,12 @@ happen actually, but due to bugs it may happen. Let's print the char as is, there's not much meaningful we can do with it. */ - str[0] = it->c; - str[1] = it->c >> 8; - str[2] = it->c >> 16; - str[3] = it->c >> 24; - len = 4; - } + str[0] = it->c; + str[1] = it->c >> 8; + str[2] = it->c >> 16; + str[3] = it->c >> 24; + len = 4; + } for (i = 0; i < len; i++) { @@ -6082,8 +6164,22 @@ else { xassert (it->len != 0); - IT_BYTEPOS (*it) += it->len; - IT_CHARPOS (*it) += 1; + + if (!it->bidi_p) + { + IT_BYTEPOS (*it) += it->len; + IT_CHARPOS (*it) += 1; + } + else + { + /* If this is a new paragraph, determine its base + direction (a.k.a. its base embedding level). */ + if (it->bidi_it.new_paragraph) + bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it); + bidi_get_next_char_visually (&it->bidi_it); + IT_BYTEPOS (*it) = it->bidi_it.bytepos; + IT_CHARPOS (*it) = it->bidi_it.charpos; + } xassert (IT_BYTEPOS (*it) == CHAR_TO_BYTE (IT_CHARPOS (*it))); } break; @@ -6236,7 +6332,7 @@ it->face_id = it->saved_face_id; /* KFS: This code used to check ip->dpvec[0] instead of the current element. - That seemed totally bogus - so I changed it... */ + That seemed totally bogus - so I changed it... */ gc = it->dpvec[it->current.dpvec_index]; if (GLYPH_CODE_P (gc) && GLYPH_CODE_CHAR_VALID_P (gc)) @@ -6471,6 +6567,45 @@ return 1; } +/* Scan forward from CHARPOS in the current buffer, until we find a + stop position > current IT's position. Then handle the stop + position before that. This is called when we bump into a stop + position while reordering bidirectional text. */ + +static void +handle_stop_backwards (it, charpos) + struct it *it; + EMACS_INT charpos; +{ + EMACS_INT where_we_are = IT_CHARPOS (*it); + struct display_pos save_current = it->current; + struct text_pos save_position = it->position; + struct text_pos pos1; + EMACS_INT next_stop; + + /* Scan in strict logical order. */ + it->bidi_p = 0; + do + { + it->prev_stop = charpos; + SET_TEXT_POS (pos1, charpos, CHAR_TO_BYTE (charpos)); + reseat_1 (it, pos1, 0); + compute_stop_pos (it); + /* We must advance forward, right? */ + if (it->stop_charpos <= it->prev_stop) + abort (); + charpos = it->stop_charpos; + } + while (charpos <= where_we_are); + + next_stop = it->stop_charpos; + it->stop_charpos = it->prev_stop; + it->bidi_p = 1; + it->current = save_current; + it->position = save_position; + handle_stop (it); + it->stop_charpos = next_stop; +} /* Load IT with the next display element from current_buffer. Value is zero if end of buffer reached. IT->stop_charpos is the next @@ -6485,6 +6620,53 @@ xassert (IT_CHARPOS (*it) >= BEGV); + /* With bidi reordering, the character to display might not be the + character at IT_CHARPOS. BIDI_IT.FIRST_ELT non-zero means that + we were reseat()ed to a new buffer position, which is potentially + a different paragraph. */ + if (it->bidi_p && it->bidi_it.first_elt) + { + it->bidi_it.charpos = IT_CHARPOS (*it); + it->bidi_it.bytepos = IT_BYTEPOS (*it); + /* If we are at the beginning of a line, we can produce the next + element right away. */ + if (it->bidi_it.bytepos == BEGV_BYTE + /* FIXME: Should support all Unicode line separators. */ + || FETCH_CHAR (it->bidi_it.bytepos - 1) == '\n' + || FETCH_CHAR (it->bidi_it.bytepos) == '\n') + { + bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it); + bidi_get_next_char_visually (&it->bidi_it); + } + else + { + int orig_bytepos = IT_BYTEPOS (*it); + + /* We need to prime the bidi iterator starting at the line's + beginning, before we will be able to produce the next + element. */ + IT_CHARPOS (*it) = find_next_newline_no_quit (IT_CHARPOS (*it), -1); + IT_BYTEPOS (*it) = CHAR_TO_BYTE (IT_CHARPOS (*it)); + it->bidi_it.charpos = IT_CHARPOS (*it); + it->bidi_it.bytepos = IT_BYTEPOS (*it); + bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it); + do + { + /* Now return to buffer position where we were asked to + get the next display element, and produce that. */ + bidi_get_next_char_visually (&it->bidi_it); + } + while (it->bidi_it.bytepos != orig_bytepos + && it->bidi_it.bytepos < ZV_BYTE); + } + + it->bidi_it.first_elt = 0; /* paranoia: bidi.c does this */ + /* Adjust IT's position information to where we ended up. */ + IT_CHARPOS (*it) = it->bidi_it.charpos; + IT_BYTEPOS (*it) = it->bidi_it.bytepos; + SET_TEXT_POS (it->position, IT_CHARPOS (*it), IT_BYTEPOS (*it)); + } + if (IT_CHARPOS (*it) >= it->stop_charpos) { if (IT_CHARPOS (*it) >= it->end_charpos) @@ -6510,12 +6692,51 @@ success_p = 0; } } - else - { + else if (!(!it->bidi_p + || BIDI_AT_BASE_LEVEL (it->bidi_it) + || IT_CHARPOS (*it) == it->stop_charpos)) + { + /* With bidi non-linear iteration, we could find ourselves + far beyond the last computed stop_charpos, with several + other stop positions in between that we missed. Scan + them all now, in buffer's logical order, until we find + and handle the last stop_charpos that precedes our + current position. */ + handle_stop_backwards (it, it->stop_charpos); + return GET_NEXT_DISPLAY_ELEMENT (it); + } + else + { + if (it->bidi_p) + { + /* Take note of the stop position we just moved across, + for when we will move back across it. */ + it->prev_stop = it->stop_charpos; + /* If we are at base paragraph embedding level, take + note of the last stop position seen at this + level. */ + if (BIDI_AT_BASE_LEVEL (it->bidi_it)) + it->base_level_stop = it->stop_charpos; + } handle_stop (it); return GET_NEXT_DISPLAY_ELEMENT (it); } } + else if (it->bidi_p + /* We can sometimes back up for reasons that have nothing + to do with bidi reordering. E.g., compositions. The + code below is only needed when we are above the base + embedding level, so test for that explicitly. */ + && !BIDI_AT_BASE_LEVEL (it->bidi_it) + && IT_CHARPOS (*it) < it->prev_stop) + { + if (it->base_level_stop <= 0) + it->base_level_stop = BEGV; + if (IT_CHARPOS (*it) < it->base_level_stop) + abort (); + handle_stop_backwards (it, it->base_level_stop); + return GET_NEXT_DISPLAY_ELEMENT (it); + } else { /* No face changes, overlays etc. in sight, so just return a @@ -6670,9 +6891,9 @@ line on the display without producing glyphs. OP should be a bit mask including some or all of these bits: - MOVE_TO_X: Stop on reaching x-position TO_X. - MOVE_TO_POS: Stop on reaching buffer or string position TO_CHARPOS. - Regardless of OP's value, stop in reaching the end of the display line. + MOVE_TO_X: Stop upon reaching x-position TO_X. + MOVE_TO_POS: Stop upon reaching buffer or string position TO_CHARPOS. + Regardless of OP's value, stop upon reaching the end of the display line. TO_X is normally a value 0 <= TO_X <= IT->last_visible_x. This means, in particular, that TO_X includes window's horizontal @@ -6708,6 +6929,8 @@ struct glyph_row *saved_glyph_row; struct it wrap_it, atpos_it, atx_it; int may_wrap = 0; + enum it_method prev_method = it->method; + EMACS_INT prev_pos = IT_CHARPOS (*it); /* Don't produce glyphs in produce_glyphs. */ saved_glyph_row = it->glyph_row; @@ -6725,7 +6948,8 @@ #define BUFFER_POS_REACHED_P() \ ((op & MOVE_TO_POS) != 0 \ && BUFFERP (it->object) \ - && IT_CHARPOS (*it) >= to_charpos \ + && (IT_CHARPOS (*it) == to_charpos \ + || (!it->bidi_p && IT_CHARPOS (*it) > to_charpos)) \ && (it->method == GET_FROM_BUFFER \ || (it->method == GET_FROM_DISPLAY_VECTOR \ && it->dpvec + it->current.dpvec_index + 1 >= it->dpend))) @@ -6749,7 +6973,16 @@ if ((op & MOVE_TO_POS) != 0 && BUFFERP (it->object) && it->method == GET_FROM_BUFFER - && IT_CHARPOS (*it) > to_charpos) + && ((!it->bidi_p && IT_CHARPOS (*it) > to_charpos) + || (it->bidi_p + && (prev_method == GET_FROM_IMAGE + || prev_method == GET_FROM_STRETCH) + /* Passed TO_CHARPOS from left to right. */ + && ((prev_pos < to_charpos + && IT_CHARPOS (*it) > to_charpos) + /* Passed TO_CHARPOS from right to left. */ + || (prev_pos > to_charpos + && IT_CHARPOS (*it) < to_charpos))))) { if (it->line_wrap != WORD_WRAP || wrap_it.sp < 0) { @@ -6763,6 +6996,9 @@ atpos_it = *it; } + prev_method = it->method; + if (it->method == GET_FROM_BUFFER) + prev_pos = IT_CHARPOS (*it); /* Stop when ZV reached. We used to stop here when TO_CHARPOS reached as well, but that is too soon if this glyph does not fit on this line. So we handle it @@ -7028,6 +7264,8 @@ break; } + if (it->method == GET_FROM_BUFFER) + prev_pos = IT_CHARPOS (*it); /* The current display element has been consumed. Advance to the next. */ set_iterator_to_next (it, 1); @@ -9498,32 +9736,7 @@ if (! STRINGP (f->name) || SBYTES (f->name) != len || bcmp (title, SDATA (f->name), len) != 0) - { -#ifdef HAVE_NS - if (FRAME_NS_P (f)) - { - if (!MINI_WINDOW_P(XWINDOW(f->selected_window))) - { - if (EQ (fmt, Qt)) - ns_set_name_as_filename (f); - else - x_implicitly_set_name (f, make_string(title, len), - Qnil); - } - } - else -#endif - x_implicitly_set_name (f, make_string (title, len), Qnil); - } -#ifdef HAVE_NS - if (FRAME_NS_P (f)) - { - /* do this also for frames with explicit names */ - ns_implicitly_set_icon_type(f); - ns_set_doc_edited(f, Fbuffer_modified_p - (XWINDOW (f->selected_window)->buffer), Qnil); - } -#endif + x_implicitly_set_name (f, make_string (title, len), Qnil); } } @@ -9620,6 +9833,11 @@ #ifdef HAVE_WINDOW_SYSTEM update_tool_bar (f, 0); #endif +#ifdef HAVE_NS + if (windows_or_buffers_changed) + ns_set_doc_edited (f, Fbuffer_modified_p + (XWINDOW (f->selected_window)->buffer)); +#endif UNGCPRO; } @@ -11033,6 +11251,17 @@ && overlay_touches_p (Z - end)) unchanged_p = 0; } + + /* Under bidi reordering, adding or deleting a character in the + beginning of a paragraph, before the first strong directional + character, can change the base direction of the paragraph (unless + the buffer specifies a fixed paragraph direction), which will + require to redisplay the whole paragraph. It might be worthwhile + to find the paragraph limits and widen the range of redisplayed + lines to that, but for now just give up this optimization. */ + if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering) + && NILP (XBUFFER (w->buffer)->bidi_paragraph_direction)) + unchanged_p = 0; } return unchanged_p; @@ -11364,16 +11593,6 @@ if (!f->glyphs_initialized_p) return; - /* The flag redisplay_performed_directly_p is set by - direct_output_for_insert when it already did the whole screen - update necessary. */ - if (redisplay_performed_directly_p) - { - redisplay_performed_directly_p = 0; - if (!hscroll_windows (selected_window)) - return; - } - #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) if (popup_activated ()) return; @@ -12323,162 +12542,409 @@ struct glyph *glyph = row->glyphs[TEXT_AREA]; struct glyph *end = glyph + row->used[TEXT_AREA]; struct glyph *cursor = NULL; - /* The first glyph that starts a sequence of glyphs from a string - that is a value of a display property. */ - struct glyph *string_start; - /* The X coordinate of string_start. */ - int string_start_x; /* The last known character position in row. */ int last_pos = MATRIX_ROW_START_CHARPOS (row) + delta; - /* The last known character position before string_start. */ - int string_before_pos; int x = row->x; int cursor_x = x; - /* Last buffer position covered by an overlay. */ - int cursor_from_overlay_pos = 0; - int pt_old = PT - delta; - - /* Skip over glyphs not having an object at the start of the row. - These are special glyphs like truncation marks on terminal - frames. */ + EMACS_INT pt_old = PT - delta; + EMACS_INT pos_before = MATRIX_ROW_START_CHARPOS (row) + delta; + EMACS_INT pos_after = MATRIX_ROW_END_CHARPOS (row) + delta; + struct glyph *glyph_before = glyph - 1, *glyph_after = end; + /* Non-zero means we've found a match for cursor position, but that + glyph has the avoid_cursor_p flag set. */ + int match_with_avoid_cursor = 0; + /* Non-zero means we've seen at least one glyph that came from a + display string. */ + int string_seen = 0; + /* Largest buffer position seen so far during scan of glyph row. */ + EMACS_INT bpos_max = last_pos; + /* Last buffer position covered by an overlay string with an integer + `cursor' property. */ + EMACS_INT bpos_covered = 0; + + /* Skip over glyphs not having an object at the start and the end of + the row. These are special glyphs like truncation marks on + terminal frames. */ if (row->displays_text_p) - while (glyph < end - && INTEGERP (glyph->object) - && glyph->charpos < 0) + { + if (!row->reversed_p) + { + while (glyph < end + && INTEGERP (glyph->object) + && glyph->charpos < 0) + { + x += glyph->pixel_width; + ++glyph; + } + while (end > glyph + && INTEGERP ((end - 1)->object) + /* CHARPOS is zero for blanks inserted by + extend_face_to_end_of_line. */ + && (end - 1)->charpos <= 0) + --end; + glyph_before = glyph - 1; + glyph_after = end; + } + else + { + struct glyph *g; + + /* If the glyph row is reversed, we need to process it from back + to front, so swap the edge pointers. */ + end = glyph - 1; + glyph += row->used[TEXT_AREA] - 1; + /* Reverse the known positions in the row. */ + last_pos = pos_after = MATRIX_ROW_START_CHARPOS (row) + delta; + pos_before = MATRIX_ROW_END_CHARPOS (row) + delta; + + while (glyph > end + 1 + && INTEGERP (glyph->object) + && glyph->charpos < 0) + { + --glyph; + x -= glyph->pixel_width; + } + if (INTEGERP (glyph->object) && glyph->charpos < 0) + --glyph; + /* By default, put the cursor on the rightmost glyph. */ + for (g = end + 1; g < glyph; g++) + x += g->pixel_width; + cursor_x = x; + while (end < glyph + && INTEGERP ((end + 1)->object) + && (end + 1)->charpos <= 0) + ++end; + glyph_before = glyph + 1; + glyph_after = end; + } + } + else if (row->reversed_p) + { + /* In R2L rows that don't display text, put the cursor on the + rightmost glyph. Case in point: an empty last line that is + part of an R2L paragraph. */ + cursor = end - 1; + x = -1; /* will be computed below, at lable compute_x */ + } + + /* Step 1: Try to find the glyph whose character position + corresponds to point. If that's not possible, find 2 glyphs + whose character positions are the closest to point, one before + point, the other after it. */ + if (!row->reversed_p) + while (/* not marched to end of glyph row */ + glyph < end + /* glyph was not inserted by redisplay for internal purposes */ + && !INTEGERP (glyph->object)) { + if (BUFFERP (glyph->object)) + { + EMACS_INT dpos = glyph->charpos - pt_old; + + if (glyph->charpos > bpos_max) + bpos_max = glyph->charpos; + if (!glyph->avoid_cursor_p) + { + /* If we hit point, we've found the glyph on which to + display the cursor. */ + if (dpos == 0) + { + match_with_avoid_cursor = 0; + break; + } + /* See if we've found a better approximation to + POS_BEFORE or to POS_AFTER. Note that we want the + first (leftmost) glyph of all those that are the + closest from below, and the last (rightmost) of all + those from above. */ + if (0 > dpos && dpos > pos_before - pt_old) + { + pos_before = glyph->charpos; + glyph_before = glyph; + } + else if (0 < dpos && dpos <= pos_after - pt_old) + { + pos_after = glyph->charpos; + glyph_after = glyph; + } + } + else if (dpos == 0) + match_with_avoid_cursor = 1; + } + else if (STRINGP (glyph->object)) + { + Lisp_Object chprop; + int glyph_pos = glyph->charpos; + + chprop = Fget_char_property (make_number (glyph_pos), Qcursor, + glyph->object); + if (INTEGERP (chprop)) + { + bpos_covered = bpos_max + XINT (chprop); + /* If the `cursor' property covers buffer positions up + to and including point, we should display cursor on + this glyph. */ + /* Implementation note: bpos_max == pt_old when, e.g., + we are in an empty line, where bpos_max is set to + MATRIX_ROW_START_CHARPOS, see above. */ + if (bpos_max <= pt_old && bpos_covered >= pt_old) + { + cursor = glyph; + break; + } + } + + string_seen = 1; + } x += glyph->pixel_width; ++glyph; } - - string_start = NULL; - while (glyph < end - && !INTEGERP (glyph->object) - && (!BUFFERP (glyph->object) - || (last_pos = glyph->charpos) < pt_old - || glyph->avoid_cursor_p)) - { - if (! STRINGP (glyph->object)) - { - string_start = NULL; - x += glyph->pixel_width; - ++glyph; - /* If we are beyond the cursor position computed from the - last overlay seen, that overlay is not in effect for - current cursor position. Reset the cursor information - computed from that overlay. */ - if (cursor_from_overlay_pos - && last_pos >= cursor_from_overlay_pos) - { - cursor_from_overlay_pos = 0; - cursor = NULL; - } - } - else - { - if (string_start == NULL) - { - string_before_pos = last_pos; - string_start = glyph; - string_start_x = x; - } - /* Skip all glyphs from a string. */ - do - { - Lisp_Object cprop; - int pos; - if ((cursor == NULL || glyph > cursor) - && (cprop = Fget_char_property (make_number ((glyph)->charpos), - Qcursor, (glyph)->object), - !NILP (cprop)) - && (pos = string_buffer_position (w, glyph->object, - string_before_pos), - (pos == 0 /* from overlay */ - || pos == pt_old))) - { - /* Compute the first buffer position after the overlay. - If the `cursor' property tells us how many positions - are associated with the overlay, use that. Otherwise, - estimate from the buffer positions of the glyphs - before and after the overlay. */ - cursor_from_overlay_pos = (pos ? 0 : last_pos - + (INTEGERP (cprop) ? XINT (cprop) : 0)); - cursor = glyph; - cursor_x = x; - } + else if (glyph > end) /* row is reversed */ + while (!INTEGERP (glyph->object)) + { + if (BUFFERP (glyph->object)) + { + EMACS_INT dpos = glyph->charpos - pt_old; + + if (glyph->charpos > bpos_max) + bpos_max = glyph->charpos; + if (!glyph->avoid_cursor_p) + { + if (dpos == 0) + { + match_with_avoid_cursor = 0; + break; + } + if (0 > dpos && dpos > pos_before - pt_old) + { + pos_before = glyph->charpos; + glyph_before = glyph; + } + else if (0 < dpos && dpos <= pos_after - pt_old) + { + pos_after = glyph->charpos; + glyph_after = glyph; + } + } + else if (dpos == 0) + match_with_avoid_cursor = 1; + } + else if (STRINGP (glyph->object)) + { + Lisp_Object chprop; + int glyph_pos = glyph->charpos; + + chprop = Fget_char_property (make_number (glyph_pos), Qcursor, + glyph->object); + if (INTEGERP (chprop)) + { + bpos_covered = bpos_max + XINT (chprop); + /* If the `cursor' property covers buffer positions up + to and including point, we should display cursor on + this glyph. */ + if (bpos_max <= pt_old && bpos_covered >= pt_old) + { + cursor = glyph; + break; + } + } + string_seen = 1; + } + --glyph; + if (glyph == end) + break; + x -= glyph->pixel_width; + } + + /* Step 2: If we didn't find an exact match for point, we need to + look for a proper place to put the cursor among glyphs between + GLYPH_BEFORE and GLYPH_AFTER. */ + if (!(BUFFERP (glyph->object) && glyph->charpos == pt_old) + && bpos_covered < pt_old) + { + if (row->ends_in_ellipsis_p && pos_after == last_pos) + { + EMACS_INT ellipsis_pos; + + /* Scan back over the ellipsis glyphs. */ + if (!row->reversed_p) + { + ellipsis_pos = (glyph - 1)->charpos; + while (glyph > row->glyphs[TEXT_AREA] + && (glyph - 1)->charpos == ellipsis_pos) + glyph--, x -= glyph->pixel_width; + /* That loop always goes one position too far, including + the glyph before the ellipsis. So scan forward over + that one. */ x += glyph->pixel_width; - ++glyph; - } - while (glyph < end && EQ (glyph->object, string_start->object)); - } - } - + glyph++; + } + else /* row is reversed */ + { + ellipsis_pos = (glyph + 1)->charpos; + while (glyph < row->glyphs[TEXT_AREA] + row->used[TEXT_AREA] - 1 + && (glyph + 1)->charpos == ellipsis_pos) + glyph++, x += glyph->pixel_width; + x -= glyph->pixel_width; + glyph--; + } + } + else if (match_with_avoid_cursor + /* zero-width characters produce no glyphs */ + || eabs (glyph_after - glyph_before) == 1) + { + cursor = glyph_after; + x = -1; + } + else if (string_seen) + { + int incr = row->reversed_p ? -1 : +1; + + /* Need to find the glyph that came out of a string which is + present at point. That glyph is somewhere between + GLYPH_BEFORE and GLYPH_AFTER, and it came from a string + positioned between POS_BEFORE and POS_AFTER in the + buffer. */ + struct glyph *stop = glyph_after; + EMACS_INT pos = pos_before; + + x = -1; + for (glyph = glyph_before + incr; + row->reversed_p ? glyph > stop : glyph < stop; ) + { + + /* Any glyphs that come from the buffer are here because + of bidi reordering. Skip them, and only pay + attention to glyphs that came from some string. */ + if (STRINGP (glyph->object)) + { + Lisp_Object str; + EMACS_INT tem; + + str = glyph->object; + tem = string_buffer_position_lim (w, str, pos, pos_after, 0); + if (tem == 0 /* from overlay */ + || pos <= tem) + { + /* If the string from which this glyph came is + found in the buffer at point, then we've + found the glyph we've been looking for. If + it comes from an overlay (tem == 0), and it + has the `cursor' property on one of its + glyphs, record that glyph as a candidate for + displaying the cursor. (As in the + unidirectional version, we will display the + cursor on the last candidate we find.) */ + if (tem == 0 || tem == pt_old) + { + /* The glyphs from this string could have + been reordered. Find the one with the + smallest string position. Or there could + be a character in the string with the + `cursor' property, which means display + cursor on that character's glyph. */ + int strpos = glyph->charpos; + + cursor = glyph; + for (glyph += incr; + EQ (glyph->object, str); + glyph += incr) + { + Lisp_Object cprop; + int gpos = glyph->charpos; + + cprop = Fget_char_property (make_number (gpos), + Qcursor, + glyph->object); + if (!NILP (cprop)) + { + cursor = glyph; + break; + } + if (glyph->charpos < strpos) + { + strpos = glyph->charpos; + cursor = glyph; + } + } + + if (tem == pt_old) + goto compute_x; + } + if (tem) + pos = tem + 1; /* don't find previous instances */ + } + /* This string is not what we want; skip all of the + glyphs that came from it. */ + do + glyph += incr; + while ((row->reversed_p ? glyph > stop : glyph < stop) + && EQ (glyph->object, str)); + } + else + glyph += incr; + } + + /* If we reached the end of the line, and END was from a string, + the cursor is not on this line. */ + if (glyph == end + && STRINGP ((glyph - incr)->object) + && row->continued_p) + return 0; + } + } + + compute_x: if (cursor != NULL) - { - glyph = cursor; - x = cursor_x; - } - else if (row->ends_in_ellipsis_p && glyph == end) - { - /* Scan back over the ellipsis glyphs, decrementing positions. */ - while (glyph > row->glyphs[TEXT_AREA] - && (glyph - 1)->charpos == last_pos) - glyph--, x -= glyph->pixel_width; - /* That loop always goes one position too far, including the - glyph before the ellipsis. So scan forward over that one. */ - x += glyph->pixel_width; - glyph++; - } - else if (string_start - && (glyph == end || !BUFFERP (glyph->object) || last_pos > pt_old)) - { - /* We may have skipped over point because the previous glyphs - are from string. As there's no easy way to know the - character position of the current glyph, find the correct - glyph on point by scanning from string_start again. */ - Lisp_Object limit; - Lisp_Object string; - struct glyph *stop = glyph; - int pos; - - limit = make_number (pt_old + 1); - glyph = string_start; - x = string_start_x; - string = glyph->object; - pos = string_buffer_position (w, string, string_before_pos); - /* If POS == 0, STRING is from overlay. We skip such glyphs - because we always put the cursor after overlay strings. */ - while (pos == 0 && glyph < stop) - { - string = glyph->object; - SKIP_GLYPHS (glyph, stop, x, EQ (glyph->object, string)); - if (glyph < stop) - pos = string_buffer_position (w, glyph->object, string_before_pos); - } - - while (glyph < stop) - { - pos = XINT (Fnext_single_char_property_change - (make_number (pos), Qdisplay, Qnil, limit)); - if (pos > pt_old) - break; - /* Skip glyphs from the same string. */ - string = glyph->object; - SKIP_GLYPHS (glyph, stop, x, EQ (glyph->object, string)); - /* Skip glyphs from an overlay. */ - while (glyph < stop - && ! string_buffer_position (w, glyph->object, pos)) - { - string = glyph->object; - SKIP_GLYPHS (glyph, stop, x, EQ (glyph->object, string)); - } - } - - /* If we reached the end of the line, and END was from a string, - the cursor is not on this line. */ - if (glyph == end && row->continued_p) + glyph = cursor; + if (x < 0) + { + struct glyph *g; + + /* Need to compute x that corresponds to GLYPH. */ + for (g = row->glyphs[TEXT_AREA], x = row->x; g < glyph; g++) + { + if (g >= row->glyphs[TEXT_AREA] + row->used[TEXT_AREA]) + abort (); + x += g->pixel_width; + } + } + + /* ROW could be part of a continued line, which might have other + rows whose start and end charpos occlude point. Only set + w->cursor if we found a better approximation to the cursor + position than we have from previously examined rows. */ + if (w->cursor.vpos >= 0 + /* Make sure cursor.vpos specifies a row whose start and end + charpos occlude point. This is because some callers of this + function leave cursor.vpos at the row where the cursor was + displayed during the last redisplay cycle. */ + && MATRIX_ROW_START_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)) <= pt_old + && pt_old < MATRIX_ROW_END_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos))) + { + struct glyph *g1 = + MATRIX_ROW_GLYPH_START (matrix, w->cursor.vpos) + w->cursor.hpos; + + /* Keep the candidate whose buffer position is the closest to + point. */ + if (BUFFERP (g1->object) + && (g1->charpos == pt_old /* an exact match always wins */ + || (BUFFERP (glyph->object) + && eabs (g1->charpos - pt_old) + < eabs (glyph->charpos - pt_old)))) return 0; - } - + /* If this candidate gives an exact match, use that. */ + if (!(BUFFERP (glyph->object) && glyph->charpos == pt_old) + /* Otherwise, keep the candidate that comes from a row + spanning less buffer positions. This may win when one or + both candidate positions are on glyphs that came from + display strings, for which we cannot compare buffer + positions. */ + && MATRIX_ROW_END_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)) + - MATRIX_ROW_START_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)) + < MATRIX_ROW_END_CHARPOS (row) - MATRIX_ROW_START_CHARPOS (row)) + return 0; + } w->cursor.hpos = glyph - row->glyphs[TEXT_AREA]; w->cursor.x = x; w->cursor.vpos = MATRIX_ROW_VPOS (row, matrix) + dvpos; @@ -13025,6 +13491,32 @@ ++row; if (!row->enabled_p) rc = CURSOR_MOVEMENT_MUST_SCROLL; + /* If rows are bidi-reordered, back up until we find a row + that does not belong to a continuation line. This is + because we must consider all rows of a continued line as + candidates for cursor positioning, since row start and + end positions change non-linearly with vertical position + in such rows. */ + /* FIXME: Revisit this when glyph ``spilling'' in + continuation lines' rows is implemented for + bidi-reordered rows. */ + if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering)) + { + while (MATRIX_ROW_CONTINUATION_LINE_P (row)) + { + xassert (row->enabled_p); + --row; + /* If we hit the beginning of the displayed portion + without finding the first row of a continued + line, give up. */ + if (row <= w->current_matrix->rows) + { + rc = CURSOR_MOVEMENT_MUST_SCROLL; + break; + } + + } + } } if (rc == CURSOR_MOVEMENT_CANNOT_BE_USED) @@ -13148,6 +13640,46 @@ } else if (scroll_p) rc = CURSOR_MOVEMENT_MUST_SCROLL; + else if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering)) + { + /* With bidi-reordered rows, there could be more than + one candidate row whose start and end positions + occlude point. We need to let set_cursor_from_row + find the best candidate. */ + /* FIXME: Revisit this when glyph ``spilling'' in + continuation lines' rows is implemented for + bidi-reordered rows. */ + int rv = 0; + + do + { + rv |= set_cursor_from_row (w, row, w->current_matrix, + 0, 0, 0, 0); + /* As soon as we've found the first suitable row + whose ends_at_zv_p flag is set, we are done. */ + if (rv + && MATRIX_ROW (w->current_matrix, w->cursor.vpos)->ends_at_zv_p) + { + rc = CURSOR_MOVEMENT_SUCCESS; + break; + } + ++row; + } + while (MATRIX_ROW_BOTTOM_Y (row) < last_y + && MATRIX_ROW_START_CHARPOS (row) <= PT + && PT <= MATRIX_ROW_END_CHARPOS (row) + && cursor_row_p (w, row)); + /* If we didn't find any candidate rows, or exited the + loop before all the candidates were examined, signal + to the caller that this method failed. */ + if (rc != CURSOR_MOVEMENT_SUCCESS + && (!rv + || (MATRIX_ROW_START_CHARPOS (row) <= PT + && PT <= MATRIX_ROW_END_CHARPOS (row)))) + rc = CURSOR_MOVEMENT_CANNOT_BE_USED; + else + rc = CURSOR_MOVEMENT_SUCCESS; + } else { do @@ -14474,15 +15006,39 @@ { struct glyph *glyph = row->glyphs[TEXT_AREA] + w->cursor.hpos; struct glyph *end = glyph + row->used[TEXT_AREA]; + struct glyph *orig_glyph = glyph; + struct cursor_pos orig_cursor = w->cursor; for (; glyph < end && (!BUFFERP (glyph->object) - || glyph->charpos < PT); + || glyph->charpos != PT); glyph++) { w->cursor.hpos++; w->cursor.x += glyph->pixel_width; } + /* With bidi reordering, charpos changes non-linearly + with hpos, so the right glyph could be to the + left. */ + if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering) + && (!BUFFERP (glyph->object) || glyph->charpos != PT)) + { + struct glyph *start_glyph = row->glyphs[TEXT_AREA]; + + glyph = orig_glyph - 1; + orig_cursor.hpos--; + orig_cursor.x -= glyph->pixel_width; + for (; glyph >= start_glyph + && (!BUFFERP (glyph->object) + || glyph->charpos != PT); + glyph--) + { + w->cursor.hpos--; + w->cursor.x -= glyph->pixel_width; + } + if (BUFFERP (glyph->object) && glyph->charpos == PT) + w->cursor = orig_cursor; + } } } @@ -14749,6 +15305,8 @@ int dy; { struct glyph_row *row = start; + struct glyph_row *best_row = NULL; + EMACS_INT mindif = BUF_ZV (XBUFFER (w->buffer)) + 1; int last_y; /* If we happen to start on a header-line, skip that. */ @@ -14781,7 +15339,30 @@ && !row->ends_at_zv_p && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row))) && charpos >= MATRIX_ROW_START_CHARPOS (row)) - return row; + { + struct glyph *g; + + if (NILP (XBUFFER (w->buffer)->bidi_display_reordering)) + return row; + /* In bidi-reordered rows, there could be several rows + occluding point. We need to find the one which fits + CHARPOS the best. */ + for (g = row->glyphs[TEXT_AREA]; + g < row->glyphs[TEXT_AREA] + row->used[TEXT_AREA]; + g++) + { + if (!STRINGP (g->object)) + { + if (g->charpos > 0 && eabs (g->charpos - charpos) < mindif) + { + mindif = eabs (g->charpos - charpos); + best_row = row; + } + } + } + } + else if (best_row) + return best_row; ++row; } } @@ -14926,6 +15507,18 @@ if (!NILP (XBUFFER (w->buffer)->word_wrap)) GIVE_UP (21); + /* Under bidi reordering, adding or deleting a character in the + beginning of a paragraph, before the first strong directional + character, can change the base direction of the paragraph (unless + the buffer specifies a fixed paragraph direction), which will + require to redisplay the whole paragraph. It might be worthwhile + to find the paragraph limits and widen the range of redisplayed + lines to that, but for now just give up this optimization and + redisplay from scratch. */ + if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering) + && NILP (XBUFFER (w->buffer)->bidi_paragraph_direction)) + GIVE_UP (22); + /* Make sure beg_unchanged and end_unchanged are up to date. Do it only if buffer has really changed. The reason is that the gap is initially at Z for freshly visited files. The code below would @@ -16284,19 +16877,37 @@ struct glyph *start = row->glyphs[TEXT_AREA]; struct glyph *glyph = start + used - 1; + if (row->reversed_p) + { + /* Right-to-left rows need to be processed in the opposite + direction, so swap the edge pointers. */ + glyph = start; + start = row->glyphs[TEXT_AREA] + used - 1; + } + /* Skip over glyphs inserted to display the cursor at the end of a line, for extending the face of the last glyph to the end of the line on terminals, and for truncation and continuation glyphs. */ - while (glyph >= start - && glyph->type == CHAR_GLYPH - && INTEGERP (glyph->object)) - --glyph; + if (!row->reversed_p) + { + while (glyph >= start + && glyph->type == CHAR_GLYPH + && INTEGERP (glyph->object)) + --glyph; + } + else + { + while (glyph <= start + && glyph->type == CHAR_GLYPH + && INTEGERP (glyph->object)) + ++glyph; + } /* If last glyph is a space or stretch, and it's trailing whitespace, set the face of all trailing whitespace glyphs in IT->glyph_row to `trailing-whitespace'. */ - if (glyph >= start + if ((row->reversed_p ? glyph <= start : glyph >= start) && BUFFERP (glyph->object) && (glyph->type == STRETCH_GLYPH || (glyph->type == CHAR_GLYPH @@ -16307,12 +16918,24 @@ if (face_id < 0) return; - while (glyph >= start - && BUFFERP (glyph->object) - && (glyph->type == STRETCH_GLYPH - || (glyph->type == CHAR_GLYPH - && glyph->u.ch == ' '))) - (glyph--)->face_id = face_id; + if (!row->reversed_p) + { + while (glyph >= start + && BUFFERP (glyph->object) + && (glyph->type == STRETCH_GLYPH + || (glyph->type == CHAR_GLYPH + && glyph->u.ch == ' '))) + (glyph--)->face_id = face_id; + } + else + { + while (glyph <= start + && BUFFERP (glyph->object) + && (glyph->type == STRETCH_GLYPH + || (glyph->type == CHAR_GLYPH + && glyph->u.ch == ' '))) + (glyph++)->face_id = face_id; + } } } } @@ -16501,6 +17124,8 @@ int wrap_row_used = -1, wrap_row_ascent, wrap_row_height; int wrap_row_phys_ascent, wrap_row_phys_height; int wrap_row_extra_line_spacing; + struct display_pos row_end; + int cvpos; /* We always start displaying at hpos zero even if hscrolled. */ xassert (it->hpos == 0 && it->current_x == 0); @@ -16589,6 +17214,11 @@ it->continuation_lines_width = 0; row->ends_at_zv_p = 1; + /* A row that displays right-to-left text must always have + its last face extended all the way to the end of line, + even if this row ends in ZV. */ + if (row->reversed_p) + extend_face_to_end_of_line (it); break; } @@ -16996,7 +17626,116 @@ compute_line_metrics (it); /* Remember the position at which this line ends. */ - row->end = it->current; + row->end = row_end = it->current; + if (it->bidi_p) + { + /* ROW->start and ROW->end must be the smallest and largest + buffer positions in ROW. But if ROW was bidi-reordered, + these two positions can be anywhere in the row, so we must + rescan all of the ROW's glyphs to find them. */ + /* FIXME: Revisit this when glyph ``spilling'' in continuation + lines' rows is implemented for bidi-reordered rows. */ + EMACS_INT min_pos = ZV + 1, max_pos = 0; + struct glyph *g; + struct it save_it; + struct text_pos tpos; + + for (g = row->glyphs[TEXT_AREA]; + g < row->glyphs[TEXT_AREA] + row->used[TEXT_AREA]; + g++) + { + if (BUFFERP (g->object)) + { + if (g->charpos > 0 && g->charpos < min_pos) + min_pos = g->charpos; + if (g->charpos > max_pos) + max_pos = g->charpos; + } + } + /* Empty lines have a valid buffer position at their first + glyph, but that glyph's OBJECT is zero, as if it didn't come + from a buffer. If we didn't find any valid buffer positions + in this row, maybe we have such an empty line. */ + if (min_pos == ZV + 1 && row->used[TEXT_AREA]) + { + for (g = row->glyphs[TEXT_AREA]; + g < row->glyphs[TEXT_AREA] + row->used[TEXT_AREA]; + g++) + { + if (INTEGERP (g->object)) + { + if (g->charpos > 0 && g->charpos < min_pos) + min_pos = g->charpos; + if (g->charpos > max_pos) + max_pos = g->charpos; + } + } + } + if (min_pos <= ZV) + { + if (min_pos != row->start.pos.charpos) + { + row->start.pos.charpos = min_pos; + row->start.pos.bytepos = CHAR_TO_BYTE (min_pos); + } + if (max_pos == 0) + max_pos = min_pos; + } + /* For ROW->end, we need the position that is _after_ max_pos, + in the logical order, unless we are at ZV. */ + if (row->ends_at_zv_p) + { + row_end = row->end = it->current; + if (!row->used[TEXT_AREA]) + { + row->start.pos.charpos = row_end.pos.charpos; + row->start.pos.bytepos = row_end.pos.bytepos; + } + } + else if (row->used[TEXT_AREA] && max_pos) + { + SET_TEXT_POS (tpos, max_pos + 1, CHAR_TO_BYTE (max_pos + 1)); + row_end = it->current; + row_end.pos = tpos; + /* If the character at max_pos+1 is a newline, skip that as + well. Note that this may skip some invisible text. */ + if (FETCH_CHAR (tpos.bytepos) == '\n' + || (FETCH_CHAR (tpos.bytepos) == '\r' && it->selective)) + { + save_it = *it; + it->bidi_p = 0; + reseat_1 (it, tpos, 0); + set_iterator_to_next (it, 1); + /* Record the position after the newline of a continued + row. We will need that to set ROW->end of the last + row produced for a continued line. */ + if (row->continued_p) + { + save_it.eol_pos.charpos = IT_CHARPOS (*it); + save_it.eol_pos.bytepos = IT_BYTEPOS (*it); + } + else + { + row_end = it->current; + save_it.eol_pos.charpos = save_it.eol_pos.bytepos = 0; + } + *it = save_it; + } + else if (!row->continued_p + && row->continuation_lines_width + && it->eol_pos.charpos > 0) + { + /* Last row of a continued line. Use the position + recorded in ROW->eol_pos, to the effect that the + newline belongs to this row, not to the row which + displays the character with the largest buffer + position. */ + row_end.pos = it->eol_pos; + it->eol_pos.charpos = it->eol_pos.bytepos = 0; + } + row->end = row_end; + } + } /* Record whether this row ends inside an ellipsis. */ row->ends_in_ellipsis_p @@ -17015,7 +17754,18 @@ it->right_user_fringe_face_id = 0; /* Maybe set the cursor. */ - if (it->w->cursor.vpos < 0 + cvpos = it->w->cursor.vpos; + if ((cvpos < 0 + /* In bidi-reordered rows, keep checking for proper cursor + position even if one has been found already, because buffer + positions in such rows change non-linearly with ROW->VPOS, + when a line is continued. One exception: when we are at ZV, + display cursor on the first suitable glyph row, since all + the empty rows after that also have their position set to ZV. */ + /* FIXME: Revisit this when glyph ``spilling'' in continuation + lines' rows is implemented for bidi-reordered rows. */ + || (it->bidi_p + && !MATRIX_ROW (it->w->desired_matrix, cvpos)->ends_at_zv_p)) && PT >= MATRIX_ROW_START_CHARPOS (row) && PT <= MATRIX_ROW_END_CHARPOS (row) && cursor_row_p (it->w, row)) @@ -17033,7 +17783,11 @@ it->current_y += row->height; ++it->vpos; ++it->glyph_row; - it->start = it->current; + /* The next row should use same value of the reversed_p flag as this + one. set_iterator_to_next decides when it's a new paragraph, and + PRODUCE_GLYPHS recomputes the value of the flag accordingly. */ + it->glyph_row->reversed_p = row->reversed_p; + it->start = row_end; return row->displays_text_p; } @@ -20562,6 +21316,17 @@ glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area]; if (glyph < it->glyph_row->glyphs[area + 1]) { + /* If the glyph row is reversed, we need to prepend the glyph + rather than append it. */ + if (it->glyph_row->reversed_p && area == TEXT_AREA) + { + struct glyph *g; + + /* Make room for the additional glyph. */ + for (g = glyph - 1; g >= it->glyph_row->glyphs[area]; g--) + g[1] = *g; + glyph = it->glyph_row->glyphs[area]; + } glyph->charpos = CHARPOS (it->position); glyph->object = it->object; if (it->pixel_width > 0) @@ -20591,6 +21356,18 @@ glyph->u.ch = it->char_to_display; glyph->slice = null_glyph_slice; glyph->font_type = FONT_TYPE_UNKNOWN; + if (it->bidi_p) + { + glyph->resolved_level = it->bidi_it.resolved_level; + if ((it->bidi_it.type & 7) != it->bidi_it.type) + abort (); + glyph->bidi_type = it->bidi_it.type; + } + else + { + glyph->resolved_level = 0; + glyph->bidi_type = UNKNOWN_BT; + } ++it->glyph_row->used[area]; } else @@ -20643,6 +21420,13 @@ glyph->face_id = it->face_id; glyph->slice = null_glyph_slice; glyph->font_type = FONT_TYPE_UNKNOWN; + if (it->bidi_p) + { + glyph->resolved_level = it->bidi_it.resolved_level; + if ((it->bidi_it.type & 7) != it->bidi_it.type) + abort (); + glyph->bidi_type = it->bidi_it.type; + } ++it->glyph_row->used[area]; } else @@ -20817,6 +21601,13 @@ glyph->u.img_id = img->id; glyph->slice = slice; glyph->font_type = FONT_TYPE_UNKNOWN; + if (it->bidi_p) + { + glyph->resolved_level = it->bidi_it.resolved_level; + if ((it->bidi_it.type & 7) != it->bidi_it.type) + abort (); + glyph->bidi_type = it->bidi_it.type; + } ++it->glyph_row->used[area]; } else @@ -20863,6 +21654,13 @@ glyph->u.stretch.height = height; glyph->slice = null_glyph_slice; glyph->font_type = FONT_TYPE_UNKNOWN; + if (it->bidi_p) + { + glyph->resolved_level = it->bidi_it.resolved_level; + if ((it->bidi_it.type & 7) != it->bidi_it.type) + abort (); + glyph->bidi_type = it->bidi_it.type; + } ++it->glyph_row->used[area]; } else @@ -22679,9 +23477,6 @@ /* Switch the display of W's cursor on or off, according to the value of ON. */ -#ifndef HAVE_NS -static -#endif void update_window_cursor (w, on) struct window *w; @@ -23040,7 +23835,7 @@ associated with the end position, which must not be highlighted. */ Lisp_Object prev_object; - int pos; + EMACS_INT pos; while (glyph > row->glyphs[TEXT_AREA]) { @@ -23600,7 +24395,8 @@ #endif if (NILP (Vmouse_highlight) - || !f->glyphs_initialized_p) + || !f->glyphs_initialized_p + || f->pointer_invisible) return; dpyinfo->mouse_face_mouse_x = x; @@ -23672,7 +24468,8 @@ && XFASTINT (w->last_modified) == BUF_MODIFF (b) && XFASTINT (w->last_overlay_modified) == BUF_OVERLAY_MODIFF (b)) { - int hpos, vpos, pos, i, dx, dy, area; + int hpos, vpos, i, dx, dy, area; + EMACS_INT pos; struct glyph *glyph; Lisp_Object object; Lisp_Object mouse_face = Qnil, overlay = Qnil, position; @@ -23960,7 +24757,7 @@ struct glyph_row *r = MATRIX_ROW (w->current_matrix, vpos); int start = MATRIX_ROW_START_CHARPOS (r); - int pos = string_buffer_position (w, object, start); + EMACS_INT pos = string_buffer_position (w, object, start); if (pos > 0) { help = Fget_char_property (make_number (pos), @@ -24015,7 +24812,8 @@ struct glyph_row *r = MATRIX_ROW (w->current_matrix, vpos); int start = MATRIX_ROW_START_CHARPOS (r); - int pos = string_buffer_position (w, object, start); + EMACS_INT pos = string_buffer_position (w, object, + start); if (pos > 0) pointer = Fget_char_property (make_number (pos), Qpointer, w->buffer); @@ -24824,6 +25622,11 @@ staticpro (&previous_help_echo_string); help_echo_pos = -1; + Qright_to_left = intern_c_string ("right-to-left"); + staticpro (&Qright_to_left); + Qleft_to_right = intern_c_string ("left-to-right"); + staticpro (&Qleft_to_right); + #ifdef HAVE_WINDOW_SYSTEM DEFVAR_BOOL ("x-stretch-cursor", &x_stretch_cursor_p, doc: /* *Non-nil means draw block cursor as wide as the glyph under it. diff -r 86c85c80cd84 -r 5a619d0a9158 src/xterm.c --- a/src/xterm.c Mon Mar 29 14:00:56 2010 +0000 +++ b/src/xterm.c Thu Apr 01 14:34:20 2010 +0000 @@ -50,9 +50,9 @@ #include <sys/types.h> #endif /* makedev */ -#ifdef BSD_SYSTEM +#ifdef HAVE_SYS_IOCTL_H #include <sys/ioctl.h> -#endif /* ! defined (BSD_SYSTEM) */ +#endif /* ! defined (HAVE_SYS_IOCTL_H) */ #include "systime.h" diff -r 86c85c80cd84 -r 5a619d0a9158 test/ChangeLog --- a/test/ChangeLog Mon Mar 29 14:00:56 2010 +0000 +++ b/test/ChangeLog Thu Apr 01 14:34:20 2010 +0000 @@ -1,3 +1,38 @@ +2010-03-29 Chong Yidong <cyd@stupidchicken.com> + + * cedet/semantic-ia-utest.el + (semantic-symref-test-count-hits-in-tag): Add function, from + semantic-test.el. + + * cedet/tests/test.cpp: + * cedet/tests/test.py: + * cedet/tests/teststruct.cpp: + * cedet/tests/testtemplates.cpp: + * cedet/tests/testusing.cpp: + * cedet/tests/scopetest.cpp: + * cedet/tests/scopetest.java: Files deleted. + + * cedet/tests/test.make: + * cedet/tests/test.c: + * cedet/tests/testjavacomp.java: + * cedet/tests/testspp.c: + * cedet/tests/testsppreplace.c: + * cedet/tests/testsppreplaced.c: + * cedet/tests/testsubclass.cpp: + * cedet/tests/testsubclass.hh: + * cedet/tests/testtypedefs.cpp: + * cedet/tests/testvarnames.c: + * cedet/tests/test.el: + * cedet/tests/testdoublens.cpp: + * cedet/tests/testdoublens.hpp: Add copyright header. + + * cedet/semantic-tests.el (semanticdb-test-gnu-global): + Remove reference to deleted files. + +2010-03-30 Juri Linkov <juri@jurta.org> + + * occur-testsuite.el (occur-tests): Add tests for context lines. + 2010-03-23 Juri Linkov <juri@jurta.org> * occur-testsuite.el: New file. diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/semantic-ia-utest.el --- a/test/cedet/semantic-ia-utest.el Mon Mar 29 14:00:56 2010 +0000 +++ b/test/cedet/semantic-ia-utest.el Thu Apr 01 14:34:20 2010 +0000 @@ -42,10 +42,7 @@ "tests/testdoublens.cpp" "tests/testsubclass.cpp" "tests/testtypedefs.cpp" - "tests/teststruct.cpp" - "tests/testtemplates.cpp" "tests/testfriends.cpp" - "tests/testusing.cpp" "tests/testnsp.cpp" "tests/testsppcomplete.c" "tests/testvarnames.c" @@ -419,6 +416,27 @@ )) +(defun semantic-symref-test-count-hits-in-tag () + "Lookup in the current tag the symbol under point. +Then count all the other references to the same symbol within the +tag that contains point, and return that." + (interactive) + (let* ((ctxt (semantic-analyze-current-context)) + (target (car (reverse (oref ctxt prefix)))) + (tag (semantic-current-tag)) + (start (current-time)) + (Lcount 0)) + (when (semantic-tag-p target) + (semantic-symref-hits-in-region + target (lambda (start end prefix) (setq Lcount (1+ Lcount))) + (semantic-tag-start tag) + (semantic-tag-end tag)) + (when (interactive-p) + (message "Found %d occurrences of %s in %.2f seconds" + Lcount (semantic-tag-name target) + (semantic-elapsed-time start (current-time)))) + Lcount))) + (defun semantic-src-utest-buffer-refs () "Run a sym-ref counting unit-test pass in the current buffer." diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/semantic-tests.el --- a/test/cedet/semantic-tests.el Mon Mar 29 14:00:56 2010 +0000 +++ b/test/cedet/semantic-tests.el Thu Apr 01 14:34:20 2010 +0000 @@ -107,53 +107,6 @@ (data-debug-new-buffer "*SemanticDB Gnu Global Result*") (data-debug-insert-thing result "?" "")))) -;;; From semantic-find - -(require 'semantic/find) - -(defun semantic-find-benchmark () - "Run some simple benchmarks to see how we are doing. -Optional argument ARG is the number of iterations to run." - (interactive) - (require 'benchmark) - (let ((f-name nil) - (b-name nil) - (f-comp) - (b-comp) - (f-regex) - ) - (garbage-collect) - (setq f-name - (benchmark-run-compiled - 1000 (semantic-find-first-tag-by-name "class3" - "test/test.cpp"))) - (garbage-collect) - (setq b-name - (benchmark-run-compiled - 1000 (semantic-brute-find-first-tag-by-name "class3" - "test/test.cpp"))) - (garbage-collect) - (setq f-comp - (benchmark-run-compiled - 1000 (semantic-find-tags-for-completion "method" - "test/test.cpp"))) - (garbage-collect) - (setq b-comp - (benchmark-run-compiled - 1000 (semantic-brute-find-tag-by-name-regexp "^method" - "test/test.cpp"))) - (garbage-collect) - (setq f-regex - (benchmark-run-compiled - 1000 (semantic-find-tags-by-name-regexp "^method" - "test/test.cpp"))) - - (message "Name [new old] [ %.3f %.3f ] Complete [newc/new old] [ %.3f/%.3f %.3f ]" - (car f-name) (car b-name) - (car f-comp) (car f-regex) - (car b-comp)) - )) - ;;; From semantic-format (require 'semantic/format) diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/scopetest.cpp --- a/test/cedet/tests/scopetest.cpp Mon Mar 29 14:00:56 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* Test scoping rules for c++ in the analyzer. */ - -namespace { - - class aclass2; // Forward reference. - - class aclass1 { - private: - int attrp1; - int amethodp1(int argp1); - aclass2 areference; - protected: - int attrpr1; - public: - int attr1; - int amethod1(int arg1); - }; -} - -namespace { - class aclass2 : public aclass1 - { - private: - int attrp2; - int amethodp2(int argp1); - public: - aclass2(int aninitvalue); - ~aclass2(); - int attr2; - int amethod2(int arg2); - }; -} - -aclass2::aclass2(init aninitvalue) -{ - /* This is a comment that talks about aclass1 */ - aclass1; -} - -int aclass2::amethod2(int arg2) -{ - int alocalvar; - float q; - - ac; -} - -// arch-tag: 9336063c-6b2e-4677-a390-d2dd091a2474 diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/scopetest.java --- a/test/cedet/tests/scopetest.java Mon Mar 29 14:00:56 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -class Foo { - - public void a1() {} - - class Bar { - - public int a2() {} - - public void b() { - a // -1- - } - - class Baz { - - public int a3() {} - - public Baz(int a4) { - a // -2- - } - - } - - } - -} \ No newline at end of file diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/templates.cpp --- a/test/cedet/tests/templates.cpp Mon Mar 29 14:00:56 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,130 +0,0 @@ -// C++ examples and requests from Klaus Berndl - -// template in a unnamed namespace -namespace -{ - template<typename Target, typename Source> - Target lexical_cast(Source arg) - { - std::stringstream interpreter; - Target result; - - if(!(interpreter << arg) || !(interpreter >> result) || - !(interpreter >> std::ws).eof()) - throw bad_lexical_cast(); - - return result; - } -} - - -template <class T, FOO> class Vector -{ -private: - static T* v; - int sz; - -public: - T& elem(int i) {return v[i];} - virtual ~Vector (); - -protected: - Vector (); -}; - -template <> class Vector <void*> -{ -private: - void** v; - int sz; - -public: - Vector (); - virtual int func1(int i); - virtual int func2(int i) = 0; - static virtual int func3(int i) = 0; - void*& elem(int i) {return v[i];} - //... -}; - -// template contains namespace -typedef vector<CzkUtilities::Action*> ActionList; - -// declaration of some template-types -map<XXX, Test::YYY>** map_var; - -map_with_size<XXX, Test::YYY, size> map_size_var; -typedef map_with_size<XXX, Test::YYY, size> SizedMap; - -map_with_10_size<XXX, Test::YYY, 10>* pMap_size10_var; -typedef map_with_10_size<XXX, Test::YYY, 10> Size10Map; - -// a function which such a template-argument -void* test_function(map<ClassX, Test::ClassY, 10>* pMap); - - -template <class T> class Vector <T*> : private Vector <void*> -{ -public: - typedef Vector <void*> Base; - - Vector () : Base() {} - - T*& elem(int i) {return static_cast<T*&>(Base::elem(i));} - //... -}; - -// outside method implementation of a template-class -template<class T> T& Vector<T*>::elem(int i) -{ - return C; -} - -// same but qualified with a namespace Testnamespace -template<class T> T& Testnamespace::Vector<T*>::elem(int i) -{ - return C; -} - -// function templates with keyword typename -template<typename Target, typename Source> -Target lexical_cast(Source arg) -{ - std::stringstream interpreter; - Target result; - - if(!(interpreter << arg) || !(interpreter >> result) || - !(interpreter >> std::ws).eof()) - throw bad_lexical_cast(); - - return result; -} - -template<class T> -static -typename T::_ptr_type -getService(const std::string& pServiceName, const int pRetries=20) -{ - return T::_narrow(getServiceObject(pServiceName, pRetries)); -} - -// function template declaration -template<class T> void sort(vector<T>&); -// complex function template definition -template<class T, class S, const NamespaceY::ClassX<TestClass, &s> volatile ***&i> -map<ClassY, ClassX, 10> -sort(const vector<T>& v) -{ - return; -} - -// variable declarations of template-types -foo<TClass, Testnamespace::XClass, i> *bar1; -foo<TClass, Testnamespace::XClass, **&i> *bar2; -foo<TClass, Testnamespace::XClass, *Namespace::ClassX::i> bar3; -foo<0> bar0; - -class SomeName; -class OtherName; - -// arch-tag: 55ff74de-74dc-44ad-8252-50dc5f3492c3 diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/test.c --- a/test/cedet/tests/test.c Mon Mar 29 14:00:56 2010 +0000 +++ b/test/cedet/tests/test.c Thu Apr 01 14:34:20 2010 +0000 @@ -1,6 +1,29 @@ -/* Test file for C language. - * Attempt to include as many aspects of the C language as possible. +/* test.c --- Semantic unit test for C. + + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, + 2010 Free Software Foundation, Inc. + + Author: Eric M. Ludlam <eric@siege-engine.com> + + This file is part of GNU Emacs. + + GNU Emacs is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + GNU Emacs is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. +*/ + +/* Attempt to include as many aspects of the C language as possible. */ + /* types of include files */ #include "includeme1.h" #include <includeme2.h> diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/test.cpp --- a/test/cedet/tests/test.cpp Mon Mar 29 14:00:56 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,592 +0,0 @@ -/* Test file for C++ language. - * Attempt to include as many aspects of the C++ language as possible. - * Do not include things tested in test.c since that shares the - * same language. - */ - -/* An include test */ -#include <stdio.h> - -#include <cmath> - -#include "c++-test.hh" - -#include <c++-test.hh> - -double var1 = 1.2; - -int simple1(int a) { - -} - -struct foo1 { - int test; -}; - -struct foo2 : public foo1 { - const int foo21(int a, int b); - const int foo22(int a, int b) { return 1 } -}; - -/* Classes */ -class class1 { -private: - int var11; - struct foo1 var12; -public: - int p_var11; - struct foo p_var12; -}; - -class i_class1 : public class1 { -private: - int var11; - struct foo var12; -public: - int p_var11; - struct foo p_var12; -}; - -class class2 { -private: - int var21; - struct foo var22; -public: - int p_var21; - struct foo p_var22; -}; - -class i_class2 : public class1, public class2 { -private: - int var21; - struct foo var22; -protected: - int pt_var21; -public: - int p_var21; - struct foo p_var22; -}; - -class class3 { - /* A class with strange things in it */ -public: - class3(); /* A constructor */ - enum embedded_foo_enum { - a, b, c - } embed1; - struct embedded_bar_struct { - int a; - int b; - } embed2; - class embedded_baz_class { - embedded_baz_class(); - ~embedded_baz_class(); - } embed3; - ~class3(); /* destructor */ - - /* Methods */ - int method_for_class3(int a, char b); - - int inline_method(int c) { return c; } - - /* Operators */ - class3& operator^= (const class3& something); - - /* Funny declmods */ - const class3 * const method_const_ptr_ptr(const int * const argconst) const = 0; -}; - -class3::class3() -{ - /* Constructor outside the definition. */ -} - -int class3::method_for_class3(int a, char b) -{ -} - -int class3::method1_for_class3( int a, int &b) -{ - int cvariablename; - class3 fooy[]; - class3 moose = new class3; - - // Complktion testing line should find external members. - a = fooy[1].me ; - b = cv ; - - if (fooy.emb) { - simple1(c); - } - - cos(10); - abs(10); - - return 1; -} - -char class3::method2_for_class3( int a, int b) throw ( exception1 ) -{ - return 'a'; -} - -void *class3::method3_for_class3( int a, int b) throw ( exception1, exception2 ) -{ - int q = a; - return "Moose"; -} - -void *class3::method31_for_class3( int a, int b) throw ( ) -{ - int q = a; - return "Moose"; -} - -void *class3::method4_for_class3( int a, int b) reentrant -{ - class3 ct; - - ct.method5_for_class3(1,a); - - pritf(); -} - -/* - * A method on class3. - */ -void *class3::method5_for_class3( int a, int b) const -{ -} - -/* - * Namespace parsing tests - */ -namespace NS { - class class_in_namespace { - int equiv(const NS::class_in_namespace *) const; - }; -} - -int NS::class_in_namespace::equiv(const NS::class_in_namespace *cin) const -{ - return 0; -} - -// Stuff Klaus found. -// Inheritance w/out a specifying for public. -class class4 : class1 { - // Pure virtual methods. - void virtual print () const = 0; - -public: - // The whacky constructor type - class4() - try : class1(args) - { - // constructor body - } - catch () - { - - } - - -}; - -class class5 : public virtual class4 { - // Virtual inheritance -}; - -class class6 : class1 { - // Mutable - mutable int i; -}; - -/* Namespaces */ -namespace namespace1 { - void ns_method1() { } - - class n_class1 { - public: - void method11(int a) { } - }; - - /* This shouldn't parse due to missing semicolon. */ - class _n_class2 : public n_class1 { - void n_c2_method1(int a, int b) { } - }; - - // Macros in the namespace -#define NSMACRO 1 - - // Template in the namespace - template<class T> T nsti1(const Foo& foo); - template<> int nsti1<int>(const Foo& foo); - -} - -namespace namespace2 { - - using namespace1::n_class1; - -} - -/* Initializers */ -void tinitializers1(): inita1(False), - inita2(False) -{ - inita1= 1; -} - -/* How about Extern C type things. */ -int funny_prototype(int ,int b,float c) -{ - -} - -extern "C" -int extern_c_1(int a, int b) -{ - - funny_prototype(1,2,3.4); - - printf("Moose", ); - - return 1; -} - -extern "C" { - - int extern_c_2(int a, int b) - { - return 1; - } - -} - -// Some operator stuff -class Action -{ - // Problems!! operator() and operator[] can not be parsed with semantic - // 1.4.2 but with latest c.by - virtual void operator()(int i, char *p ) = 0; - virtual String& operator[]() = 0; - virtual void operator!() = 0; - virtual void operator->() = 0; - virtual T& operator+=(); - virtual T& operator*(); - virtual T& operator*=(); -}; - -// class with namespace qualified parents -class Multiinherit : public virtual POA::Parent, - public virtual POA::Parent1, - Parent -{ -private: - int i; - -public: - Multiinherit(); - ~Multiinherit(); - - // method with a list of qualified exceptions - void* throwtest() - throw(Exception0, - Testnamespace::Exception1, - Testnamespace::Excpetion2, - Testnamespace::testnamespace1::Exception3); - -}; - -void* -Multiinherit::throwtest() - throw (Exception0, - Testnamespace::Exception1, - Testnamespace::Excpetion2, - Testnamespace::testnamespace1::Exception3) -{ - return; -} - -// Jens Rock <jens.rock@asamnet.de>: Nested classes or structs defined -// outside of the containing class/struct. -class container -{ - public: - struct contained; - container(); - ~container(); -}; - -struct container::contained -{ - public: - contained(); - ~contained(); -}; - -/* - * Ok, how about some template stuff. - */ -template <class CT, class container = vector<CT> > -const CT& max (const CT& a, const CT& b) -{ - return a < b ? b : a; -} - -// Arne Schmitz found this one -std::vector<int> &a, &b, &c; - -class TemplateUsingClass -{ - typedef TestClassMap::iterator iterator; - typedef map<long, long> TestClassMap; - - // typedefs with const and volatile - typedef const map<long, long> const_TestClassMap; - typedef TestClassMap<string>::iterator volatile volatile_iterator; - - map<int, int> mapclassvarthingy; -}; - -template<class T> T ti1(const Foo& foo); -template<> int ti1<int>(const Foo& foo); - - -// ----------------------------------- -// Now some namespace and related stuff -// ----------------------------------- - -using CORBA::LEX::get_token; -using Namespace1; - -using namespace POA::std; -using namespace Test; - - - -namespace Parser -{ - namespace - { - using Lexer::get_test; - string str = ""; - } - - namespace XXX - { - - class Foobar : public virtual POA::Parent, - public virtual POA::Parent1, - private POA::list<fact>, - private map<string> - { - ini i; - list <shared_ptr<item> >::const_iterator l; - public: - - Foobar(); - ~Foobar(); - }; - } - - - void test_function(int i); - -}; - -// unnamed namespaces - even nested -namespace -{ - namespace - { - using Lexer::get_test; - string str = ""; - } - - // some builtin types - long long ll = 0; - long double d = 0.0; - unsigned test; - unsigned long int **uli = 0; - signed si = 0; - signed short ss = 0; - short int i = 0; - long int li = 0; - - // expressions with namespace/class-qualifyiers - ORB_var cGlobalOrb = ORB::_nil(); - ORB_var1 cGlobalOrb1 = ORB::_test; - - class Testclass - { - #define TEST 0 - ini i; - - public: - - Testclass(); - ~Testclass(); - }; - - static void test_function(unsigned int i); - -}; - - -// outside method implementations which should be grouped to type Test -XXX& -Test::waiting() -{ - return; -} - -void -Test::print() -{ - return; -} - -// outside method implementations with namespaces which should be grouped to -// their complete (incl. namespace) types -void* -Parser::XXX::Foobar::wait(int i, const char const * const * p) -{ - return; -} - -void* -Namespace1::Test::wait1(int i) -{ - return; -} - -int -Namespace1::Test::waiting(int i) -{ - return; -} - -// a class with some outside implementations which should all be grouped to -// this class declaration -class ClassWithExternals -{ -private: - int i; - -public: - ClassWithExternals(); - ~ClassWithExternals(); - void non_nil(); -}; - - -// Foobar is not displayed; seems that semantic tries to add this to the class -// Foobar but can not find/display it, because contained in the namespace above. -void -Foobar::non_nil() -{ - return; -} - -// are correctly grouped to the ClassWithExternals class -void -ClassWithExternals::non_nil() -{ - String s = "lödfjg dlfgkdlfkgjdl"; - return; -} - -ClassWithExternals::ClassWithExternals() -{ - return; -} - -void -ClassWithExternals::~ClassWithExternals() -{ - return; -} - - -// ------------------------------- -// Now some macro and define stuff -// ------------------------------- - -#define TEST 0 -#define TEST1 "String" - -// The first backslash makes this macro unmatched syntax with semantic 1.4.2! -// With flexing \+newline as nothing all is working fine! -#define MZK_ENTER(METHOD) \ -{ \ - CzkMethodLog lMethodLog(METHOD,"Framework");\ -} - -#define ZK_ASSERTM(METHOD,ASSERTION,MESSAGE) \ - { if(!(ASSERTION))\ - {\ - std::ostringstream lMesgStream; \ - lMesgStream << "Assertion failed: " \ - << MESSAGE; \ - CzkLogManager::doLog(CzkLogManager::FATAL,"",METHOD, \ - "Assert",lMesgStream); \ - assert(ASSERTION);\ - }\ - } - -// Test if not newline-backslashes are handled correctly -string s = "My \"quoted\" string"; - -// parsed fine as macro -#define FOO (arg) method(arg, "foo"); - -// With semantic 1.4.2 this parsed as macro BAR *and* function method. -// With latest c.bnf at least one-liner macros can be parsed correctly. -#define BAR (arg) CzkMessageLog method(arg, "bar"); - -// some const and volatile stuff -char * p1 = "Hello"; // 1. variable Pointer, variable Data -const char * p2 = "Hello"; // 2. variable pointer, constant data -char * const p3 = "Hello"; // 3. constant pointer, variable data -const char * const p4 = "Hello"; // 4. constant pointer, constant data - -// Case 2 and 4 can exchange first "const" and "char" -char const * p21 = "Hello"; // variable pointer, constant data -char const * const p41 = "Hello"; // constant pointer, constant data - -char volatile a = 0; // a volatile char -void foo(bar const &arg); // a reference to a const bar -int foobar(bar const * const p); // a const pointer to a const bar -int foobar(bar const volatile * const p); // a const pointer to a const bar -int foobar3(char* p); // a const pointer to a const bar - -// Should not be parsed because this is invalid code -int const & const r3 = i; - -boolean i = 0; -boolean & r1 = i; -boolean const & r2 = i; - -// const * sequences can be very long in C++ ;-) -char const * const * const * const * ppp; - -// complex function declarationen with named pointer-arguments -const char** foobar1(volatile char const * const **p); -const char** foobar11(volatile Test::Namespace::Char<char*> const * const **p); - -// complex function declarationen with unnamed pointer-arguments -const char* foobar2(const char***); -const char* foobar21(const Test::Namespace::Char<char>***); - -// string literal parsing even with wchar_t -char const *p = "string1"; -char const *q = "string1" "str\"ing2" "string3"; -wchar_t testc = L'a'; - -wchar_t const *wp = L"string with a \" in it"; -wchar_t const *wq = L"string \n\t\"test" L"string2"; -wchar_t const *wr = L"string L"; - -// arch-tag: 59828880-d72f-4059-922f-89579edf9e58 diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/test.el --- a/test/cedet/tests/test.el Mon Mar 29 14:00:56 2010 +0000 +++ b/test/cedet/tests/test.el Thu Apr 01 14:34:20 2010 +0000 @@ -1,6 +1,24 @@ -;; Test file for Emacs Lisp. -;; Attempt to include as many aspects of Emacs Lisp as possible. -;; +;;; test.el --- Unit test file for Semantic Emacs Lisp support. + +;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +;; Free Software Foundation, Inc. + +;; Author: Eric M. Ludlam <eric@siege-engine.com> + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. ;;; Require ;; @@ -88,7 +106,7 @@ (autoload (quote a-autoload) "somefile" "Non-interactive autoload." nil nil) -(autoload (quote a-autoload-interactive) "somefile" +(autoload (quote a-autoload-interactive) "somefile" "Interactive autoload." t nil) @@ -116,7 +134,7 @@ (slot-1 :equal 'eq) slot-2) -(defstruct test-struct-2 +(defstruct test-struct-2 slot-1 slot-2) diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/test.make --- a/test/cedet/tests/test.make Mon Mar 29 14:00:56 2010 +0000 +++ b/test/cedet/tests/test.make Thu Apr 01 14:34:20 2010 +0000 @@ -1,4 +1,23 @@ -# Test makefile -*- makefile -*- +# test.make --- Semantic unit test for Make -*- makefile -*- + +# Copyright (C) 2001, 2002, 2010 Free Software Foundation, Inc. + +# Author: Eric M. Ludlam <eric@siege-engine.com> + +# This file is part of GNU Emacs. + +# GNU Emacs is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# GNU Emacs is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. top= ede_FILES=Project.ede Makefile diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/test.py --- a/test/cedet/tests/test.py Mon Mar 29 14:00:56 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,580 +0,0 @@ -# Test file for Python language. -# - -# Simle class compount statement with blank lines sprinkled. -class Foo(Bar): - - x = 1 - - y = 2 - -# Simple def statement with no argument -def sss(): - i = 1 - -# Simple def statement with arguments -def ttt(x,y,z): - i = 1 - -import foo - -for x in y: - print x - -while y > 0: - y = y - 1 - -a=b=c=d=e=f=i=j=k=l=m=n=o=p=q=r=s=t=x=y=1 - -if x: - x = 2 - y = 3 - -x = 2 -y = 3 -s and t -q | r -o ^ p -m & n -k << l -z = 4 -i >> j -e / f -c * d -a + b -2 ** 5 -x -s = "a" "b" "c" -1 - -# implicit continuation lines, see -# http://docs.python.org/ref/implicit-joining.html - -a_list = [ 1, 2, 3, - 4, 5, - 6 ] - -a_tuple = (1, 2, 3, - - 4, 5, 6) - -a_hash = { 'a':1, "b":2, - 'c' : 3, - "d" : 4 } - - -def longarglist(a, - b, - c, - d): - a=1; - b=1; - c=1; - d=1; - -class longclasslist(xx.yyy, - zz.aa): - foo=1 - - -# wisent-python.wy chokes on this! -ryk 6/17/02 - -class HTTPServer(xxx.yyy): - allow_reuse_address = 1 # Seems to make sense in testing environment - def server_bind(self): - SocketServer.TCPServer.server_bind(self) - host, port = self.socket.getsockname() - self.server_name = socket.getfqdn(host) - self.server_port = port - - -######################################################################### -### /usr/lib/python2.2/BaseHTTPServer.py -######################################################################### - -"""HTTP server base class. - -Note: the class in this module doesn't implement any HTTP request; see -SimpleHTTPServer for simple implementations of GET, HEAD and POST -(including CGI scripts). - -Contents: - -- BaseHTTPRequestHandler: HTTP request handler base class -- test: test function - -XXX To do: - -- send server version -- log requests even later (to capture byte count) -- log user-agent header and other interesting goodies -- send error log to separate file -- are request names really case sensitive? - -""" - - -# See also: -# -# HTTP Working Group T. Berners-Lee -# INTERNET-DRAFT R. T. Fielding -# <draft-ietf-http-v10-spec-00.txt> H. Frystyk Nielsen -# Expires September 8, 1995 March 8, 1995 -# -# URL: http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-v10-spec-00.txt - - -# Log files -# --------- -# -# Here's a quote from the NCSA httpd docs about log file format. -# -# | The logfile format is as follows. Each line consists of: -# | -# | host rfc931 authuser [DD/Mon/YYYY:hh:mm:ss] "request" ddd bbbb -# | -# | host: Either the DNS name or the IP number of the remote client -# | rfc931: Any information returned by identd for this person, -# | - otherwise. -# | authuser: If user sent a userid for authentication, the user name, -# | - otherwise. -# | DD: Day -# | Mon: Month (calendar name) -# | YYYY: Year -# | hh: hour (24-hour format, the machine's timezone) -# | mm: minutes -# | ss: seconds -# | request: The first line of the HTTP request as sent by the client. -# | ddd: the status code returned by the server, - if not available. -# | bbbb: the total number of bytes sent, -# | *not including the HTTP/1.0 header*, - if not available -# | -# | You can determine the name of the file accessed through request. -# -# (Actually, the latter is only true if you know the server configuration -# at the time the request was made!) - - -__version__ = "0.2" - -__all__ = ["HTTPServer", "BaseHTTPRequestHandler"] - -import sys -import time -import socket # For gethostbyaddr() -import mimetools -import SocketServer - -# Default error message -DEFAULT_ERROR_MESSAGE = """\ -<head> -<title>Error response - - -

Error response

-

Error code %(code)d. -

Message: %(message)s. -

Error code explanation: %(code)s = %(explain)s. - -""" - - -class HTTPServer(SocketServer.TCPServer): - - allow_reuse_address = 1 # Seems to make sense in testing environment - - def server_bind(self): - """Override server_bind to store the server name.""" - SocketServer.TCPServer.server_bind(self) - host, port = self.socket.getsockname() - self.server_name = socket.getfqdn(host) - self.server_port = port - - -class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler): - - """HTTP request handler base class. - - The following explanation of HTTP serves to guide you through the - code as well as to expose any misunderstandings I may have about - HTTP (so you don't need to read the code to figure out I'm wrong - :-). - - HTTP (HyperText Transfer Protocol) is an extensible protocol on - top of a reliable stream transport (e.g. TCP/IP). The protocol - recognizes three parts to a request: - - 1. One line identifying the request type and path - 2. An optional set of RFC-822-style headers - 3. An optional data part - - The headers and data are separated by a blank line. - - The first line of the request has the form - - - - where is a (case-sensitive) keyword such as GET or POST, - is a string containing path information for the request, - and should be the string "HTTP/1.0". is encoded - using the URL encoding scheme (using %xx to signify the ASCII - character with hex code xx). - - The protocol is vague about whether lines are separated by LF - characters or by CRLF pairs -- for compatibility with the widest - range of clients, both should be accepted. Similarly, whitespace - in the request line should be treated sensibly (allowing multiple - spaces between components and allowing trailing whitespace). - - Similarly, for output, lines ought to be separated by CRLF pairs - but most clients grok LF characters just fine. - - If the first line of the request has the form - - - - (i.e. is left out) then this is assumed to be an HTTP - 0.9 request; this form has no optional headers and data part and - the reply consists of just the data. - - The reply form of the HTTP 1.0 protocol again has three parts: - - 1. One line giving the response code - 2. An optional set of RFC-822-style headers - 3. The data - - Again, the headers and data are separated by a blank line. - - The response code line has the form - - - - where is the protocol version (always "HTTP/1.0"), - is a 3-digit response code indicating success or - failure of the request, and is an optional - human-readable string explaining what the response code means. - - This server parses the request and the headers, and then calls a - function specific to the request type (). Specifically, - a request SPAM will be handled by a method do_SPAM(). If no - such method exists the server sends an error response to the - client. If it exists, it is called with no arguments: - - do_SPAM() - - Note that the request name is case sensitive (i.e. SPAM and spam - are different requests). - - The various request details are stored in instance variables: - - - client_address is the client IP address in the form (host, - port); - - - command, path and version are the broken-down request line; - - - headers is an instance of mimetools.Message (or a derived - class) containing the header information; - - - rfile is a file object open for reading positioned at the - start of the optional input data part; - - - wfile is a file object open for writing. - - IT IS IMPORTANT TO ADHERE TO THE PROTOCOL FOR WRITING! - - The first thing to be written must be the response line. Then - follow 0 or more header lines, then a blank line, and then the - actual data (if any). The meaning of the header lines depends on - the command executed by the server; in most cases, when data is - returned, there should be at least one header line of the form - - Content-type: / - - where and should be registered MIME types, - e.g. "text/html" or "text/plain". - - """ - - # The Python system version, truncated to its first component. - sys_version = "Python/" + sys.version.split()[0] - - # The server software version. You may want to override this. - # The format is multiple whitespace-separated strings, - # where each string is of the form name[/version]. - server_version = "BaseHTTP/" + __version__ - - def parse_request(self): - """Parse a request (internal). - - The request should be stored in self.raw_request; the results - are in self.command, self.path, self.request_version and - self.headers. - - Return value is 1 for success, 0 for failure; on failure, an - error is sent back. - - """ - self.request_version = version = "HTTP/0.9" # Default - requestline = self.raw_requestline - if requestline[-2:] == '\r\n': - requestline = requestline[:-2] - elif requestline[-1:] == '\n': - requestline = requestline[:-1] - self.requestline = requestline - words = requestline.split() - if len(words) == 3: - [command, path, version] = words - if version[:5] != 'HTTP/': - self.send_error(400, "Bad request version (%s)" % `version`) - return 0 - elif len(words) == 2: - [command, path] = words - if command != 'GET': - self.send_error(400, - "Bad HTTP/0.9 request type (%s)" % `command`) - return 0 - else: - self.send_error(400, "Bad request syntax (%s)" % `requestline`) - return 0 - self.command, self.path, self.request_version = command, path, version - self.headers = self.MessageClass(self.rfile, 0) - return 1 - - def handle(self): - """Handle a single HTTP request. - - You normally don't need to override this method; see the class - __doc__ string for information on how to handle specific HTTP - commands such as GET and POST. - - """ - - self.raw_requestline = self.rfile.readline() - if not self.parse_request(): # An error code has been sent, just exit - return - mname = 'do_' + self.command - if not hasattr(self, mname): - self.send_error(501, "Unsupported method (%s)" % `self.command`) - return - method = getattr(self, mname) - method() - - def send_error(self, code, message=None): - """Send and log an error reply. - - Arguments are the error code, and a detailed message. - The detailed message defaults to the short entry matching the - response code. - - This sends an error response (so it must be called before any - output has been generated), logs the error, and finally sends - a piece of HTML explaining the error to the user. - - """ - - try: - short, long = self.responses[code] - except KeyError: - short, long = '???', '???' - if not message: - message = short - explain = long - self.log_error("code %d, message %s", code, message) - self.send_response(code, message) - self.send_header("Content-Type", "text/html") - self.end_headers() - self.wfile.write(self.error_message_format % - {'code': code, - 'message': message, - 'explain': explain}) - - error_message_format = DEFAULT_ERROR_MESSAGE - - def send_response(self, code, message=None): - """Send the response header and log the response code. - - Also send two standard headers with the server software - version and the current date. - - """ - self.log_request(code) - if message is None: - if self.responses.has_key(code): - message = self.responses[code][0] - else: - message = '' - if self.request_version != 'HTTP/0.9': - self.wfile.write("%s %s %s\r\n" % - (self.protocol_version, str(code), message)) - self.send_header('Server', self.version_string()) - self.send_header('Date', self.date_time_string()) - - def send_header(self, keyword, value): - """Send a MIME header.""" - if self.request_version != 'HTTP/0.9': - self.wfile.write("%s: %s\r\n" % (keyword, value)) - - def end_headers(self): - """Send the blank line ending the MIME headers.""" - if self.request_version != 'HTTP/0.9': - self.wfile.write("\r\n") - - def log_request(self, code='-', size='-'): - """Log an accepted request. - - This is called by send_reponse(). - - """ - - self.log_message('"%s" %s %s', - self.requestline, str(code), str(size)) - - def log_error(self, *args): - """Log an error. - - This is called when a request cannot be fulfilled. By - default it passes the message on to log_message(). - - Arguments are the same as for log_message(). - - XXX This should go to the separate error log. - - """ - - apply(self.log_message, args) - - def log_message(self, format, *args): - """Log an arbitrary message. - - This is used by all other logging functions. Override - it if you have specific logging wishes. - - The first argument, FORMAT, is a format string for the - message to be logged. If the format string contains - any % escapes requiring parameters, they should be - specified as subsequent arguments (it's just like - printf!). - - The client host and current date/time are prefixed to - every message. - - """ - - sys.stderr.write("%s - - [%s] %s\n" % - (self.address_string(), - self.log_date_time_string(), - format%args)) - - def version_string(self): - """Return the server software version string.""" - return self.server_version + ' ' + self.sys_version - - def date_time_string(self): - """Return the current date and time formatted for a message header.""" - now = time.time() - year, month, day, hh, mm, ss, wd, y, z = time.gmtime(now) - s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % ( - self.weekdayname[wd], - day, self.monthname[month], year, - hh, mm, ss) - return s - - def log_date_time_string(self): - """Return the current time formatted for logging.""" - now = time.time() - year, month, day, hh, mm, ss, x, y, z = time.localtime(now) - s = "%02d/%3s/%04d %02d:%02d:%02d" % ( - day, self.monthname[month], year, hh, mm, ss) - return s - - weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] - - monthname = [None, - 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] - - def address_string(self): - """Return the client address formatted for logging. - - This version looks up the full hostname using gethostbyaddr(), - and tries to find a name that contains at least one dot. - - """ - - host, port = self.client_address - return socket.getfqdn(host) - - # Essentially static class variables - - # The version of the HTTP protocol we support. - # Don't override unless you know what you're doing (hint: incoming - # requests are required to have exactly this version string). - protocol_version = "HTTP/1.0" - - # The Message-like class used to parse headers - MessageClass = mimetools.Message - - # Table mapping response codes to messages; entries have the - # form {code: (shortmessage, longmessage)}. - # See http://www.w3.org/hypertext/WWW/Protocols/HTTP/HTRESP.html - responses = { - 200: ('OK', 'Request fulfilled, document follows'), - 201: ('Created', 'Document created, URL follows'), - 202: ('Accepted', - 'Request accepted, processing continues off-line'), - 203: ('Partial information', 'Request fulfilled from cache'), - 204: ('No response', 'Request fulfilled, nothing follows'), - - 301: ('Moved', 'Object moved permanently -- see URI list'), - 302: ('Found', 'Object moved temporarily -- see URI list'), - 303: ('Method', 'Object moved -- see Method and URL list'), - 304: ('Not modified', - 'Document has not changed singe given time'), - - 400: ('Bad request', - 'Bad request syntax or unsupported method'), - 401: ('Unauthorized', - 'No permission -- see authorization schemes'), - 402: ('Payment required', - 'No payment -- see charging schemes'), - 403: ('Forbidden', - 'Request forbidden -- authorization will not help'), - 404: ('Not found', 'Nothing matches the given URI'), - - 500: ('Internal error', 'Server got itself in trouble'), - 501: ('Not implemented', - 'Server does not support this operation'), - 502: ('Service temporarily overloaded', - 'The server cannot process the request due to a high load'), - 503: ('Gateway timeout', - 'The gateway server did not receive a timely response'), - - } - - -def test(HandlerClass = BaseHTTPRequestHandler, - ServerClass = HTTPServer): - """Test the HTTP request handler class. - - This runs an HTTP server on port 8000 (or the first command line - argument). - - """ - - if sys.argv[1:]: - port = int(sys.argv[1]) - else: - port = 8000 - server_address = ('', port) - - httpd = ServerClass(server_address, HandlerClass) - - sa = httpd.socket.getsockname() - print "Serving HTTP on", sa[0], "port", sa[1], "..." - httpd.serve_forever() - - -if __name__ == '__main__': - test() - -# arch-tag: 567449b3-cc90-45b6-bbe3-1e113995bdae diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/testdoublens.cpp --- a/test/cedet/tests/testdoublens.cpp Mon Mar 29 14:00:56 2010 +0000 +++ b/test/cedet/tests/testdoublens.cpp Thu Apr 01 14:34:20 2010 +0000 @@ -1,7 +1,24 @@ -// -// CPP file for semantic-ia-utest -// completion engine unit tests. -// +// testdoublens.cpp --- semantic-ia-utest completion engine unit tests + +// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. + +// Author: Eric M. Ludlam + +// This file is part of GNU Emacs. + +// GNU Emacs is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// GNU Emacs is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with GNU Emacs. If not, see . + #include "testdoublens.hpp" namespace Name1 { @@ -29,7 +46,7 @@ void Foo::sendStuff(int /* a */, int /* b */) // ^3^ { } - + } // namespace Name2 } // namespace Name1 @@ -44,7 +61,7 @@ Name1::Name2::F//-4- // #4# ( "Foo" ) ; - + // @TODO - get this working... Name1::stage2_Foo::M//-5- /// #5# ( "Mumble" ) @@ -58,15 +75,15 @@ // Second test from Ravikiran Rajagopal -namespace A { +namespace A { class foo { public: void aa(); void bb(); }; } -namespace A { - class bar { +namespace A { + class bar { public: void xx(); public: @@ -96,7 +113,7 @@ int Bar::baz() { - return dum// -7- + return dum// -7- // #7# ( "dumdum" ) ; } diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/testdoublens.hpp --- a/test/cedet/tests/testdoublens.hpp Mon Mar 29 14:00:56 2010 +0000 +++ b/test/cedet/tests/testdoublens.hpp Thu Apr 01 14:34:20 2010 +0000 @@ -1,6 +1,24 @@ -// -// Header file used in one of the ia-utest tests. -// +// testdoublens.hpp --- Header file used in one of the Semantic tests + +// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. + +// Author: Eric M. Ludlam + +// This file is part of GNU Emacs. + +// GNU Emacs is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// GNU Emacs is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with GNU Emacs. If not, see . + namespace Name1 { namespace Name2 { diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/testjavacomp.java --- a/test/cedet/tests/testjavacomp.java Mon Mar 29 14:00:56 2010 +0000 +++ b/test/cedet/tests/testjavacomp.java Thu Apr 01 14:34:20 2010 +0000 @@ -1,24 +1,23 @@ -/** testjavacomp.java --- - * - * Copyright (C) 2009, 2010 Free Software Foundation, Inc. - * - * Author: Eric M. Ludlam - * - * This file is part of GNU Emacs. - * - * GNU Emacs is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GNU Emacs is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Emacs. If not, see . - */ +// testjavacomp.java --- Semantic unit test for Java + +// Copyright (C) 2009, 2010 Free Software Foundation, Inc. + +// Author: Eric M. Ludlam + +// This file is part of GNU Emacs. + +// GNU Emacs is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// GNU Emacs is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with GNU Emacs. If not, see . package tests.testjavacomp; diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/testspp.c --- a/test/cedet/tests/testspp.c Mon Mar 29 14:00:56 2010 +0000 +++ b/test/cedet/tests/testspp.c Thu Apr 01 14:34:20 2010 +0000 @@ -1,6 +1,24 @@ -/* Attempt to test the C preprocessor - * - */ +/* testspp.cpp --- Semantic unit test for the C preprocessor + + Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + Author: Eric M. Ludlam + + This file is part of GNU Emacs. + + GNU Emacs is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + GNU Emacs is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Emacs. If not, see . +*/ int some_fcn (){} diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/testsppreplace.c --- a/test/cedet/tests/testsppreplace.c Mon Mar 29 14:00:56 2010 +0000 +++ b/test/cedet/tests/testsppreplace.c Thu Apr 01 14:34:20 2010 +0000 @@ -1,5 +1,23 @@ -/* Test CPP/SPP Replacement - */ +/* testsppreplace.c --- unit test for CPP/SPP Replacement + Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + Author: Eric M. Ludlam + + This file is part of GNU Emacs. + + GNU Emacs is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + GNU Emacs is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Emacs. If not, see . +*/ /* TEST: The EMU keyword doesn't screw up the function defn. */ #define EMU diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/testsppreplaced.c --- a/test/cedet/tests/testsppreplaced.c Mon Mar 29 14:00:56 2010 +0000 +++ b/test/cedet/tests/testsppreplaced.c Thu Apr 01 14:34:20 2010 +0000 @@ -1,5 +1,25 @@ -/* What the SPP replace file would looklike with MACROS replaced. - */ +/* testsppreplaced.c --- unit test for CPP/SPP Replacement + Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + Author: Eric M. Ludlam + + This file is part of GNU Emacs. + + GNU Emacs is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + GNU Emacs is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Emacs. If not, see . +*/ + +/* What the SPP replace file would looklike with MACROS replaced: */ /* TEST: The EMU keyword doesn't screw up the function defn. */ char parse_around_emu () diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/teststruct.cpp --- a/test/cedet/tests/teststruct.cpp Mon Mar 29 14:00:56 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -// Combinations of templates and structure inheritance. -// -// Created by Alex Ott. - -template -struct grammar { -public: - typedef grammar self_t; - typedef DerivedT const& embed_t; - grammar() {} - ~grammar() { } - void use_parser() const { } - void test1() { } -}; - -struct PDFbool_parser : public grammar { - PDFbool_parser() {} - template struct definition { - typedef typename scannerT::iterator_t iterator_t; - int top; - definition(const PDFbool_parser& /*self*/) { - return ; - } - const int start() const { - return top; - } - }; -}; - -int main(void) { - PDFbool_parser PDFbool_p = PDFbool_parser(); - PDFbool_p.//-1- - ; - // #1# ("definition" "embed_t" "self_t" "test1" "use_parser") -} - -// ---------------------------------------------------------------------- - -template struct Base { -public: - void interface() - { - // ... - static_cast(this)->implementation(); - // ... - } - - static void static_func() - { - // ... - Derived::static_sub_func(); - // ... - } -}; - -struct Derived : Base { - void implementation() { } - static void static_sub_func() { } -}; - -int foo () { - Derived d; - d.//-2- - ; - // #2# ("implementation" "interface" "static_func" "static_sub_func") -} - -// arch-tag: d6e39f96-525e-44af-8cd1-d03e1829acd3 diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/testsubclass.cpp --- a/test/cedet/tests/testsubclass.cpp Mon Mar 29 14:00:56 2010 +0000 +++ b/test/cedet/tests/testsubclass.cpp Thu Apr 01 14:34:20 2010 +0000 @@ -1,5 +1,23 @@ -/* Special test file for Semantic Analyzer and complex C++ inheritance. - */ +// testsubclass.cpp --- unit test for analyzer and complex C++ inheritance + +// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +// Author: Eric M. Ludlam + +// This file is part of GNU Emacs. + +// GNU Emacs is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// GNU Emacs is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with GNU Emacs. If not, see . //#include #include "testsubclass.hh" @@ -94,7 +112,7 @@ MooseVariableName = createMoose(); doLatinStuff(MooseVariableName); - + tmp = this.f// -1- // #1# ( "fAlcesBool" "fIsValid" "fLatin" ) ; @@ -125,7 +143,7 @@ int someFunction(int mPickle) { moose mMoose = deer::alces::createMoose(); - + if (mPickle == 1) { int mOption1 = 2; @@ -152,7 +170,7 @@ class A{ private: void private_a(){} - public: + public: void public_a(); }; diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/testsubclass.hh --- a/test/cedet/tests/testsubclass.hh Mon Mar 29 14:00:56 2010 +0000 +++ b/test/cedet/tests/testsubclass.hh Thu Apr 01 14:34:20 2010 +0000 @@ -1,8 +1,23 @@ -/* Special test file for Semantic Analyzer and complex C++ inheritance. - * - * Header file for testsubclass.cpp with class defns but no - * implementations. - */ +// testsubclass.hh --- unit test for analyzer and complex C++ inheritance + +// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +// Author: Eric M. Ludlam + +// This file is part of GNU Emacs. + +// GNU Emacs is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// GNU Emacs is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with GNU Emacs. If not, see . //#include // #include diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/testtemplates.cpp --- a/test/cedet/tests/testtemplates.cpp Mon Mar 29 14:00:56 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -// Templates Test file: -// Written by 'Raf' - -template -class read_ref { -public: - const T* read_ref_member_one( T); - const V* read_ref_member_two(); -}; - -namespace NS { - template - class ref { - public: - read_ref operator->() { - m_// -1- - ; - // #1# ( "m_datas" ) - } - - private: - T m_datas[U]; - }; - -} - -class FooOne { -public: - int fooOneMember(); -}; - -class FooTwo { -public: - int fooTwoMember(); -}; - -class FooThree { -public: - int fooThreeMember(); - - FooOne * operator->(); -}; - -typedef ref Test; - -using NS; - -void -main(void) { - ref v; - - v->read_ref_member_one()-> // -2- - ; - // #2# ( "fooOneMember" ) - - v->read_ref_member_two()-> // -3- - ; - // #3# ( "fooTwoMember" ) - - v-> // -4- - ; - // #4# ( "read_ref_member_one" "read_ref_member_two" ) - - Test t; - - t->read_ref_member_two()-> // -5- - ; - // #5# ( "fooTwoMember" ) - - ref v2; - - v2->read_ref_member_two()-> // -6- - ; - // #6# ( "fooOneMember" ) - - /* Try all these things by also specifying the namespace in the name. */ - NS::ref v3; - - v3->read_ref_member_one()-> // -7- - ; - // #7# ( "fooOneMember" ) - - v3->read_ref_member_two()-> // -8- - ; - // #8# ( "fooTwoMember" ) - - v3->read_ref_member_two// @1@ 5 - ; - -} - -// arch-tag: 03cbb8c3-3d01-42ab-b416-42a08ea7b896 diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/testtypedefs.cpp --- a/test/cedet/tests/testtypedefs.cpp Mon Mar 29 14:00:56 2010 +0000 +++ b/test/cedet/tests/testtypedefs.cpp Thu Apr 01 14:34:20 2010 +0000 @@ -1,16 +1,31 @@ -// Sample with some fake bits out of std::string -// +// testtypedefs.cpp --- Sample with some fake bits out of std::string + +// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. + +// Author: Eric M. Ludlam + +// This file is part of GNU Emacs. + +// GNU Emacs is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// GNU Emacs is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with GNU Emacs. If not, see . + // Thanks Ming-Wei Chang for these examples. namespace std { - template class basic_string { - public: void resize(int); - }; - } typedef std::basic_string mstring; @@ -18,41 +33,34 @@ using namespace std; typedef basic_string bstring; - int main(){ mstring a; - a.// -1- ; // #1# ( "resize" ) - bstring b; // It doesn't work here. b.// -2- ; // #2# ( "resize" ) - return 0; } - // ------------------ -class Bar +class Bar { public: void someFunc() {} - }; typedef Bar new_Bar; template -class TBar +class TBar { public: void otherFunc() {} - }; typedef TBar new_TBar; @@ -65,11 +73,9 @@ nb.// -3- ; // #3# ("someFunc") - ntb.// -4- ; // #4# ("otherFunc") - return 0; } diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/testusing.cpp --- a/test/cedet/tests/testusing.cpp Mon Mar 29 14:00:56 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,134 +0,0 @@ -// Test using statements in C++ - -#include - -#include - -namespace moose { - - class MyClass; - class Point; - - typedef MyClass snerk; -} - -namespace moose { - - class Point; - class MyClass; - -} - -namespace { - - int global_variable = 0; - -}; - -using moose::MyClass; - -void someFcn() { - - MyClass f; - - f.//-1- - ; //#1# ( "getVal" "setVal" ) - -} - -// Code from Zhiqiu Kong - -namespace panda { - - using namespace bread_name; - - int func() - { - bread test; - test.//-2- - ;// #2# ( "geta" ) - return 0; - } -} - -// Local using statements and aliased types -// Code from David Engster - -void func2() -{ - using namespace somestuff; - OneClass f; - f.//-3- - ; //#3# ( "aFunc" "anInt" ) -} - -void func3() -{ - using somestuff::OneClass; - OneClass f; - f.//-4- - ; //#4# ( "aFunc" "anInt" ) -} - -// Dereferencing alias types created through 'using' statements - -// Alias with fully qualified name -void func4() -{ - otherstuff::OneClass f; - f. //-5- - ; //#5# ( "aFunc" "anInt" ) -} - -// Alias through namespace directive -void func5() -{ - using namespace otherstuff; - OneClass f; - f. //-6- - ; //#6# ( "aFunc" "anInt" ) -} - -// Check name hiding -void func6() -{ - using namespace morestuff; - OneClass f; // Alias for somestuff::OneClass - f. //-7- - ; //#7# ( "aFunc" "anInt" ) - aStruct g; // This however is morestuff::aStruct ! - g. //-8- - ; //#8# ( "anotherBar" "anotherFoo" ) -} - -// Alias of an alias -// Currently doesn't work interactively for some reason. -void func6() -{ - using namespace evenmorestuff; - OneClass f; - f. //-7- - ; //#7# ( "aFunc" "anInt" ) -} - -// Alias for struct in nested namespace, fully qualified -void func7() -{ - outer::StructNested f; - f.//-8- - ; //#8# ( "one" "two" ) -} - -// Alias for nested namespace -void func8() -{ - using namespace outerinner; - StructNested f; - AnotherStruct g; - f.//-9- - ; //#9# ( "one" "two" ) - g.//-10- - ; //#10# ( "four" "three" ) -} - -// arch-tag: 8e68d5d1-4d48-47c6-a910-d8d6b66b2768 diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/testusing.hh --- a/test/cedet/tests/testusing.hh Mon Mar 29 14:00:56 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,127 +0,0 @@ -// test usings header file. - -namespace moose { - - class Point; - - class MyClass; - -} - - -namespace moose { - - class Point; - - class MyClass { - public: - MyClass() : fVal(0) { - } - - ~MyClass() {}; - - /** - * fVal Accessors - * @{ - */ - int getVal() const { - return fVal; - } - void setVal(int Val) const { - fVal = Val; - } - /** - * @} - */ - private: - int fVal; - }; - -} - -namespace deer { - - class Pickle; - -}; - -// Code from Zhiqiu Kong - -#ifndef BREAD_H -#define BREAD_H - -namespace bread_name { - class bread - { - public: - void geta(); - private: - int m_a; - int m_b; - }; -} - -#endif - -// Code from David Engster -// Creating alias types through 'using' trickery - -namespace somestuff { - class OneClass { - public: - void aFunc(); - int anInt; - }; - struct aStruct { - int foo; - int bar; - }; -} - -namespace otherstuff { - // make otherstuff::OneClass an alias for somestuff::OneClass - using somestuff::OneClass; -} - -namespace morestuff { - // make morestuff an alias namespace for somestuff - using namespace somestuff; - // but hide aStruct with own type - struct aStruct { - int anotherFoo; - int anotherBar; - }; -} - -// We can also create an alias for an alias -namespace evenmorestuff { - using otherstuff::OneClass; -} - -// Now with nested namespaces -namespace outer { - namespace inner { - struct StructNested { - int one; - int two; - }; - struct AnotherStruct { - int three; - int four; - }; - } -} - -// Elevate the first struct into 'outer' -// so that we can access it via 'outer::StructNested' -namespace outer { - using outer::inner::StructNested; -} - -// Create an alias for a nested namespace -namespace outerinner { - // equivalent to 'namespace outerinner = outer::inner;' - using namespace outer::inner; -} - -// arch-tag: f7e59fad-100b-47d3-ae8b-a8390a026ade diff -r 86c85c80cd84 -r 5a619d0a9158 test/cedet/tests/testvarnames.c --- a/test/cedet/tests/testvarnames.c Mon Mar 29 14:00:56 2010 +0000 +++ b/test/cedet/tests/testvarnames.c Thu Apr 01 14:34:20 2010 +0000 @@ -1,6 +1,25 @@ -/* - * Test variable and function names, lists of variables on one line, etc. - */ +/* testvarnames.cpp + Test variable and function names, lists of variables on one line, etc. + + Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. + + Author: Eric M. Ludlam + + This file is part of GNU Emacs. + + GNU Emacs is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + GNU Emacs is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Emacs. If not, see . +*/ struct independent { int indep_1; diff -r 86c85c80cd84 -r 5a619d0a9158 test/occur-testsuite.el --- a/test/occur-testsuite.el Mon Mar 29 14:00:56 2010 +0000 +++ b/test/occur-testsuite.el Thu Apr 01 14:34:20 2010 +0000 @@ -107,7 +107,214 @@ :fx : ") - ) + ;; * Test non-overlapping context lines with matches at bob/eob. + ("x" 1 "\ +ax +b +c +d +ex +f +g +hx +" "\ +3 matches for \"x\" in buffer: *temp* + 1:ax + :b +------- + :d + 5:ex + :f +------- + :g + 8:hx +") + ;; * Test non-overlapping context lines with matches not at bob/eob. + ("x" 1 "\ +a +bx +c +d +ex +f +" "\ +2 matches for \"x\" in buffer: *temp* + :a + 2:bx + :c +------- + :d + 5:ex + :f +") + ;; * Test overlapping context lines with matches at bob/eob. + ("x" 2 "\ +ax +bx +c +dx +e +f +gx +h +i +j +kx +" "\ +5 matches for \"x\" in buffer: *temp* + 1:ax + 2:bx + :c + 4:dx + :e + :f + 7:gx + :h + :i + :j + 11:kx +") + ;; * Test overlapping context lines with matches not at bob/eob. + ("x" 2 "\ +a +b +cx +d +e +f +gx +h +i +" "\ +2 matches for \"x\" in buffer: *temp* + :a + :b + 3:cx + :d + :e + :f + 7:gx + :h + :i +") + ;; * Test overlapping context lines with empty first and last line.. + ("x" 2 "\ + +b +cx +d +e +f +gx +h + +" "\ +2 matches for \"x\" in buffer: *temp* + : + :b + 3:cx + :d + :e + :f + 7:gx + :h + : +") + ;; * Test multi-line overlapping context lines. + ("x\n.x" 2 "\ +ax +bx +c +d +ex +fx +g +h +i +jx +kx +" "\ +3 matches for \"x^J.x\" in buffer: *temp* + 1:ax + :bx + :c + :d + 5:ex + :fx + :g + :h + :i + 10:jx + :kx +") + ;; * Test multi-line non-overlapping context lines. + ("x\n.x" 2 "\ +ax +bx +c +d +e +f +gx +hx +" "\ +2 matches for \"x^J.x\" in buffer: *temp* + 1:ax + :bx + :c + :d +------- + :e + :f + 7:gx + :hx +") + ;; * Test non-overlapping negative (before-context) lines. + ("x" -2 "\ +a +bx +c +d +e +fx +g +h +ix +" "\ +3 matches for \"x\" in buffer: *temp* + :a + 2:bx +------- + :d + :e + 6:fx +------- + :g + :h + 9:ix +") + ;; * Test overlapping negative (before-context) lines. + ("x" -3 "\ +a +bx +c +dx +e +f +gx +h +" "\ +3 matches for \"x\" in buffer: *temp* + :a + 2:bx + :c + 4:dx + :e + :f + 7:gx +") + +) "List of tests for `occur'. Each element has the format: \(REGEXP NLINES INPUT-BUFFER-STRING OUTPUT-BUFFER-STRING).")