Using saved parent location: http://bzr.savannah.gnu.org/r/emacs/trunk/ Now on revision 103573. ------------------------------------------------------------ revno: 103573 author: Ed Reingold committer: Glenn Morris branch nick: trunk timestamp: Sun 2011-03-06 23:48:32 -0800 message: cal-hebrew addition from bug#8190. * lisp/calendar/cal-hebrew.el (diary-hebrew-yahrzeit): Add optional `after-sunset' argument. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-03-07 07:35:25 +0000 +++ lisp/ChangeLog 2011-03-07 07:48:32 +0000 @@ -1,3 +1,8 @@ +2011-03-07 Ed Reingold + + * calendar/cal-hebrew.el (diary-hebrew-yahrzeit): + Add optional `after-sunset' argument. (Bug#8190) + 2011-03-07 Aaron S. Hawley * play/morse.el (nato-alphabet, nato-region, denato-region): === modified file 'lisp/calendar/cal-hebrew.el' --- lisp/calendar/cal-hebrew.el 2011-03-01 03:53:18 +0000 +++ lisp/calendar/cal-hebrew.el 2011-03-07 07:48:32 +0000 @@ -879,21 +879,27 @@ (declare-function diary-ordinal-suffix "diary-lib" (n)) ;;;###diary-autoload -(defun diary-hebrew-yahrzeit (death-month death-day death-year &optional mark) +(defun diary-hebrew-yahrzeit (death-month death-day death-year + &optional mark after-sunset) "Yahrzeit diary entry--entry applies if date is Yahrzeit or the day before. Parameters are DEATH-MONTH, DEATH-DAY, DEATH-YEAR; the diary entry is assumed to be the name of the person. Although the date of death is specified by the civil calendar, the proper Hebrew calendar Yahrzeit is determined. +If the death occurred after local sunset on the given civil date, +the following civil date corresponds to the Hebrew date of +death--set the optional parameter AFTER-SUNSET non-nil in this case. + The order of the input parameters changes according to `calendar-date-style' \(e.g. to DEATH-DAY, DEATH-MONTH, DEATH-YEAR in the European style). An optional parameter MARK specifies a face or single-character string to use when highlighting the day in the calendar." (let* ((h-date (calendar-hebrew-from-absolute - (calendar-absolute-from-gregorian - (diary-make-date death-month death-day death-year)))) + (+ (calendar-absolute-from-gregorian + (diary-make-date death-month death-day death-year)) + (if after-sunset 1 0)))) (h-month (calendar-extract-month h-date)) (h-day (calendar-extract-day h-date)) (h-year (calendar-extract-year h-date)) ------------------------------------------------------------ revno: 103572 committer: Glenn Morris branch nick: trunk timestamp: Sun 2011-03-06 23:37:02 -0800 message: * etc/NEWS: Mention nato-region. diff: === modified file 'etc/NEWS' --- etc/NEWS 2011-03-06 18:24:11 +0000 +++ etc/NEWS 2011-03-07 07:37:02 +0000 @@ -645,6 +645,8 @@ --- *** `copyright-fix-years' can optionally convert consecutive years to ranges. +*** New command `nato-region' converts text to NATO phonetic alphabet. + * New Modes and Packages in Emacs 24.1 ------------------------------------------------------------ revno: 103571 author: Aaron S. Hawley committer: Glenn Morris branch nick: trunk timestamp: Sun 2011-03-06 23:35:25 -0800 message: * lisp/play/morse.el (morse-region, unmorse-region): Barf if read-only. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-03-07 07:33:11 +0000 +++ lisp/ChangeLog 2011-03-07 07:35:25 +0000 @@ -2,6 +2,7 @@ * play/morse.el (nato-alphabet, nato-region, denato-region): New variable and functions. (Bug#2288) + (morse-region, unmorse-region): Barf if read-only. 2011-03-06 Stefan Monnier === modified file 'lisp/play/morse.el' --- lisp/play/morse.el 2011-03-07 07:33:11 +0000 +++ lisp/play/morse.el 2011-03-07 07:35:25 +0000 @@ -151,7 +151,7 @@ ;;;###autoload (defun morse-region (beg end) "Convert all text in a given region to morse code." - (interactive "r") + (interactive "*r") (if (integerp end) (setq end (copy-marker end))) (save-excursion @@ -174,7 +174,7 @@ ;;;###autoload (defun unmorse-region (beg end) "Convert morse coded text in region to ordinary ASCII text." - (interactive "r") + (interactive "*r") (if (integerp end) (setq end (copy-marker end))) (save-excursion ------------------------------------------------------------ revno: 103570 author: Aaron S. Hawley committer: Glenn Morris branch nick: trunk timestamp: Sun 2011-03-06 23:33:11 -0800 message: morse.el additions from bug#2288. * lisp/play/morse.el (nato-alphabet, nato-region, denato-region): New variable and functions. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-03-06 20:55:52 +0000 +++ lisp/ChangeLog 2011-03-07 07:33:11 +0000 @@ -1,3 +1,8 @@ +2011-03-07 Aaron S. Hawley + + * play/morse.el (nato-alphabet, nato-region, denato-region): + New variable and functions. (Bug#2288) + 2011-03-06 Stefan Monnier * progmodes/gud.el (gdb-script-syntax-propertize-function): === modified file 'lisp/play/morse.el' --- lisp/play/morse.el 2011-01-25 04:08:28 +0000 +++ lisp/play/morse.el 2011-03-07 07:33:11 +0000 @@ -25,6 +25,9 @@ ;; Converts text to Morse code and back with M-x morse-region and ;; M-x unmorse-region (though Morse code is no longer official :-(). +;; Converts text to NATO phonetic alphabet and back with M-x +;; nato-region and M-x denato-region. + ;;; Code: (defvar morse-code '(("a" . ".-") @@ -91,6 +94,60 @@ ("@" . ".--.-.")) "Morse code character set.") +(defvar nato-alphabet '(("a" . "Alfa") + ("b" . "Bravo") + ("c" . "Charlie") + ("d" . "Delta") + ("e" . "Echo") + ("f" . "Foxtrot") + ("g" . "Golf") + ("h" . "Hotel") + ("i" . "India") + ("j" . "Juliett") + ("k" . "Kilo") + ("l" . "Lima") + ("m" . "Mike") + ("n" . "November") + ("o" . "Oscar") + ("p" . "Papa") + ("q" . "Quebec") + ("r" . "Romeo") + ("s" . "Sierra") + ("t" . "Tango") + ("u" . "Uniform") + ("v" . "Victor") + ("w" . "Whiskey") + ("x" . "Xray") + ("y" . "Yankee") + ("z" . "Zulu") + ;; Numbers + ("0" . "Zero") + ("1" . "One") + ("2" . "Two") + ("3" . "Three") + ("4" . "Four") + ("5" . "Five") + ("6" . "Six") + ("7" . "Seven") + ("8" . "Eight") + ("9" . "Niner") + ;; Punctuation is not part of standard + ("=" . "Equals") + ("?" . "Query") + ("/" . "Slash") + ("," . "Comma") + ("." . "Stop") + (":" . "Colon") + ("'" . "Apostrophe") + ("-" . "Dash") + ("(" . "Open") + (")" . "Close") + ("@" . "At")) + "NATO phonetic alphabet. +See ''International Code of Signals'' (INTERCO), United States +Edition, 1969 Edition (Revised 2003) available from National +Geospatial-Intelligence Agency at http://www.nga.mil/") + ;;;###autoload (defun morse-region (beg end) "Convert all text in a given region to morse code." @@ -136,6 +193,53 @@ (if (looking-at "/") (delete-char 1)))))))) +;;;###autoload +(defun nato-region (beg end) + "Convert all text in a given region to NATO phonetic alphabet." + ;; Copied from morse-region. -- ashawley 2009-02-10 + (interactive "*r") + (if (integerp end) + (setq end (copy-marker end))) + (save-excursion + (let ((sep "") + str nato) + (goto-char beg) + (while (< (point) end) + (setq str (downcase (buffer-substring (point) (1+ (point))))) + (cond ((looking-at "\\s-+") + (goto-char (match-end 0)) + (setq sep "")) + ((setq nato (assoc str nato-alphabet)) + (delete-char 1) + (insert sep (cdr nato)) + (setq sep "-")) + (t + (forward-char 1) + (setq sep ""))))))) + +;;;###autoload +(defun denato-region (beg end) + "Convert NATO phonetic alphabet in region to ordinary ASCII text." + ;; Copied from unmorse-region. -- ashawley 2009-02-10 + (interactive "*r") + (if (integerp end) + (setq end (copy-marker end))) + (save-excursion + (let (str paren nato) + (goto-char beg) + (while (< (point) end) + (if (null (looking-at "[a-z]+")) + (forward-char 1) + (setq str (buffer-substring (match-beginning 0) (match-end 0))) + (if (null (setq nato (rassoc str nato-alphabet))) + (goto-char (match-end 0)) + (replace-match + (if (string-equal "(" (car nato)) + (if (setq paren (null paren)) "(" ")") + (car nato)) t) + (if (looking-at "-") + (delete-char 1)))))))) + (provide 'morse) ;;; morse.el ends here ------------------------------------------------------------ revno: 103569 committer: Chong Yidong branch nick: trunk timestamp: Sun 2011-03-06 18:19:25 -0500 message: Revert incorrect logic in revision 103558. * src/xdisp.c (redisplay_window): Revert incorrect logic in 2011-03-06 change. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-03-06 10:53:51 +0000 +++ src/ChangeLog 2011-03-06 23:19:25 +0000 @@ -1,3 +1,8 @@ +2011-03-06 Chong Yidong + + * xdisp.c (redisplay_window): Revert incorrect logic in 2011-03-06 + change. + 2011-03-06 Paul Eggert current_column: Now returns EMACS_INT, fixing some iftc === modified file 'src/xdisp.c' --- src/xdisp.c 2011-03-06 10:27:06 +0000 +++ src/xdisp.c 2011-03-06 23:19:25 +0000 @@ -13697,6 +13697,7 @@ int buffer_unchanged_p = 0; int temp_scroll_step = 0; int count = SPECPDL_INDEX (); + int rc; int centering_position = -1; int last_line_misfit = 0; EMACS_INT beg_unchanged, end_unchanged; @@ -14008,15 +14009,12 @@ /* Handle case where text has not changed, only point, and it has not moved off the frame, and we are not retrying after hscroll. (current_matrix_up_to_date_p is nonzero when retrying.) */ - if (current_matrix_up_to_date_p) + if (current_matrix_up_to_date_p + && (rc = try_cursor_movement (window, startp, &temp_scroll_step), + rc != CURSOR_MOVEMENT_CANNOT_BE_USED)) { - int rc = try_cursor_movement (window, startp, &temp_scroll_step); - switch (rc) { - case CURSOR_MOVEMENT_CANNOT_BE_USED: - break; - case CURSOR_MOVEMENT_SUCCESS: used_current_matrix_p = 1; goto done; ------------------------------------------------------------ revno: 103568 committer: Chong Yidong branch nick: trunk timestamp: Sun 2011-03-06 16:52:17 -0500 message: Document package archives in the Lisp manual. * doc/lispref/package.texi: Update index keywords. (Package Archives): New node contents. Document package-x.el. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2011-03-06 20:11:19 +0000 +++ doc/lispref/ChangeLog 2011-03-06 21:52:17 +0000 @@ -1,3 +1,8 @@ +2011-03-06 Chong Yidong + + * package.texi: Update index keywords. + (Package Archives): New node contents. Document package-x.el. + 2011-03-06 Juanma Barranquero * makefile.w32-in (srcs): Add package.texi. === modified file 'doc/lispref/package.texi' --- doc/lispref/package.texi 2011-03-06 15:54:36 +0000 +++ doc/lispref/package.texi 2011-03-06 21:52:17 +0000 @@ -5,7 +5,8 @@ @setfilename ../../info/package @node Packaging, Antinews, System Interface, Top @chapter Preparing Lisp code for distribution -@cindex packaging +@cindex package +@cindex Lisp package Emacs provides a standard way to distribute Emacs Lisp code to users. A @dfn{package} is a collection of one or more files, @@ -24,8 +25,11 @@ @node Packaging Basics @section Packaging Basics -@cindex packaging basics @cindex package attributes +@cindex package name +@cindex package version +@cindex dependencies +@cindex package dependencies A package is either a @dfn{simple package} or a @dfn{multi-file package}. A simple package is stored in a package archive as a single @@ -69,6 +73,7 @@ if any dependency cannot be found, the package cannot be installed. @end table +@cindex content directory, package Installing a package, either via the Package Menu, or via the command @code{package-install-file}, creates a subdirectory of @code{package-user-dir} named @file{@var{name}-@var{version}}, where @@ -78,6 +83,7 @@ package's contents (the single Lisp file for a simple package, or the files extracted from a multi-file package). +@cindex package autoloads Emacs then searches every Lisp file in the content directory for autoload magic comments (@pxref{Autoload}). These autoload definitions are saved to a file named @file{@var{name}-autoloads.el} @@ -98,7 +104,8 @@ @node Simple Packages @section Simple Packages -@cindex single file packages +@cindex single file package +@cindex simple package A simple package consists of a single Emacs Lisp source file. The file must conform to the Emacs Lisp library header conventions @@ -160,7 +167,7 @@ @node Multi-file Packages @section Multi-file Packages -@cindex multi-file packages +@cindex multi-file package A multi-file package is less convenient to create than a single-file package, but it offers more features: it can include multiple Emacs @@ -206,10 +213,10 @@ If the content directory contains a file named @file{dir}, this is assumed to be an Info directory file made with @command{install-info}. @xref{Invoking install-info, Invoking install-info, Invoking -install-info, texinfo, Texinfo}. The Info files listed in this -directory file should also be present in the content directory. In -this case, Emacs will automatically add the content directory to -@code{Info-directory-list} when the package is activated. +install-info, texinfo, Texinfo}. The relevant Info files should also +be present in the content directory. In this case, Emacs will +automatically add the content directory to @code{Info-directory-list} +when the package is activated. Do not include any @file{.elc} files in the package. Those are created when the package is installed. Note that there is no way to @@ -234,5 +241,79 @@ @node Package Archives @section Creating and Maintaining Package Archives - -To be done. +@cindex package archive + + Via the Package Menu, users may download packages from @dfn{package +archives}. Such archives are specified by the variable +@code{package-archives}, whose default value contains a single entry: +the archive hosted by the GNU project at @url{elpa.gnu.org}. This +section describes how to set up and maintain a package archive. + +@cindex base location, package archive +@defopt package-archives +The value of this variable is an alist of package archives recognized +by the Emacs package manager. + +Each alist element corresponds to one archive, and should have the +form @code{(@var{id} . @var{location})}, where @var{id} is the name of +the archive (a string) and @var{location} is its @dfn{base location} +(a string). + +If the base location starts with @samp{http:}, it is treated as a HTTP +URL, and packages are downloaded from this archive via HTTP (as is the +case for the default GNU archive). + +Otherwise, the base location should be a directory name. In this +case, Emacs retrieves packages from this archive via ordinary file +access. Such ``local'' archives are mainly useful for testing. +@end defopt + + A package archive is simply a directory in which the package files, +and associated files, are stored. If you want the archive to be +reachable via HTTP, this directory must be accessible to a web server. +How to accomplish this is beyond the scope of this manual. + + A convenient way to set up and update a package archive is via the +@code{package-x} library. This is included with Emacs, but not loaded +by default; type @kbd{M-x load-library @kbd{RET} package-x @kbd{RET}} +to load it, or add @code{(require 'package-x)} to your init file. +@xref{Lisp Libraries,, Lisp Libraries, emacs, The GNU Emacs Manual}. +Once loaded, you can make use of the following: + +@defopt package-archive-upload-base +The value of this variable is the base location of a package archive, +as a directory name. The commands in the @code{package-x} library +will use this base location. + +The directory name should be absolute. You may specify a remote name, +such as @file{/ssh:foo@@example.com:/var/www/packages/}, if the +package archive is on a different machine. @xref{Remote Files,, +Remote Files, emacs, The GNU Emacs Manual}. +@end defopt + +@deffn Command package-upload-file filename +This command prompts for @var{filename}, a file name, and uploads that +file to @code{package-archive-upload-base}. The file must be either a +simple package (a @file{.el} file) or a multi-file package (a +@file{.tar} file); otherwise, an error is raised. The package +attributes are automatically extracted, and the archive's contents +list is updated with this information. + +If @code{package-archive-upload-base} does not specify a valid +directory, the function prompts interactively for one. If the +directory does not exist, it is created. The directory need not have +any initial contents (i.e., you can use this command to populate an +initially empty archive). +@end deffn + +@deffn Command package-upload-buffer +This command is similar to @code{package-upload-file}, but instead of +prompting for a package file, it uploads the contents of the current +buffer. The current buffer must be visiting a simple package (a +@file{.el} file) or a multi-file package (a @file{.tar} file); +otherwise, an error is raised. +@end deffn + +@noindent +After you create an archive, remember that it is not accessible in the +Package Menu interface unless it is in @code{package-archives}. ------------------------------------------------------------ revno: 103567 committer: Stefan Monnier branch nick: trunk timestamp: Sun 2011-03-06 15:55:52 -0500 message: * lisp/progmodes/gud.el (gdb-script-syntax-propertize-function): Don't change the syntax of a \n that closes a comment. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-03-06 20:19:39 +0000 +++ lisp/ChangeLog 2011-03-06 20:55:52 +0000 @@ -1,3 +1,8 @@ +2011-03-06 Stefan Monnier + + * progmodes/gud.el (gdb-script-syntax-propertize-function): + Don't change the syntax of a \n that closes a comment (bug#8169). + 2011-03-06 Chong Yidong * emacs-lisp/package-x.el (package-archive-upload-base): Make it a @@ -25,8 +30,8 @@ 2011-03-06 Jay Belanger - * calc/calc-ext.el (calc-init-extensions): Rename - calc-logunits-dblevel and calc-logunits-nplevel to calc-dblevel + * calc/calc-ext.el (calc-init-extensions): + Rename calc-logunits-dblevel and calc-logunits-nplevel to calc-dblevel and calc-nplevel, respectively. Add keybindings for calc-spn, calc-midi and calc-freq. Add autoloads for calcFunc-spn, calcFunc-midi, calcFunc-freq, calc-spn, calc-midi and calc-freq. === modified file 'lisp/progmodes/gud.el' --- lisp/progmodes/gud.el 2011-03-04 16:19:56 +0000 +++ lisp/progmodes/gud.el 2011-03-06 20:55:52 +0000 @@ -3127,7 +3127,9 @@ ("^document\\s-.*\\(\n\\)" (1 "< b")) ("^end\\(\\>\\)" (1 (ignore - (unless (eq (match-beginning 0) (point-min)) + (when (and (> (match-beginning 0) (point-min)) + (eq 1 (nth 7 (save-excursion + (syntax-ppss (1- (match-beginning 0))))))) ;; We change the \n in front, which is more difficult, but results ;; in better highlighting. If the doc is empty, the single \n is ;; both the beginning and the end of the docstring, which can't be ------------------------------------------------------------ revno: 103566 committer: Chong Yidong branch nick: trunk timestamp: Sun 2011-03-06 15:19:39 -0500 message: Usability improvements to commands in package-x.el. * lisp/emacs-lisp/package-x.el (package-archive-upload-base): Make it a defcustom. (package--update-file): Doc fix. Accept relative file names. (package--archive-contents-from-file): Remove the argument, since it's necessarily always "archive-contents". (package-maint-add-news-item): Pass relative file name args to package--update-file. (package-upload-buffer-internal): Prompt for a destination if package-archive-upload-base is invalid. Create the directory if it does not exist. (package-upload-buffer, package-upload-file): Doc fix. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-03-06 18:24:11 +0000 +++ lisp/ChangeLog 2011-03-06 20:19:39 +0000 @@ -1,5 +1,19 @@ 2011-03-06 Chong Yidong + * emacs-lisp/package-x.el (package-archive-upload-base): Make it a + defcustom. + (package--update-file): Doc fix. Accept relative file names. + (package--archive-contents-from-file): Remove the argument, since + it's necessarily always "archive-contents". + (package-maint-add-news-item): Pass relative file name args to + package--update-file. + (package-upload-buffer-internal): Prompt for a destination if + package-archive-upload-base is invalid. Create the directory if + it does not exist. + (package-upload-buffer, package-upload-file): Doc fix. + +2011-03-06 Chong Yidong + * isearch.el (isearch-mode-map): Bind C-y to isearch-yank-kill, and move isearch-yank-line to M-s C-e (Bug#8183). === modified file 'lisp/emacs-lisp/package-x.el' --- lisp/emacs-lisp/package-x.el 2011-02-25 18:30:00 +0000 +++ lisp/emacs-lisp/package-x.el 2011-03-06 20:19:39 +0000 @@ -27,21 +27,41 @@ ;;; Commentary: -;; This file currently contains parts of the package system most -;; people won't need, such as package uploading. +;; This file currently contains parts of the package system that many +;; won't need, such as package uploading. + +;; To upload to an archive, first set `package-archive-upload-base' to +;; some desired directory. For testing purposes, you can specify any +;; directory you want, but if you want the archive to be accessible to +;; others via http, this is typically a directory in the /var/www tree +;; (possibly one on a remote machine, accessed via Tramp). + +;; Then call M-x package-upload-file, which prompts for a file to +;; upload. Alternatively, M-x package-upload-buffer uploads the +;; current buffer, if it's visiting a package file. + +;; Once a package is uploaded, users can access it via the Package +;; Menu, by adding the archive to `package-archives'. ;;; Code: (require 'package) (defvar gnus-article-buffer) -;; Note that this only works if you have the password, which you -;; probably don't :-). -(defvar package-archive-upload-base nil - "Base location for uploading to package archive.") +(defcustom package-archive-upload-base "/path/to/archive" + "The base location of the archive to which packages are uploaded. +This should be an absolute directory name. If the archive is on +another machine, you may specify a remote name in the usual way, +e.g. \"/ssh:foo@example.com:/var/www/packages/\". +See Info node `(emacs)Remote Files'. + +Unlike `package-archives', you can't specify a HTTP URL." + :type 'directory + :group 'package + :version "24.1") (defvar package-update-news-on-upload nil - "Whether package upload should also update NEWS and RSS feeds.") + "Whether uploading a package should also update NEWS and RSS feeds.") (defun package--encode (string) "Encode a string by replacing some characters with XML entities." @@ -75,13 +95,18 @@ title " - " (package--encode text) " \n")) -(defun package--update-file (file location text) +(defun package--update-file (file tag text) + "Update the package archive file named FILE. +FILE should be relative to `package-archive-upload-base'. +TAG is a string that can be found within the file; TEXT is +inserted after its first occurrence in the file." + (setq file (expand-file-name file package-archive-upload-base)) (save-excursion (let ((old-buffer (find-buffer-visiting file))) (with-current-buffer (let ((find-file-visit-truename t)) (or old-buffer (find-file-noselect file))) (goto-char (point-min)) - (search-forward location) + (search-forward tag) (forward-line) (insert text) (let ((file-precious-flag t)) @@ -105,30 +130,31 @@ (buffer-substring-no-properties (point-min) (point-max))) (kill-buffer buffer)))))) -(defun package--archive-contents-from-file (file) - "Parse the given archive-contents file." - (if (not (file-exists-p file)) - ;; no existing archive-contents, possibly a new ELPA repo. - (list package-archive-version) - (let ((dont-kill (find-buffer-visiting file))) - (with-current-buffer (let ((find-file-visit-truename t)) - (find-file-noselect file)) - (prog1 - (package-read-from-string - (buffer-substring-no-properties (point-min) (point-max))) - (unless dont-kill - (kill-buffer (current-buffer)))))))) +(defun package--archive-contents-from-file () + "Parse the archive-contents at `package-archive-upload-base'" + (let ((file (expand-file-name "archive-contents" + package-archive-upload-base))) + (if (not (file-exists-p file)) + ;; No existing archive-contents means a new archive. + (list package-archive-version) + (let ((dont-kill (find-buffer-visiting file))) + (with-current-buffer (let ((find-file-visit-truename t)) + (find-file-noselect file)) + (prog1 + (package-read-from-string + (buffer-substring-no-properties (point-min) (point-max))) + (unless dont-kill + (kill-buffer (current-buffer))))))))) (defun package-maint-add-news-item (title description archive-url) - "Add a news item to the ELPA web pages. + "Add a news item to the webpages associated with the package archive. TITLE is the title of the news item. -DESCRIPTION is the text of the news item. -You need administrative access to ELPA to use this." +DESCRIPTION is the text of the news item." (interactive "sTitle: \nsText: ") - (package--update-file (concat package-archive-upload-base "elpa.rss") + (package--update-file "elpa.rss" "" (package--make-rss-entry title description archive-url)) - (package--update-file (concat package-archive-upload-base "news.html") + (package--update-file "news.html" "New entries go here" (package--make-html-entry title description))) @@ -144,8 +170,8 @@ EXTENSION is the file extension, a string. It can be either \"el\" or \"tar\". -The variable `package-archive-upload-base' specifies the upload -destination. If this is nil, signal an error. +The upload destination is given by `package-archive-upload-base'. +If its value is invalid, prompt for a directory. Optional arg ARCHIVE-URL is the URL of the destination archive. If it is non-nil, compute the new \"archive-contents\" file @@ -156,85 +182,97 @@ If ARCHIVE-URL is nil, compute the new \"archive-contents\" file from the \"archive-contents\" at `package-archive-upload-base', if it exists." - (unless package-archive-upload-base - (error "No destination specified in `package-archive-upload-base'")) - (save-excursion - (save-restriction - (let* ((file-type (cond - ((equal extension "el") 'single) - ((equal extension "tar") 'tar) - (t (error "Unknown extension `%s'" extension)))) - (file-name (aref pkg-info 0)) - (pkg-name (intern file-name)) - (requires (aref pkg-info 1)) - (desc (if (string= (aref pkg-info 2) "") - (read-string "Description of package: ") - (aref pkg-info 2))) - (pkg-version (aref pkg-info 3)) - (commentary (aref pkg-info 4)) - (split-version (version-to-list pkg-version)) - (pkg-buffer (current-buffer))) - - ;; Get archive-contents from ARCHIVE-URL if it's non-nil, or - ;; from `package-archive-upload-base' otherwise. - (let ((contents (or (package--archive-contents-from-url archive-url) - (package--archive-contents-from-file - (concat package-archive-upload-base - "archive-contents")))) - (new-desc (vector split-version requires desc file-type))) - (if (> (car contents) package-archive-version) - (error "Unrecognized archive version %d" (car contents))) - (let ((elt (assq pkg-name (cdr contents)))) - (if elt - (if (version-list-<= split-version - (package-desc-vers (cdr elt))) - (error "New package has smaller version: %s" pkg-version) - (setcdr elt new-desc)) - (setq contents (cons (car contents) - (cons (cons pkg-name new-desc) - (cdr contents)))))) - - ;; Now CONTENTS is the updated archive contents. Upload - ;; this and the package itself. For now we assume ELPA is - ;; writable via file primitives. - (let ((print-level nil) - (print-length nil)) - (write-region (concat (pp-to-string contents) "\n") - nil - (concat package-archive-upload-base - "archive-contents"))) - - ;; If there is a commentary section, write it. - (when commentary - (write-region commentary nil - (concat package-archive-upload-base - (symbol-name pkg-name) "-readme.txt"))) - - (set-buffer pkg-buffer) - (write-region (point-min) (point-max) - (concat package-archive-upload-base - file-name "-" pkg-version - "." extension) - nil nil nil 'excl) - - ;; Write a news entry. - (and package-update-news-on-upload - archive-url - (package--update-news (concat file-name "." extension) - pkg-version desc archive-url)) - - ;; special-case "package": write a second copy so that the - ;; installer can easily find the latest version. - (if (string= file-name "package") - (write-region (point-min) (point-max) - (concat package-archive-upload-base - file-name "." extension) - nil nil nil 'ask))))))) + (let ((package-archive-upload-base package-archive-upload-base)) + ;; Check if `package-archive-upload-base' is valid. + (when (or (not (stringp package-archive-upload-base)) + (eq package-archive-upload-base + (car-safe + (get 'package-archive-upload-base 'standard-value)))) + (setq package-archive-upload-base + (read-directory-name + "Base directory for package archive: "))) + (unless (file-directory-p package-archive-upload-base) + (if (y-or-n-p (format "%s does not exist; create it? " + package-archive-upload-base)) + (make-directory package-archive-upload-base t) + (error "Aborted"))) + (save-excursion + (save-restriction + (let* ((file-type (cond + ((equal extension "el") 'single) + ((equal extension "tar") 'tar) + (t (error "Unknown extension `%s'" extension)))) + (file-name (aref pkg-info 0)) + (pkg-name (intern file-name)) + (requires (aref pkg-info 1)) + (desc (if (string= (aref pkg-info 2) "") + (read-string "Description of package: ") + (aref pkg-info 2))) + (pkg-version (aref pkg-info 3)) + (commentary (aref pkg-info 4)) + (split-version (version-to-list pkg-version)) + (pkg-buffer (current-buffer))) + + ;; Get archive-contents from ARCHIVE-URL if it's non-nil, or + ;; from `package-archive-upload-base' otherwise. + (let ((contents (or (package--archive-contents-from-url archive-url) + (package--archive-contents-from-file))) + (new-desc (vector split-version requires desc file-type))) + (if (> (car contents) package-archive-version) + (error "Unrecognized archive version %d" (car contents))) + (let ((elt (assq pkg-name (cdr contents)))) + (if elt + (if (version-list-<= split-version + (package-desc-vers (cdr elt))) + (error "New package has smaller version: %s" pkg-version) + (setcdr elt new-desc)) + (setq contents (cons (car contents) + (cons (cons pkg-name new-desc) + (cdr contents)))))) + + ;; Now CONTENTS is the updated archive contents. Upload + ;; this and the package itself. For now we assume ELPA is + ;; writable via file primitives. + (let ((print-level nil) + (print-length nil)) + (write-region (concat (pp-to-string contents) "\n") + nil + (expand-file-name "archive-contents" + package-archive-upload-base))) + + ;; If there is a commentary section, write it. + (when commentary + (write-region commentary nil + (expand-file-name + (concat (symbol-name pkg-name) "-readme.txt") + package-archive-upload-base))) + + (set-buffer pkg-buffer) + (write-region (point-min) (point-max) + (expand-file-name + (concat file-name "-" pkg-version "." extension) + package-archive-upload-base) + nil nil nil 'excl) + + ;; Write a news entry. + (and package-update-news-on-upload + archive-url + (package--update-news (concat file-name "." extension) + pkg-version desc archive-url)) + + ;; special-case "package": write a second copy so that the + ;; installer can easily find the latest version. + (if (string= file-name "package") + (write-region (point-min) (point-max) + (expand-file-name + (concat file-name "." extension) + package-archive-upload-base) + nil nil nil 'ask)))))))) (defun package-upload-buffer () "Upload the current buffer as a single-file Emacs Lisp package. -The variable `package-archive-upload-base' specifies the upload -destination." +If `package-archive-upload-base' does not specify a valid upload +destination, prompt for one." (interactive) (save-excursion (save-restriction @@ -247,9 +285,8 @@ Interactively, prompt for FILE. The package is considered a single-file package if FILE ends in \".el\", and a multi-file package if FILE ends in \".tar\". - -The variable `package-archive-upload-base' specifies the upload -destination." +If `package-archive-upload-base' does not specify a valid upload +destination, prompt for one." (interactive "fPackage file name: ") (with-temp-buffer (insert-file-contents-literally file) ------------------------------------------------------------ revno: 103565 committer: Juanma Barranquero branch nick: trunk timestamp: Sun 2011-03-06 21:11:19 +0100 message: doc/lispref/makefile.w32-in (srcs): Add package.texi. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2011-03-06 15:54:36 +0000 +++ doc/lispref/ChangeLog 2011-03-06 20:11:19 +0000 @@ -1,3 +1,7 @@ +2011-03-06 Juanma Barranquero + + * makefile.w32-in (srcs): Add package.texi. + 2011-03-06 Chong Yidong * package.texi (Packaging, Packaging Basics, Simple Packages) === modified file 'doc/lispref/makefile.w32-in' --- doc/lispref/makefile.w32-in 2011-01-29 14:48:19 +0000 +++ doc/lispref/makefile.w32-in 2011-03-06 20:11:19 +0000 @@ -87,6 +87,7 @@ $(srcdir)/numbers.texi \ $(srcdir)/objects.texi \ $(srcdir)/os.texi \ + $(srcdir)/package.texi \ $(srcdir)/positions.texi \ $(srcdir)/processes.texi \ $(srcdir)/searching.texi \ ------------------------------------------------------------ revno: 103564 committer: Chong Yidong branch nick: trunk timestamp: Sun 2011-03-06 13:24:11 -0500 message: Bind C-y in Isearch to isearch-yank-kill. * lisp/isearch.el (isearch-mode-map): Bind C-y to isearch-yank-kill, and move isearch-yank-line to M-s C-e. * doc/emacs/search.texi (Isearch Yank): C-y now bound to isearch-yank-kill. diff: === modified file 'doc/emacs/ChangeLog' --- doc/emacs/ChangeLog 2011-03-03 07:00:23 +0000 +++ doc/emacs/ChangeLog 2011-03-06 18:24:11 +0000 @@ -1,3 +1,7 @@ +2011-03-06 Chong Yidong + + * search.texi (Isearch Yank): C-y now bound to isearch-yank-kill. + 2011-03-03 Drake Wilson (tiny change) * misc.texi (emacsclient Options): Add q/quiet. === modified file 'doc/emacs/search.texi' --- doc/emacs/search.texi 2011-02-28 01:07:29 +0000 +++ doc/emacs/search.texi 2011-03-06 18:24:11 +0000 @@ -271,19 +271,24 @@ @node Isearch Yank @subsection Isearch Yanking - Within incremental search, you can use @kbd{C-w} and @kbd{C-y} to grab -text from the buffer into the search string. This makes it convenient -to search for another occurrence of text at point. - - @kbd{C-w} copies the character or word after point and adds it to -the search string, advancing point over it. (The decision, whether to -copy a character or a word, is heuristic.) - - @kbd{C-y} is similar to @kbd{C-w} but copies all the rest of the -current line into the search string. If point is already at the end -of a line, it grabs the entire next line. If the search is currently -case-insensitive, both @kbd{C-y} and @kbd{C-w} convert the text they -copy to lower case, so that the search remains case-insensitive. + Within incremental search, @kbd{C-y} (@code{isearch-yank-kill}) +copies text from the kill ring into the search string. It uses the +same text that @kbd{C-y}, outside of incremental search, would +normally yank into the buffer. @kbd{Mouse-2} in the echo area does +the same. @xref{Yanking}. + + @kbd{C-w} (@code{isearch-yank-word-or-char}) grabs the next +character or word at point, and adds it to the search string. This is +convenient for searching for another occurrence of the text at point. +(The decision, whether to copy a character or a word, is heuristic.) + + Similarly, @kbd{M-s C-e} (@code{isearch-yank-line}) grabs the rest +of the current line, and adds it to the search string. If point is +already at the end of a line, it grabs the entire next line. + + If the search is currently case-insensitive, both @kbd{C-w} and +@kbd{M-s C-e} convert the text they copy to lower case, so that the +search remains case-insensitive. @kbd{C-M-w} and @kbd{C-M-y} modify the search string by only one character at a time: @kbd{C-M-w} deletes the last character from the @@ -293,10 +298,6 @@ @kbd{M-e} and to type @kbd{C-f} at the end of the search string in the minibuffer. - The character @kbd{M-y} copies text from the kill ring into the -search string. It uses the same text that @kbd{C-y} would yank. -@kbd{Mouse-2} in the echo area does the same. @xref{Yanking}. - @node Isearch Scroll @subsection Scrolling During Incremental Search === modified file 'etc/NEWS' --- etc/NEWS 2011-03-06 03:01:23 +0000 +++ etc/NEWS 2011-03-06 18:24:11 +0000 @@ -247,6 +247,15 @@ * Editing Changes in Emacs 24.1 +** Search changes + ++++ +*** C-y in Isearch is now bound to isearch-yank-kill, instead of +isearch-yank-line. + ++++ +*** M-s C-e in Isearch is now bound to isearch-yank-line. + +++ ** There is a new command `count-words-region', which does what you expect. === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-03-06 17:03:45 +0000 +++ lisp/ChangeLog 2011-03-06 18:24:11 +0000 @@ -1,3 +1,8 @@ +2011-03-06 Chong Yidong + + * isearch.el (isearch-mode-map): Bind C-y to isearch-yank-kill, + and move isearch-yank-line to M-s C-e (Bug#8183). + 2011-03-06 Alan Mackenzie * progmodes/cc-engine.el (c-guess-basic-syntax): Reindent. === modified file 'lisp/isearch.el' --- lisp/isearch.el 2011-01-26 08:36:39 +0000 +++ lisp/isearch.el 2011-03-06 18:24:11 +0000 @@ -464,7 +464,8 @@ (define-key map "\C-w" 'isearch-yank-word-or-char) (define-key map "\M-\C-w" 'isearch-del-char) (define-key map "\M-\C-y" 'isearch-yank-char) - (define-key map "\C-y" 'isearch-yank-line) + (define-key map "\C-y" 'isearch-yank-kill) + (define-key map "\M-s\C-e" 'isearch-yank-line) (define-key map (char-to-string help-char) isearch-help-map) (define-key map [help] isearch-help-map) ------------------------------------------------------------ revno: 103563 committer: Alan Mackenzie branch nick: trunk timestamp: Sun 2011-03-06 17:03:45 +0000 message: (c-guess-basic-syntax): Move CASE 19 to a different place, correctly to process template-args-cont lines. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-03-06 16:57:31 +0000 +++ lisp/ChangeLog 2011-03-06 17:03:45 +0000 @@ -1,15 +1,16 @@ 2011-03-06 Alan Mackenzie * progmodes/cc-engine.el (c-guess-basic-syntax): Reindent. + (c-guess-basic-syntax): Move CASE 19 to a different place, + correctly to process template-args-cont lines. 2011-03-06 Jay Belanger - * calc/calc-ext.el (calc-init-extensions): - Rename calc-logunits-dblevel and calc-logunits-nplevel to - calc-dblevel and calc-nplevel, respectively. - Add keybindings for calc-spn, calc-midi and calc-freq. Add - autoloads for calcFunc-spn, calcFunc-midi, calcFunc-freq, - calc-spn, calc-midi and calc-freq. + * calc/calc-ext.el (calc-init-extensions): Rename + calc-logunits-dblevel and calc-logunits-nplevel to calc-dblevel + and calc-nplevel, respectively. Add keybindings for calc-spn, + calc-midi and calc-freq. Add autoloads for calcFunc-spn, + calcFunc-midi, calcFunc-freq, calc-spn, calc-midi and calc-freq. * calc/calc-units.el (calc-dblevel): Rename from calc-logunits-dblevel. === modified file 'lisp/progmodes/cc-engine.el' --- lisp/progmodes/cc-engine.el 2011-03-06 16:57:31 +0000 +++ lisp/progmodes/cc-engine.el 2011-03-06 17:03:45 +0000 @@ -9628,28 +9628,6 @@ (c-most-enclosing-brace paren-state (point)) paren-state)) - ;; CASE 19: line is an expression, not a statement, and is directly - ;; contained by a template delimiter. Most likely, we are in a - ;; template arglist within a statement. This case is based on CASE - ;; 7. At some point in the future, we may wish to create more - ;; syntactic symbols such as `template-intro', - ;; `template-cont-nonempty', etc., and distinguish between them as we - ;; do for `arglist-intro' etc. (2009-12-07). - ((and c-recognize-<>-arglists - (setq containing-< (c-up-list-backward indent-point containing-sexp)) - (eq (char-after containing-<) ?\<)) - (setq placeholder (c-point 'boi containing-<)) - (goto-char containing-sexp) ; Most nested Lbrace/Lparen (but not - ; '<') before indent-point. - (if (>= (point) placeholder) - (progn - (forward-char) - (skip-chars-forward " \t")) - (goto-char placeholder)) - (c-add-stmt-syntax 'template-args-cont (list containing-<) t - (c-most-enclosing-brace c-state-cache (point)) - paren-state)) - ;; CASE 7B: Looking at the opening brace of an ;; in-expression block or brace list. C.f. cases 4, 16A ;; and 17E. @@ -9986,6 +9964,28 @@ paren-state)) )) + ;; CASE 19: line is an expression, not a statement, and is directly + ;; contained by a template delimiter. Most likely, we are in a + ;; template arglist within a statement. This case is based on CASE + ;; 7. At some point in the future, we may wish to create more + ;; syntactic symbols such as `template-intro', + ;; `template-cont-nonempty', etc., and distinguish between them as we + ;; do for `arglist-intro' etc. (2009-12-07). + ((and c-recognize-<>-arglists + (setq containing-< (c-up-list-backward indent-point containing-sexp)) + (eq (char-after containing-<) ?\<)) + (setq placeholder (c-point 'boi containing-<)) + (goto-char containing-sexp) ; Most nested Lbrace/Lparen (but not + ; '<') before indent-point. + (if (>= (point) placeholder) + (progn + (forward-char) + (skip-chars-forward " \t")) + (goto-char placeholder)) + (c-add-stmt-syntax 'template-args-cont (list containing-<) t + (c-most-enclosing-brace c-state-cache (point)) + paren-state)) + ;; CASE 17: Statement or defun catchall. (t (goto-char indent-point) ------------------------------------------------------------ revno: 103562 committer: Alan Mackenzie branch nick: trunk timestamp: Sun 2011-03-06 16:57:31 +0000 message: progmodes/cc-engine.el (c-guess-basic-syntax): Reindent. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-03-06 04:28:39 +0000 +++ lisp/ChangeLog 2011-03-06 16:57:31 +0000 @@ -1,3 +1,7 @@ +2011-03-06 Alan Mackenzie + + * progmodes/cc-engine.el (c-guess-basic-syntax): Reindent. + 2011-03-06 Jay Belanger * calc/calc-ext.el (calc-init-extensions): === modified file 'lisp/progmodes/cc-engine.el' --- lisp/progmodes/cc-engine.el 2011-02-21 21:25:35 +0000 +++ lisp/progmodes/cc-engine.el 2011-03-06 16:57:31 +0000 @@ -8725,841 +8725,841 @@ (defun c-guess-basic-syntax () "Return the syntactic context of the current line." (save-excursion - (beginning-of-line) - (c-save-buffer-state - ((indent-point (point)) - (case-fold-search nil) - ;; A whole ugly bunch of various temporary variables. Have - ;; to declare them here since it's not possible to declare - ;; a variable with only the scope of a cond test and the - ;; following result clauses, and most of this function is a - ;; single gigantic cond. :P - literal char-before-ip before-ws-ip char-after-ip macro-start - in-macro-expr c-syntactic-context placeholder c-in-literal-cache - step-type tmpsymbol keyword injava-inher special-brace-list tmp-pos - containing-< - ;; The following record some positions for the containing - ;; declaration block if we're directly within one: - ;; `containing-decl-open' is the position of the open - ;; brace. `containing-decl-start' is the start of the - ;; declaration. `containing-decl-kwd' is the keyword - ;; symbol of the keyword that tells what kind of block it - ;; is. - containing-decl-open - containing-decl-start - containing-decl-kwd - ;; The open paren of the closest surrounding sexp or nil if - ;; there is none. - containing-sexp - ;; The position after the closest preceding brace sexp - ;; (nested sexps are ignored), or the position after - ;; `containing-sexp' if there is none, or (point-min) if - ;; `containing-sexp' is nil. - lim - ;; The paren state outside `containing-sexp', or at - ;; `indent-point' if `containing-sexp' is nil. - (paren-state (c-parse-state)) - ;; There's always at most one syntactic element which got - ;; an anchor pos. It's stored in syntactic-relpos. - syntactic-relpos - (c-stmt-delim-chars c-stmt-delim-chars)) - - ;; Check if we're directly inside an enclosing declaration - ;; level block. - (when (and (setq containing-sexp - (c-most-enclosing-brace paren-state)) - (progn - (goto-char containing-sexp) - (eq (char-after) ?{)) - (setq placeholder - (c-looking-at-decl-block - (c-most-enclosing-brace paren-state - containing-sexp) - t))) - (setq containing-decl-open containing-sexp - containing-decl-start (point) - containing-sexp nil) - (goto-char placeholder) - (setq containing-decl-kwd (and (looking-at c-keywords-regexp) - (c-keyword-sym (match-string 1))))) - - ;; Init some position variables. - (if c-state-cache - (progn - (setq containing-sexp (car paren-state) - paren-state (cdr paren-state)) - (if (consp containing-sexp) + (beginning-of-line) + (c-save-buffer-state + ((indent-point (point)) + (case-fold-search nil) + ;; A whole ugly bunch of various temporary variables. Have + ;; to declare them here since it's not possible to declare + ;; a variable with only the scope of a cond test and the + ;; following result clauses, and most of this function is a + ;; single gigantic cond. :P + literal char-before-ip before-ws-ip char-after-ip macro-start + in-macro-expr c-syntactic-context placeholder c-in-literal-cache + step-type tmpsymbol keyword injava-inher special-brace-list tmp-pos + containing-< + ;; The following record some positions for the containing + ;; declaration block if we're directly within one: + ;; `containing-decl-open' is the position of the open + ;; brace. `containing-decl-start' is the start of the + ;; declaration. `containing-decl-kwd' is the keyword + ;; symbol of the keyword that tells what kind of block it + ;; is. + containing-decl-open + containing-decl-start + containing-decl-kwd + ;; The open paren of the closest surrounding sexp or nil if + ;; there is none. + containing-sexp + ;; The position after the closest preceding brace sexp + ;; (nested sexps are ignored), or the position after + ;; `containing-sexp' if there is none, or (point-min) if + ;; `containing-sexp' is nil. + lim + ;; The paren state outside `containing-sexp', or at + ;; `indent-point' if `containing-sexp' is nil. + (paren-state (c-parse-state)) + ;; There's always at most one syntactic element which got + ;; an anchor pos. It's stored in syntactic-relpos. + syntactic-relpos + (c-stmt-delim-chars c-stmt-delim-chars)) + + ;; Check if we're directly inside an enclosing declaration + ;; level block. + (when (and (setq containing-sexp + (c-most-enclosing-brace paren-state)) + (progn + (goto-char containing-sexp) + (eq (char-after) ?{)) + (setq placeholder + (c-looking-at-decl-block + (c-most-enclosing-brace paren-state + containing-sexp) + t))) + (setq containing-decl-open containing-sexp + containing-decl-start (point) + containing-sexp nil) + (goto-char placeholder) + (setq containing-decl-kwd (and (looking-at c-keywords-regexp) + (c-keyword-sym (match-string 1))))) + + ;; Init some position variables. + (if c-state-cache + (progn + (setq containing-sexp (car paren-state) + paren-state (cdr paren-state)) + (if (consp containing-sexp) + (progn + (setq lim (cdr containing-sexp)) + (if (cdr c-state-cache) + ;; Ignore balanced paren. The next entry + ;; can't be another one. + (setq containing-sexp (car (cdr c-state-cache)) + paren-state (cdr paren-state)) + ;; If there is no surrounding open paren then + ;; put the last balanced pair back on paren-state. + (setq paren-state (cons containing-sexp paren-state) + containing-sexp nil))) + (setq lim (1+ containing-sexp)))) + (setq lim (point-min))) + + ;; If we're in a parenthesis list then ',' delimits the + ;; "statements" rather than being an operator (with the + ;; exception of the "for" clause). This difference is + ;; typically only noticeable when statements are used in macro + ;; arglists. + (when (and containing-sexp + (eq (char-after containing-sexp) ?\()) + (setq c-stmt-delim-chars c-stmt-delim-chars-with-comma)) + ;; cache char before and after indent point, and move point to + ;; the most likely position to perform the majority of tests + (goto-char indent-point) + (c-backward-syntactic-ws lim) + (setq before-ws-ip (point) + char-before-ip (char-before)) + (goto-char indent-point) + (skip-chars-forward " \t") + (setq char-after-ip (char-after)) + + ;; are we in a literal? + (setq literal (c-in-literal lim)) + + ;; now figure out syntactic qualities of the current line + (cond + + ;; CASE 1: in a string. + ((eq literal 'string) + (c-add-syntax 'string (c-point 'bopl))) + + ;; CASE 2: in a C or C++ style comment. + ((and (memq literal '(c c++)) + ;; This is a kludge for XEmacs where we use + ;; `buffer-syntactic-context', which doesn't correctly + ;; recognize "\*/" to end a block comment. + ;; `parse-partial-sexp' which is used by + ;; `c-literal-limits' will however do that in most + ;; versions, which results in that we get nil from + ;; `c-literal-limits' even when `c-in-literal' claims + ;; we're inside a comment. + (setq placeholder (c-literal-limits lim))) + (c-add-syntax literal (car placeholder))) + + ;; CASE 3: in a cpp preprocessor macro continuation. + ((and (save-excursion + (when (c-beginning-of-macro) + (setq macro-start (point)))) + (/= macro-start (c-point 'boi)) + (progn + (setq tmpsymbol 'cpp-macro-cont) + (or (not c-syntactic-indentation-in-macros) + (save-excursion + (goto-char macro-start) + ;; If at the beginning of the body of a #define + ;; directive then analyze as cpp-define-intro + ;; only. Go on with the syntactic analysis + ;; otherwise. in-macro-expr is set if we're in a + ;; cpp expression, i.e. before the #define body + ;; or anywhere in a non-#define directive. + (if (c-forward-to-cpp-define-body) + (let ((indent-boi (c-point 'boi indent-point))) + (setq in-macro-expr (> (point) indent-boi) + tmpsymbol 'cpp-define-intro) + (= (point) indent-boi)) + (setq in-macro-expr t) + nil))))) + (c-add-syntax tmpsymbol macro-start) + (setq macro-start nil)) + + ;; CASE 11: an else clause? + ((looking-at "else\\>[^_]") + (c-beginning-of-statement-1 containing-sexp) + (c-add-stmt-syntax 'else-clause nil t + containing-sexp paren-state)) + + ;; CASE 12: while closure of a do/while construct? + ((and (looking-at "while\\>[^_]") + (save-excursion + (prog1 (eq (c-beginning-of-statement-1 containing-sexp) + 'beginning) + (setq placeholder (point))))) + (goto-char placeholder) + (c-add-stmt-syntax 'do-while-closure nil t + containing-sexp paren-state)) + + ;; CASE 13: A catch or finally clause? This case is simpler + ;; than if-else and do-while, because a block is required + ;; after every try, catch and finally. + ((save-excursion + (and (cond ((c-major-mode-is 'c++-mode) + (looking-at "catch\\>[^_]")) + ((c-major-mode-is 'java-mode) + (looking-at "\\(catch\\|finally\\)\\>[^_]"))) + (and (c-safe (c-backward-syntactic-ws) + (c-backward-sexp) + t) + (eq (char-after) ?{) + (c-safe (c-backward-syntactic-ws) + (c-backward-sexp) + t) + (if (eq (char-after) ?\() + (c-safe (c-backward-sexp) t) + t)) + (looking-at "\\(try\\|catch\\)\\>[^_]") + (setq placeholder (point)))) + (goto-char placeholder) + (c-add-stmt-syntax 'catch-clause nil t + containing-sexp paren-state)) + + ;; CASE 18: A substatement we can recognize by keyword. + ((save-excursion + (and c-opt-block-stmt-key + (not (eq char-before-ip ?\;)) + (not (c-at-vsemi-p before-ws-ip)) + (not (memq char-after-ip '(?\) ?\] ?,))) + (or (not (eq char-before-ip ?})) + (c-looking-at-inexpr-block-backward c-state-cache)) + (> (point) (progn - (setq lim (cdr containing-sexp)) - (if (cdr c-state-cache) - ;; Ignore balanced paren. The next entry - ;; can't be another one. - (setq containing-sexp (car (cdr c-state-cache)) - paren-state (cdr paren-state)) - ;; If there is no surrounding open paren then - ;; put the last balanced pair back on paren-state. - (setq paren-state (cons containing-sexp paren-state) - containing-sexp nil))) - (setq lim (1+ containing-sexp)))) - (setq lim (point-min))) - - ;; If we're in a parenthesis list then ',' delimits the - ;; "statements" rather than being an operator (with the - ;; exception of the "for" clause). This difference is - ;; typically only noticeable when statements are used in macro - ;; arglists. - (when (and containing-sexp - (eq (char-after containing-sexp) ?\()) - (setq c-stmt-delim-chars c-stmt-delim-chars-with-comma)) - ;; cache char before and after indent point, and move point to - ;; the most likely position to perform the majority of tests - (goto-char indent-point) - (c-backward-syntactic-ws lim) - (setq before-ws-ip (point) - char-before-ip (char-before)) - (goto-char indent-point) - (skip-chars-forward " \t") - (setq char-after-ip (char-after)) - - ;; are we in a literal? - (setq literal (c-in-literal lim)) - - ;; now figure out syntactic qualities of the current line - (cond - - ;; CASE 1: in a string. - ((eq literal 'string) - (c-add-syntax 'string (c-point 'bopl))) - - ;; CASE 2: in a C or C++ style comment. - ((and (memq literal '(c c++)) - ;; This is a kludge for XEmacs where we use - ;; `buffer-syntactic-context', which doesn't correctly - ;; recognize "\*/" to end a block comment. - ;; `parse-partial-sexp' which is used by - ;; `c-literal-limits' will however do that in most - ;; versions, which results in that we get nil from - ;; `c-literal-limits' even when `c-in-literal' claims - ;; we're inside a comment. - (setq placeholder (c-literal-limits lim))) - (c-add-syntax literal (car placeholder))) - - ;; CASE 3: in a cpp preprocessor macro continuation. - ((and (save-excursion - (when (c-beginning-of-macro) - (setq macro-start (point)))) - (/= macro-start (c-point 'boi)) - (progn - (setq tmpsymbol 'cpp-macro-cont) - (or (not c-syntactic-indentation-in-macros) - (save-excursion - (goto-char macro-start) - ;; If at the beginning of the body of a #define - ;; directive then analyze as cpp-define-intro - ;; only. Go on with the syntactic analysis - ;; otherwise. in-macro-expr is set if we're in a - ;; cpp expression, i.e. before the #define body - ;; or anywhere in a non-#define directive. - (if (c-forward-to-cpp-define-body) - (let ((indent-boi (c-point 'boi indent-point))) - (setq in-macro-expr (> (point) indent-boi) - tmpsymbol 'cpp-define-intro) - (= (point) indent-boi)) - (setq in-macro-expr t) - nil))))) - (c-add-syntax tmpsymbol macro-start) - (setq macro-start nil)) - - ;; CASE 11: an else clause? - ((looking-at "else\\>[^_]") - (c-beginning-of-statement-1 containing-sexp) - (c-add-stmt-syntax 'else-clause nil t - containing-sexp paren-state)) - - ;; CASE 12: while closure of a do/while construct? - ((and (looking-at "while\\>[^_]") - (save-excursion - (prog1 (eq (c-beginning-of-statement-1 containing-sexp) - 'beginning) - (setq placeholder (point))))) - (goto-char placeholder) - (c-add-stmt-syntax 'do-while-closure nil t - containing-sexp paren-state)) - - ;; CASE 13: A catch or finally clause? This case is simpler - ;; than if-else and do-while, because a block is required - ;; after every try, catch and finally. - ((save-excursion - (and (cond ((c-major-mode-is 'c++-mode) - (looking-at "catch\\>[^_]")) - ((c-major-mode-is 'java-mode) - (looking-at "\\(catch\\|finally\\)\\>[^_]"))) - (and (c-safe (c-backward-syntactic-ws) - (c-backward-sexp) - t) - (eq (char-after) ?{) - (c-safe (c-backward-syntactic-ws) - (c-backward-sexp) - t) - (if (eq (char-after) ?\() - (c-safe (c-backward-sexp) t) - t)) - (looking-at "\\(try\\|catch\\)\\>[^_]") - (setq placeholder (point)))) - (goto-char placeholder) - (c-add-stmt-syntax 'catch-clause nil t - containing-sexp paren-state)) - - ;; CASE 18: A substatement we can recognize by keyword. - ((save-excursion - (and c-opt-block-stmt-key - (not (eq char-before-ip ?\;)) - (not (c-at-vsemi-p before-ws-ip)) - (not (memq char-after-ip '(?\) ?\] ?,))) - (or (not (eq char-before-ip ?})) - (c-looking-at-inexpr-block-backward c-state-cache)) - (> (point) - (progn - ;; Ought to cache the result from the - ;; c-beginning-of-statement-1 calls here. + ;; Ought to cache the result from the + ;; c-beginning-of-statement-1 calls here. + (setq placeholder (point)) + (while (eq (setq step-type + (c-beginning-of-statement-1 lim)) + 'label)) + (if (eq step-type 'previous) + (goto-char placeholder) (setq placeholder (point)) - (while (eq (setq step-type - (c-beginning-of-statement-1 lim)) - 'label)) - (if (eq step-type 'previous) - (goto-char placeholder) - (setq placeholder (point)) - (if (and (eq step-type 'same) - (not (looking-at c-opt-block-stmt-key))) - ;; Step up to the containing statement if we - ;; stayed in the same one. - (let (step) - (while (eq - (setq step - (c-beginning-of-statement-1 lim)) - 'label)) - (if (eq step 'up) - (setq placeholder (point)) - ;; There was no containing statement afterall. - (goto-char placeholder))))) - placeholder)) - (if (looking-at c-block-stmt-2-key) - ;; Require a parenthesis after these keywords. - ;; Necessary to catch e.g. synchronized in Java, - ;; which can be used both as statement and - ;; modifier. - (and (zerop (c-forward-token-2 1 nil)) - (eq (char-after) ?\()) - (looking-at c-opt-block-stmt-key)))) - - (if (eq step-type 'up) - ;; CASE 18A: Simple substatement. - (progn - (goto-char placeholder) - (cond - ((eq char-after-ip ?{) - (c-add-stmt-syntax 'substatement-open nil nil - containing-sexp paren-state)) - ((save-excursion - (goto-char indent-point) - (back-to-indentation) - (c-forward-label)) - (c-add-stmt-syntax 'substatement-label nil nil - containing-sexp paren-state)) - (t - (c-add-stmt-syntax 'substatement nil nil - containing-sexp paren-state)))) - - ;; CASE 18B: Some other substatement. This is shared - ;; with case 10. - (c-guess-continued-construct indent-point - char-after-ip - placeholder - lim - paren-state))) - - ;; CASE 14: A case or default label - ((looking-at c-label-kwds-regexp) - (if containing-sexp - (progn - (goto-char containing-sexp) - (setq lim (c-most-enclosing-brace c-state-cache - containing-sexp)) - (c-backward-to-block-anchor lim) - (c-add-stmt-syntax 'case-label nil t lim paren-state)) - ;; Got a bogus label at the top level. In lack of better - ;; alternatives, anchor it on (point-min). - (c-add-syntax 'case-label (point-min)))) - - ;; CASE 15: any other label - ((save-excursion - (back-to-indentation) - (and (not (looking-at c-syntactic-ws-start)) - (c-forward-label))) - (cond (containing-decl-open - (setq placeholder (c-add-class-syntax 'inclass - containing-decl-open - containing-decl-start - containing-decl-kwd - paren-state)) - ;; Append access-label with the same anchor point as - ;; inclass gets. - (c-append-syntax 'access-label placeholder)) - - (containing-sexp - (goto-char containing-sexp) - (setq lim (c-most-enclosing-brace c-state-cache - containing-sexp)) - (save-excursion - (setq tmpsymbol - (if (and (eq (c-beginning-of-statement-1 lim) 'up) - (looking-at "switch\\>[^_]")) - ;; If the surrounding statement is a switch then - ;; let's analyze all labels as switch labels, so - ;; that they get lined up consistently. - 'case-label - 'label))) - (c-backward-to-block-anchor lim) - (c-add-stmt-syntax tmpsymbol nil t lim paren-state)) - - (t - ;; A label on the top level. Treat it as a class - ;; context. (point-min) is the closest we get to the - ;; class open brace. - (c-add-syntax 'access-label (point-min))))) - - ;; CASE 4: In-expression statement. C.f. cases 7B, 16A and - ;; 17E. - ((setq placeholder (c-looking-at-inexpr-block - (c-safe-position containing-sexp paren-state) - containing-sexp - ;; Have to turn on the heuristics after - ;; the point even though it doesn't work - ;; very well. C.f. test case class-16.pike. - t)) - (setq tmpsymbol (assq (car placeholder) - '((inexpr-class . class-open) - (inexpr-statement . block-open)))) - (if tmpsymbol - ;; It's a statement block or an anonymous class. - (setq tmpsymbol (cdr tmpsymbol)) - ;; It's a Pike lambda. Check whether we are between the - ;; lambda keyword and the argument list or at the defun - ;; opener. - (setq tmpsymbol (if (eq char-after-ip ?{) - 'inline-open - 'lambda-intro-cont))) - (goto-char (cdr placeholder)) + (if (and (eq step-type 'same) + (not (looking-at c-opt-block-stmt-key))) + ;; Step up to the containing statement if we + ;; stayed in the same one. + (let (step) + (while (eq + (setq step + (c-beginning-of-statement-1 lim)) + 'label)) + (if (eq step 'up) + (setq placeholder (point)) + ;; There was no containing statement afterall. + (goto-char placeholder))))) + placeholder)) + (if (looking-at c-block-stmt-2-key) + ;; Require a parenthesis after these keywords. + ;; Necessary to catch e.g. synchronized in Java, + ;; which can be used both as statement and + ;; modifier. + (and (zerop (c-forward-token-2 1 nil)) + (eq (char-after) ?\()) + (looking-at c-opt-block-stmt-key)))) + + (if (eq step-type 'up) + ;; CASE 18A: Simple substatement. + (progn + (goto-char placeholder) + (cond + ((eq char-after-ip ?{) + (c-add-stmt-syntax 'substatement-open nil nil + containing-sexp paren-state)) + ((save-excursion + (goto-char indent-point) + (back-to-indentation) + (c-forward-label)) + (c-add-stmt-syntax 'substatement-label nil nil + containing-sexp paren-state)) + (t + (c-add-stmt-syntax 'substatement nil nil + containing-sexp paren-state)))) + + ;; CASE 18B: Some other substatement. This is shared + ;; with case 10. + (c-guess-continued-construct indent-point + char-after-ip + placeholder + lim + paren-state))) + + ;; CASE 14: A case or default label + ((looking-at c-label-kwds-regexp) + (if containing-sexp + (progn + (goto-char containing-sexp) + (setq lim (c-most-enclosing-brace c-state-cache + containing-sexp)) + (c-backward-to-block-anchor lim) + (c-add-stmt-syntax 'case-label nil t lim paren-state)) + ;; Got a bogus label at the top level. In lack of better + ;; alternatives, anchor it on (point-min). + (c-add-syntax 'case-label (point-min)))) + + ;; CASE 15: any other label + ((save-excursion (back-to-indentation) - (c-add-stmt-syntax tmpsymbol nil t - (c-most-enclosing-brace c-state-cache (point)) - paren-state) - (unless (eq (point) (cdr placeholder)) - (c-add-syntax (car placeholder)))) - - ;; CASE 5: Line is inside a declaration level block or at top level. - ((or containing-decl-open (null containing-sexp)) + (and (not (looking-at c-syntactic-ws-start)) + (c-forward-label))) + (cond (containing-decl-open + (setq placeholder (c-add-class-syntax 'inclass + containing-decl-open + containing-decl-start + containing-decl-kwd + paren-state)) + ;; Append access-label with the same anchor point as + ;; inclass gets. + (c-append-syntax 'access-label placeholder)) + + (containing-sexp + (goto-char containing-sexp) + (setq lim (c-most-enclosing-brace c-state-cache + containing-sexp)) + (save-excursion + (setq tmpsymbol + (if (and (eq (c-beginning-of-statement-1 lim) 'up) + (looking-at "switch\\>[^_]")) + ;; If the surrounding statement is a switch then + ;; let's analyze all labels as switch labels, so + ;; that they get lined up consistently. + 'case-label + 'label))) + (c-backward-to-block-anchor lim) + (c-add-stmt-syntax tmpsymbol nil t lim paren-state)) + + (t + ;; A label on the top level. Treat it as a class + ;; context. (point-min) is the closest we get to the + ;; class open brace. + (c-add-syntax 'access-label (point-min))))) + + ;; CASE 4: In-expression statement. C.f. cases 7B, 16A and + ;; 17E. + ((setq placeholder (c-looking-at-inexpr-block + (c-safe-position containing-sexp paren-state) + containing-sexp + ;; Have to turn on the heuristics after + ;; the point even though it doesn't work + ;; very well. C.f. test case class-16.pike. + t)) + (setq tmpsymbol (assq (car placeholder) + '((inexpr-class . class-open) + (inexpr-statement . block-open)))) + (if tmpsymbol + ;; It's a statement block or an anonymous class. + (setq tmpsymbol (cdr tmpsymbol)) + ;; It's a Pike lambda. Check whether we are between the + ;; lambda keyword and the argument list or at the defun + ;; opener. + (setq tmpsymbol (if (eq char-after-ip ?{) + 'inline-open + 'lambda-intro-cont))) + (goto-char (cdr placeholder)) + (back-to-indentation) + (c-add-stmt-syntax tmpsymbol nil t + (c-most-enclosing-brace c-state-cache (point)) + paren-state) + (unless (eq (point) (cdr placeholder)) + (c-add-syntax (car placeholder)))) + + ;; CASE 5: Line is inside a declaration level block or at top level. + ((or containing-decl-open (null containing-sexp)) + (cond + + ;; CASE 5A: we are looking at a defun, brace list, class, + ;; or inline-inclass method opening brace + ((setq special-brace-list + (or (and c-special-brace-lists + (c-looking-at-special-brace-list)) + (eq char-after-ip ?{))) (cond - ;; CASE 5A: we are looking at a defun, brace list, class, - ;; or inline-inclass method opening brace - ((setq special-brace-list - (or (and c-special-brace-lists - (c-looking-at-special-brace-list)) - (eq char-after-ip ?{))) - (cond - - ;; CASE 5A.1: Non-class declaration block open. - ((save-excursion - (let (tmp) - (and (eq char-after-ip ?{) - (setq tmp (c-looking-at-decl-block containing-sexp t)) - (progn - (setq placeholder (point)) - (goto-char tmp) - (looking-at c-symbol-key)) - (c-keyword-member - (c-keyword-sym (setq keyword (match-string 0))) - 'c-other-block-decl-kwds)))) - (goto-char placeholder) - (c-add-stmt-syntax - (if (string-equal keyword "extern") - ;; Special case for extern-lang-open. - 'extern-lang-open - (intern (concat keyword "-open"))) - nil t containing-sexp paren-state)) - - ;; CASE 5A.2: we are looking at a class opening brace - ((save-excursion - (goto-char indent-point) - (skip-chars-forward " \t") - (and (eq (char-after) ?{) - (c-looking-at-decl-block containing-sexp t) - (setq placeholder (point)))) - (c-add-syntax 'class-open placeholder)) - - ;; CASE 5A.3: brace list open - ((save-excursion - (c-beginning-of-decl-1 lim) - (while (looking-at c-specifier-key) - (goto-char (match-end 1)) - (c-forward-syntactic-ws indent-point)) - (setq placeholder (c-point 'boi)) - (or (consp special-brace-list) - (and (or (save-excursion - (goto-char indent-point) - (setq tmpsymbol nil) - (while (and (> (point) placeholder) - (zerop (c-backward-token-2 1 t)) - (/= (char-after) ?=)) - (and c-opt-inexpr-brace-list-key - (not tmpsymbol) - (looking-at c-opt-inexpr-brace-list-key) - (setq tmpsymbol 'topmost-intro-cont))) - (eq (char-after) ?=)) - (looking-at c-brace-list-key)) - (save-excursion - (while (and (< (point) indent-point) - (zerop (c-forward-token-2 1 t)) - (not (memq (char-after) '(?\; ?\())))) - (not (memq (char-after) '(?\; ?\())) - )))) - (if (and (not c-auto-newline-analysis) - (c-major-mode-is 'java-mode) - (eq tmpsymbol 'topmost-intro-cont)) - ;; We're in Java and have found that the open brace - ;; belongs to a "new Foo[]" initialization list, - ;; which means the brace list is part of an - ;; expression and not a top level definition. We - ;; therefore treat it as any topmost continuation - ;; even though the semantically correct symbol still - ;; is brace-list-open, on the same grounds as in - ;; case B.2. - (progn - (c-beginning-of-statement-1 lim) - (c-add-syntax 'topmost-intro-cont (c-point 'boi))) - (c-add-syntax 'brace-list-open placeholder))) - - ;; CASE 5A.4: inline defun open - ((and containing-decl-open - (not (c-keyword-member containing-decl-kwd - 'c-other-block-decl-kwds))) - (c-add-syntax 'inline-open) - (c-add-class-syntax 'inclass - containing-decl-open - containing-decl-start - containing-decl-kwd - paren-state)) - - ;; CASE 5A.5: ordinary defun open - (t - (save-excursion - (c-beginning-of-decl-1 lim) - (while (looking-at c-specifier-key) - (goto-char (match-end 1)) - (c-forward-syntactic-ws indent-point)) - (c-add-syntax 'defun-open (c-point 'boi)) - ;; Bogus to use bol here, but it's the legacy. (Resolved, - ;; 2007-11-09) - )))) - - ;; CASE 5B: After a function header but before the body (or - ;; the ending semicolon if there's no body). + ;; CASE 5A.1: Non-class declaration block open. ((save-excursion - (when (setq placeholder (c-just-after-func-arglist-p lim)) - (setq tmp-pos (point)))) - (cond - - ;; CASE 5B.1: Member init list. - ((eq (char-after tmp-pos) ?:) - (if (or (> tmp-pos indent-point) - (= (c-point 'bosws) (1+ tmp-pos))) - (progn - ;; There is no preceding member init clause. - ;; Indent relative to the beginning of indentation - ;; for the topmost-intro line that contains the - ;; prototype's open paren. - (goto-char placeholder) - (c-add-syntax 'member-init-intro (c-point 'boi))) - ;; Indent relative to the first member init clause. - (goto-char (1+ tmp-pos)) - (c-forward-syntactic-ws) - (c-add-syntax 'member-init-cont (point)))) - - ;; CASE 5B.2: K&R arg decl intro - ((and c-recognize-knr-p - (c-in-knr-argdecl lim)) - (c-beginning-of-statement-1 lim) - (c-add-syntax 'knr-argdecl-intro (c-point 'boi)) - (if containing-decl-open - (c-add-class-syntax 'inclass - containing-decl-open - containing-decl-start - containing-decl-kwd - paren-state))) - - ;; CASE 5B.4: Nether region after a C++ or Java func - ;; decl, which could include a `throws' declaration. - (t - (c-beginning-of-statement-1 lim) - (c-add-syntax 'func-decl-cont (c-point 'boi)) - ))) - - ;; CASE 5C: inheritance line. could be first inheritance - ;; line, or continuation of a multiple inheritance - ((or (and (c-major-mode-is 'c++-mode) + (let (tmp) + (and (eq char-after-ip ?{) + (setq tmp (c-looking-at-decl-block containing-sexp t)) (progn - (when (eq char-after-ip ?,) - (skip-chars-forward " \t") - (forward-char)) - (looking-at c-opt-postfix-decl-spec-key))) - (and (or (eq char-before-ip ?:) - ;; watch out for scope operator - (save-excursion - (and (eq char-after-ip ?:) - (c-safe (forward-char 1) t) - (not (eq (char-after) ?:)) - ))) - (save-excursion - (c-backward-syntactic-ws lim) - (if (eq char-before-ip ?:) - (progn - (forward-char -1) - (c-backward-syntactic-ws lim))) - (back-to-indentation) - (looking-at c-class-key))) - ;; for Java - (and (c-major-mode-is 'java-mode) - (let ((fence (save-excursion - (c-beginning-of-statement-1 lim) - (point))) - cont done) + (setq placeholder (point)) + (goto-char tmp) + (looking-at c-symbol-key)) + (c-keyword-member + (c-keyword-sym (setq keyword (match-string 0))) + 'c-other-block-decl-kwds)))) + (goto-char placeholder) + (c-add-stmt-syntax + (if (string-equal keyword "extern") + ;; Special case for extern-lang-open. + 'extern-lang-open + (intern (concat keyword "-open"))) + nil t containing-sexp paren-state)) + + ;; CASE 5A.2: we are looking at a class opening brace + ((save-excursion + (goto-char indent-point) + (skip-chars-forward " \t") + (and (eq (char-after) ?{) + (c-looking-at-decl-block containing-sexp t) + (setq placeholder (point)))) + (c-add-syntax 'class-open placeholder)) + + ;; CASE 5A.3: brace list open + ((save-excursion + (c-beginning-of-decl-1 lim) + (while (looking-at c-specifier-key) + (goto-char (match-end 1)) + (c-forward-syntactic-ws indent-point)) + (setq placeholder (c-point 'boi)) + (or (consp special-brace-list) + (and (or (save-excursion + (goto-char indent-point) + (setq tmpsymbol nil) + (while (and (> (point) placeholder) + (zerop (c-backward-token-2 1 t)) + (/= (char-after) ?=)) + (and c-opt-inexpr-brace-list-key + (not tmpsymbol) + (looking-at c-opt-inexpr-brace-list-key) + (setq tmpsymbol 'topmost-intro-cont))) + (eq (char-after) ?=)) + (looking-at c-brace-list-key)) (save-excursion - (while (not done) - (cond ((looking-at c-opt-postfix-decl-spec-key) - (setq injava-inher (cons cont (point)) - done t)) - ((or (not (c-safe (c-forward-sexp -1) t)) - (<= (point) fence)) - (setq done t)) - ) - (setq cont t))) - injava-inher) - (not (c-crosses-statement-barrier-p (cdr injava-inher) - (point))) - )) - (cond - - ;; CASE 5C.1: non-hanging colon on an inher intro - ((eq char-after-ip ?:) - (c-beginning-of-statement-1 lim) - (c-add-syntax 'inher-intro (c-point 'boi)) - ;; don't add inclass symbol since relative point already - ;; contains any class offset - ) - - ;; CASE 5C.2: hanging colon on an inher intro - ((eq char-before-ip ?:) - (c-beginning-of-statement-1 lim) - (c-add-syntax 'inher-intro (c-point 'boi)) - (if containing-decl-open - (c-add-class-syntax 'inclass - containing-decl-open - containing-decl-start - containing-decl-kwd - paren-state))) - - ;; CASE 5C.3: in a Java implements/extends - (injava-inher - (let ((where (cdr injava-inher)) - (cont (car injava-inher))) - (goto-char where) - (cond ((looking-at "throws\\>[^_]") - (c-add-syntax 'func-decl-cont - (progn (c-beginning-of-statement-1 lim) - (c-point 'boi)))) - (cont (c-add-syntax 'inher-cont where)) - (t (c-add-syntax 'inher-intro - (progn (goto-char (cdr injava-inher)) - (c-beginning-of-statement-1 lim) - (point)))) - ))) - - ;; CASE 5C.4: a continued inheritance line - (t - (c-beginning-of-inheritance-list lim) - (c-add-syntax 'inher-cont (point)) - ;; don't add inclass symbol since relative point already - ;; contains any class offset - ))) - - ;; CASE 5D: this could be a top-level initialization, a - ;; member init list continuation, or a template argument - ;; list continuation. - ((save-excursion - ;; Note: We use the fact that lim is always after any - ;; preceding brace sexp. - (if c-recognize-<>-arglists - (while (and - (progn - (c-syntactic-skip-backward "^;,=<>" lim t) - (> (point) lim)) - (or - (when c-overloadable-operators-regexp - (when (setq placeholder (c-after-special-operator-id lim)) - (goto-char placeholder) - t)) - (cond - ((eq (char-before) ?>) - (or (c-backward-<>-arglist nil lim) - (backward-char)) - t) - ((eq (char-before) ?<) - (backward-char) - (if (save-excursion - (c-forward-<>-arglist nil)) - (progn (forward-char) - nil) - t)) - (t nil))))) - ;; NB: No c-after-special-operator-id stuff in this - ;; clause - we assume only C++ needs it. - (c-syntactic-skip-backward "^;,=" lim t)) - (memq (char-before) '(?, ?= ?<))) - (cond - - ;; CASE 5D.3: perhaps a template list continuation? - ((and (c-major-mode-is 'c++-mode) - (save-excursion - (save-restriction - (c-with-syntax-table c++-template-syntax-table - (goto-char indent-point) - (setq placeholder (c-up-list-backward)) - (and placeholder - (eq (char-after placeholder) ?<)))))) - (c-with-syntax-table c++-template-syntax-table - (goto-char placeholder) - (c-beginning-of-statement-1 lim t) - (if (save-excursion - (c-backward-syntactic-ws lim) - (eq (char-before) ?<)) - ;; In a nested template arglist. - (progn - (goto-char placeholder) - (c-syntactic-skip-backward "^,;" lim t) - (c-forward-syntactic-ws)) - (back-to-indentation))) - ;; FIXME: Should use c-add-stmt-syntax, but it's not yet - ;; template aware. - (c-add-syntax 'template-args-cont (point) placeholder)) - - ;; CASE 5D.4: perhaps a multiple inheritance line? - ((and (c-major-mode-is 'c++-mode) - (save-excursion - (c-beginning-of-statement-1 lim) - (setq placeholder (point)) - (if (looking-at "static\\>[^_]") - (c-forward-token-2 1 nil indent-point)) - (and (looking-at c-class-key) - (zerop (c-forward-token-2 2 nil indent-point)) - (if (eq (char-after) ?<) - (c-with-syntax-table c++-template-syntax-table - (zerop (c-forward-token-2 1 t indent-point))) - t) - (eq (char-after) ?:)))) - (goto-char placeholder) - (c-add-syntax 'inher-cont (c-point 'boi))) - - ;; CASE 5D.5: Continuation of the "expression part" of a - ;; top level construct. Or, perhaps, an unrecognised construct. - (t - (while (and (setq placeholder (point)) - (eq (car (c-beginning-of-decl-1 containing-sexp)) - 'same) - (save-excursion - (c-backward-syntactic-ws) - (eq (char-before) ?})) - (< (point) placeholder))) - (c-add-stmt-syntax - (cond - ((eq (point) placeholder) 'statement) ; unrecognised construct - ;; A preceding comma at the top level means that a - ;; new variable declaration starts here. Use - ;; topmost-intro-cont for it, for consistency with - ;; the first variable declaration. C.f. case 5N. - ((eq char-before-ip ?,) 'topmost-intro-cont) - (t 'statement-cont)) - nil nil containing-sexp paren-state)) - )) - - ;; CASE 5F: Close of a non-class declaration level block. - ((and (eq char-after-ip ?}) - (c-keyword-member containing-decl-kwd - 'c-other-block-decl-kwds)) - ;; This is inconsistent: Should use `containing-decl-open' - ;; here if it's at boi, like in case 5J. - (goto-char containing-decl-start) - (c-add-stmt-syntax - (if (string-equal (symbol-name containing-decl-kwd) "extern") - ;; Special case for compatibility with the - ;; extern-lang syntactic symbols. - 'extern-lang-close - (intern (concat (symbol-name containing-decl-kwd) - "-close"))) - nil t - (c-most-enclosing-brace paren-state (point)) - paren-state)) - - ;; CASE 5G: we are looking at the brace which closes the - ;; enclosing nested class decl - ((and containing-sexp - (eq char-after-ip ?}) - (eq containing-decl-open containing-sexp)) - (c-add-class-syntax 'class-close + (while (and (< (point) indent-point) + (zerop (c-forward-token-2 1 t)) + (not (memq (char-after) '(?\; ?\())))) + (not (memq (char-after) '(?\; ?\())) + )))) + (if (and (not c-auto-newline-analysis) + (c-major-mode-is 'java-mode) + (eq tmpsymbol 'topmost-intro-cont)) + ;; We're in Java and have found that the open brace + ;; belongs to a "new Foo[]" initialization list, + ;; which means the brace list is part of an + ;; expression and not a top level definition. We + ;; therefore treat it as any topmost continuation + ;; even though the semantically correct symbol still + ;; is brace-list-open, on the same grounds as in + ;; case B.2. + (progn + (c-beginning-of-statement-1 lim) + (c-add-syntax 'topmost-intro-cont (c-point 'boi))) + (c-add-syntax 'brace-list-open placeholder))) + + ;; CASE 5A.4: inline defun open + ((and containing-decl-open + (not (c-keyword-member containing-decl-kwd + 'c-other-block-decl-kwds))) + (c-add-syntax 'inline-open) + (c-add-class-syntax 'inclass containing-decl-open containing-decl-start containing-decl-kwd paren-state)) - ;; CASE 5H: we could be looking at subsequent knr-argdecls + ;; CASE 5A.5: ordinary defun open + (t + (save-excursion + (c-beginning-of-decl-1 lim) + (while (looking-at c-specifier-key) + (goto-char (match-end 1)) + (c-forward-syntactic-ws indent-point)) + (c-add-syntax 'defun-open (c-point 'boi)) + ;; Bogus to use bol here, but it's the legacy. (Resolved, + ;; 2007-11-09) + )))) + + ;; CASE 5B: After a function header but before the body (or + ;; the ending semicolon if there's no body). + ((save-excursion + (when (setq placeholder (c-just-after-func-arglist-p lim)) + (setq tmp-pos (point)))) + (cond + + ;; CASE 5B.1: Member init list. + ((eq (char-after tmp-pos) ?:) + (if (or (> tmp-pos indent-point) + (= (c-point 'bosws) (1+ tmp-pos))) + (progn + ;; There is no preceding member init clause. + ;; Indent relative to the beginning of indentation + ;; for the topmost-intro line that contains the + ;; prototype's open paren. + (goto-char placeholder) + (c-add-syntax 'member-init-intro (c-point 'boi))) + ;; Indent relative to the first member init clause. + (goto-char (1+ tmp-pos)) + (c-forward-syntactic-ws) + (c-add-syntax 'member-init-cont (point)))) + + ;; CASE 5B.2: K&R arg decl intro ((and c-recognize-knr-p - (not containing-sexp) ; can't be knr inside braces. - (not (eq char-before-ip ?})) - (save-excursion - (setq placeholder (cdr (c-beginning-of-decl-1 lim))) - (and placeholder - ;; Do an extra check to avoid tripping up on - ;; statements that occur in invalid contexts - ;; (e.g. in macro bodies where we don't really - ;; know the context of what we're looking at). - (not (and c-opt-block-stmt-key - (looking-at c-opt-block-stmt-key))))) - (< placeholder indent-point)) - (goto-char placeholder) - (c-add-syntax 'knr-argdecl (point))) - - ;; CASE 5I: ObjC method definition. - ((and c-opt-method-key - (looking-at c-opt-method-key)) - (c-beginning-of-statement-1 nil t) - (if (= (point) indent-point) - ;; Handle the case when it's the first (non-comment) - ;; thing in the buffer. Can't look for a 'same return - ;; value from cbos1 since ObjC directives currently - ;; aren't recognized fully, so that we get 'same - ;; instead of 'previous if it moved over a preceding - ;; directive. - (goto-char (point-min))) - (c-add-syntax 'objc-method-intro (c-point 'boi))) - - ;; CASE 5P: AWK pattern or function or continuation - ;; thereof. - ((c-major-mode-is 'awk-mode) - (setq placeholder (point)) - (c-add-stmt-syntax - (if (and (eq (c-beginning-of-statement-1) 'same) - (/= (point) placeholder)) - 'topmost-intro-cont - 'topmost-intro) - nil nil - containing-sexp paren-state)) - - ;; CASE 5N: At a variable declaration that follows a class - ;; definition or some other block declaration that doesn't - ;; end at the closing '}'. C.f. case 5D.5. - ((progn - (c-backward-syntactic-ws lim) - (and (eq (char-before) ?}) + (c-in-knr-argdecl lim)) + (c-beginning-of-statement-1 lim) + (c-add-syntax 'knr-argdecl-intro (c-point 'boi)) + (if containing-decl-open + (c-add-class-syntax 'inclass + containing-decl-open + containing-decl-start + containing-decl-kwd + paren-state))) + + ;; CASE 5B.4: Nether region after a C++ or Java func + ;; decl, which could include a `throws' declaration. + (t + (c-beginning-of-statement-1 lim) + (c-add-syntax 'func-decl-cont (c-point 'boi)) + ))) + + ;; CASE 5C: inheritance line. could be first inheritance + ;; line, or continuation of a multiple inheritance + ((or (and (c-major-mode-is 'c++-mode) + (progn + (when (eq char-after-ip ?,) + (skip-chars-forward " \t") + (forward-char)) + (looking-at c-opt-postfix-decl-spec-key))) + (and (or (eq char-before-ip ?:) + ;; watch out for scope operator + (save-excursion + (and (eq char-after-ip ?:) + (c-safe (forward-char 1) t) + (not (eq (char-after) ?:)) + ))) (save-excursion - (let ((start (point))) - (if (and c-state-cache - (consp (car c-state-cache)) - (eq (cdar c-state-cache) (point))) - ;; Speed up the backward search a bit. - (goto-char (caar c-state-cache))) - (c-beginning-of-decl-1 containing-sexp) - (setq placeholder (point)) - (if (= start (point)) - ;; The '}' is unbalanced. - nil - (c-end-of-decl-1) - (>= (point) indent-point)))))) - (goto-char placeholder) - (c-add-stmt-syntax 'topmost-intro-cont nil nil - containing-sexp paren-state)) - - ;; NOTE: The point is at the end of the previous token here. - - ;; CASE 5J: we are at the topmost level, make - ;; sure we skip back past any access specifiers - ((and - ;; A macro continuation line is never at top level. - (not (and macro-start - (> indent-point macro-start))) - (save-excursion - (setq placeholder (point)) - (or (memq char-before-ip '(?\; ?{ ?} nil)) - (c-at-vsemi-p before-ws-ip) - (when (and (eq char-before-ip ?:) - (eq (c-beginning-of-statement-1 lim) - 'label)) (c-backward-syntactic-ws lim) - (setq placeholder (point))) - (and (c-major-mode-is 'objc-mode) - (catch 'not-in-directive - (c-beginning-of-statement-1 lim) - (setq placeholder (point)) - (while (and (c-forward-objc-directive) - (< (point) indent-point)) - (c-forward-syntactic-ws) - (if (>= (point) indent-point) - (throw 'not-in-directive t)) - (setq placeholder (point))) - nil))))) - ;; For historic reasons we anchor at bol of the last - ;; line of the previous declaration. That's clearly - ;; highly bogus and useless, and it makes our lives hard - ;; to remain compatible. :P - (goto-char placeholder) - (c-add-syntax 'topmost-intro (c-point 'bol)) + (if (eq char-before-ip ?:) + (progn + (forward-char -1) + (c-backward-syntactic-ws lim))) + (back-to-indentation) + (looking-at c-class-key))) + ;; for Java + (and (c-major-mode-is 'java-mode) + (let ((fence (save-excursion + (c-beginning-of-statement-1 lim) + (point))) + cont done) + (save-excursion + (while (not done) + (cond ((looking-at c-opt-postfix-decl-spec-key) + (setq injava-inher (cons cont (point)) + done t)) + ((or (not (c-safe (c-forward-sexp -1) t)) + (<= (point) fence)) + (setq done t)) + ) + (setq cont t))) + injava-inher) + (not (c-crosses-statement-barrier-p (cdr injava-inher) + (point))) + )) + (cond + + ;; CASE 5C.1: non-hanging colon on an inher intro + ((eq char-after-ip ?:) + (c-beginning-of-statement-1 lim) + (c-add-syntax 'inher-intro (c-point 'boi)) + ;; don't add inclass symbol since relative point already + ;; contains any class offset + ) + + ;; CASE 5C.2: hanging colon on an inher intro + ((eq char-before-ip ?:) + (c-beginning-of-statement-1 lim) + (c-add-syntax 'inher-intro (c-point 'boi)) (if containing-decl-open - (if (c-keyword-member containing-decl-kwd - 'c-other-block-decl-kwds) - (progn - (goto-char (c-brace-anchor-point containing-decl-open)) - (c-add-stmt-syntax - (if (string-equal (symbol-name containing-decl-kwd) - "extern") - ;; Special case for compatibility with the - ;; extern-lang syntactic symbols. - 'inextern-lang - (intern (concat "in" - (symbol-name containing-decl-kwd)))) - nil t - (c-most-enclosing-brace paren-state (point)) - paren-state)) - (c-add-class-syntax 'inclass - containing-decl-open - containing-decl-start - containing-decl-kwd - paren-state))) - (when (and c-syntactic-indentation-in-macros - macro-start - (/= macro-start (c-point 'boi indent-point))) - (c-add-syntax 'cpp-define-intro) - (setq macro-start nil))) - - ;; CASE 5K: we are at an ObjC method definition - ;; continuation line. - ((and c-opt-method-key + (c-add-class-syntax 'inclass + containing-decl-open + containing-decl-start + containing-decl-kwd + paren-state))) + + ;; CASE 5C.3: in a Java implements/extends + (injava-inher + (let ((where (cdr injava-inher)) + (cont (car injava-inher))) + (goto-char where) + (cond ((looking-at "throws\\>[^_]") + (c-add-syntax 'func-decl-cont + (progn (c-beginning-of-statement-1 lim) + (c-point 'boi)))) + (cont (c-add-syntax 'inher-cont where)) + (t (c-add-syntax 'inher-intro + (progn (goto-char (cdr injava-inher)) + (c-beginning-of-statement-1 lim) + (point)))) + ))) + + ;; CASE 5C.4: a continued inheritance line + (t + (c-beginning-of-inheritance-list lim) + (c-add-syntax 'inher-cont (point)) + ;; don't add inclass symbol since relative point already + ;; contains any class offset + ))) + + ;; CASE 5D: this could be a top-level initialization, a + ;; member init list continuation, or a template argument + ;; list continuation. + ((save-excursion + ;; Note: We use the fact that lim is always after any + ;; preceding brace sexp. + (if c-recognize-<>-arglists + (while (and + (progn + (c-syntactic-skip-backward "^;,=<>" lim t) + (> (point) lim)) + (or + (when c-overloadable-operators-regexp + (when (setq placeholder (c-after-special-operator-id lim)) + (goto-char placeholder) + t)) + (cond + ((eq (char-before) ?>) + (or (c-backward-<>-arglist nil lim) + (backward-char)) + t) + ((eq (char-before) ?<) + (backward-char) + (if (save-excursion + (c-forward-<>-arglist nil)) + (progn (forward-char) + nil) + t)) + (t nil))))) + ;; NB: No c-after-special-operator-id stuff in this + ;; clause - we assume only C++ needs it. + (c-syntactic-skip-backward "^;,=" lim t)) + (memq (char-before) '(?, ?= ?<))) + (cond + + ;; CASE 5D.3: perhaps a template list continuation? + ((and (c-major-mode-is 'c++-mode) + (save-excursion + (save-restriction + (c-with-syntax-table c++-template-syntax-table + (goto-char indent-point) + (setq placeholder (c-up-list-backward)) + (and placeholder + (eq (char-after placeholder) ?<)))))) + (c-with-syntax-table c++-template-syntax-table + (goto-char placeholder) + (c-beginning-of-statement-1 lim t) + (if (save-excursion + (c-backward-syntactic-ws lim) + (eq (char-before) ?<)) + ;; In a nested template arglist. + (progn + (goto-char placeholder) + (c-syntactic-skip-backward "^,;" lim t) + (c-forward-syntactic-ws)) + (back-to-indentation))) + ;; FIXME: Should use c-add-stmt-syntax, but it's not yet + ;; template aware. + (c-add-syntax 'template-args-cont (point) placeholder)) + + ;; CASE 5D.4: perhaps a multiple inheritance line? + ((and (c-major-mode-is 'c++-mode) (save-excursion (c-beginning-of-statement-1 lim) - (beginning-of-line) - (when (looking-at c-opt-method-key) - (setq placeholder (point))))) - (c-add-syntax 'objc-method-args-cont placeholder)) - - ;; CASE 5L: we are at the first argument of a template + (setq placeholder (point)) + (if (looking-at "static\\>[^_]") + (c-forward-token-2 1 nil indent-point)) + (and (looking-at c-class-key) + (zerop (c-forward-token-2 2 nil indent-point)) + (if (eq (char-after) ?<) + (c-with-syntax-table c++-template-syntax-table + (zerop (c-forward-token-2 1 t indent-point))) + t) + (eq (char-after) ?:)))) + (goto-char placeholder) + (c-add-syntax 'inher-cont (c-point 'boi))) + + ;; CASE 5D.5: Continuation of the "expression part" of a + ;; top level construct. Or, perhaps, an unrecognised construct. + (t + (while (and (setq placeholder (point)) + (eq (car (c-beginning-of-decl-1 containing-sexp)) + 'same) + (save-excursion + (c-backward-syntactic-ws) + (eq (char-before) ?})) + (< (point) placeholder))) + (c-add-stmt-syntax + (cond + ((eq (point) placeholder) 'statement) ; unrecognised construct + ;; A preceding comma at the top level means that a + ;; new variable declaration starts here. Use + ;; topmost-intro-cont for it, for consistency with + ;; the first variable declaration. C.f. case 5N. + ((eq char-before-ip ?,) 'topmost-intro-cont) + (t 'statement-cont)) + nil nil containing-sexp paren-state)) + )) + + ;; CASE 5F: Close of a non-class declaration level block. + ((and (eq char-after-ip ?}) + (c-keyword-member containing-decl-kwd + 'c-other-block-decl-kwds)) + ;; This is inconsistent: Should use `containing-decl-open' + ;; here if it's at boi, like in case 5J. + (goto-char containing-decl-start) + (c-add-stmt-syntax + (if (string-equal (symbol-name containing-decl-kwd) "extern") + ;; Special case for compatibility with the + ;; extern-lang syntactic symbols. + 'extern-lang-close + (intern (concat (symbol-name containing-decl-kwd) + "-close"))) + nil t + (c-most-enclosing-brace paren-state (point)) + paren-state)) + + ;; CASE 5G: we are looking at the brace which closes the + ;; enclosing nested class decl + ((and containing-sexp + (eq char-after-ip ?}) + (eq containing-decl-open containing-sexp)) + (c-add-class-syntax 'class-close + containing-decl-open + containing-decl-start + containing-decl-kwd + paren-state)) + + ;; CASE 5H: we could be looking at subsequent knr-argdecls + ((and c-recognize-knr-p + (not containing-sexp) ; can't be knr inside braces. + (not (eq char-before-ip ?})) + (save-excursion + (setq placeholder (cdr (c-beginning-of-decl-1 lim))) + (and placeholder + ;; Do an extra check to avoid tripping up on + ;; statements that occur in invalid contexts + ;; (e.g. in macro bodies where we don't really + ;; know the context of what we're looking at). + (not (and c-opt-block-stmt-key + (looking-at c-opt-block-stmt-key))))) + (< placeholder indent-point)) + (goto-char placeholder) + (c-add-syntax 'knr-argdecl (point))) + + ;; CASE 5I: ObjC method definition. + ((and c-opt-method-key + (looking-at c-opt-method-key)) + (c-beginning-of-statement-1 nil t) + (if (= (point) indent-point) + ;; Handle the case when it's the first (non-comment) + ;; thing in the buffer. Can't look for a 'same return + ;; value from cbos1 since ObjC directives currently + ;; aren't recognized fully, so that we get 'same + ;; instead of 'previous if it moved over a preceding + ;; directive. + (goto-char (point-min))) + (c-add-syntax 'objc-method-intro (c-point 'boi))) + + ;; CASE 5P: AWK pattern or function or continuation + ;; thereof. + ((c-major-mode-is 'awk-mode) + (setq placeholder (point)) + (c-add-stmt-syntax + (if (and (eq (c-beginning-of-statement-1) 'same) + (/= (point) placeholder)) + 'topmost-intro-cont + 'topmost-intro) + nil nil + containing-sexp paren-state)) + + ;; CASE 5N: At a variable declaration that follows a class + ;; definition or some other block declaration that doesn't + ;; end at the closing '}'. C.f. case 5D.5. + ((progn + (c-backward-syntactic-ws lim) + (and (eq (char-before) ?}) + (save-excursion + (let ((start (point))) + (if (and c-state-cache + (consp (car c-state-cache)) + (eq (cdar c-state-cache) (point))) + ;; Speed up the backward search a bit. + (goto-char (caar c-state-cache))) + (c-beginning-of-decl-1 containing-sexp) + (setq placeholder (point)) + (if (= start (point)) + ;; The '}' is unbalanced. + nil + (c-end-of-decl-1) + (>= (point) indent-point)))))) + (goto-char placeholder) + (c-add-stmt-syntax 'topmost-intro-cont nil nil + containing-sexp paren-state)) + + ;; NOTE: The point is at the end of the previous token here. + + ;; CASE 5J: we are at the topmost level, make + ;; sure we skip back past any access specifiers + ((and + ;; A macro continuation line is never at top level. + (not (and macro-start + (> indent-point macro-start))) + (save-excursion + (setq placeholder (point)) + (or (memq char-before-ip '(?\; ?{ ?} nil)) + (c-at-vsemi-p before-ws-ip) + (when (and (eq char-before-ip ?:) + (eq (c-beginning-of-statement-1 lim) + 'label)) + (c-backward-syntactic-ws lim) + (setq placeholder (point))) + (and (c-major-mode-is 'objc-mode) + (catch 'not-in-directive + (c-beginning-of-statement-1 lim) + (setq placeholder (point)) + (while (and (c-forward-objc-directive) + (< (point) indent-point)) + (c-forward-syntactic-ws) + (if (>= (point) indent-point) + (throw 'not-in-directive t)) + (setq placeholder (point))) + nil))))) + ;; For historic reasons we anchor at bol of the last + ;; line of the previous declaration. That's clearly + ;; highly bogus and useless, and it makes our lives hard + ;; to remain compatible. :P + (goto-char placeholder) + (c-add-syntax 'topmost-intro (c-point 'bol)) + (if containing-decl-open + (if (c-keyword-member containing-decl-kwd + 'c-other-block-decl-kwds) + (progn + (goto-char (c-brace-anchor-point containing-decl-open)) + (c-add-stmt-syntax + (if (string-equal (symbol-name containing-decl-kwd) + "extern") + ;; Special case for compatibility with the + ;; extern-lang syntactic symbols. + 'inextern-lang + (intern (concat "in" + (symbol-name containing-decl-kwd)))) + nil t + (c-most-enclosing-brace paren-state (point)) + paren-state)) + (c-add-class-syntax 'inclass + containing-decl-open + containing-decl-start + containing-decl-kwd + paren-state))) + (when (and c-syntactic-indentation-in-macros + macro-start + (/= macro-start (c-point 'boi indent-point))) + (c-add-syntax 'cpp-define-intro) + (setq macro-start nil))) + + ;; CASE 5K: we are at an ObjC method definition + ;; continuation line. + ((and c-opt-method-key + (save-excursion + (c-beginning-of-statement-1 lim) + (beginning-of-line) + (when (looking-at c-opt-method-key) + (setq placeholder (point))))) + (c-add-syntax 'objc-method-args-cont placeholder)) + + ;; CASE 5L: we are at the first argument of a template ;; arglist that begins on the previous line. ((and c-recognize-<>-arglists (eq (char-before) ?<) @@ -9573,32 +9573,32 @@ (c-beginning-of-statement-1 containing-sexp) (c-add-stmt-syntax 'statement nil t containing-sexp paren-state)) - ;;CASE 5N: We are at a tompmost continuation line and the only - ;;preceding items are annotations. + ;;CASE 5N: We are at a tompmost continuation line and the only + ;;preceding items are annotations. ((and (c-major-mode-is 'java-mode) (setq placeholder (point)) - (c-beginning-of-statement-1) - (progn + (c-beginning-of-statement-1) + (progn (while (and (c-forward-annotation)) - (c-forward-syntactic-ws)) - t) - (prog1 - (>= (point) placeholder) - (goto-char placeholder))) - (c-add-syntax 'annotation-top-cont (c-point 'boi))) + (c-forward-syntactic-ws)) + t) + (prog1 + (>= (point) placeholder) + (goto-char placeholder))) + (c-add-syntax 'annotation-top-cont (c-point 'boi))) ;; CASE 5M: we are at a topmost continuation line (t (c-beginning-of-statement-1 (c-safe-position (point) paren-state)) - (when (c-major-mode-is 'objc-mode) - (setq placeholder (point)) - (while (and (c-forward-objc-directive) - (< (point) indent-point)) - (c-forward-syntactic-ws) - (setq placeholder (point))) - (goto-char placeholder)) - (c-add-syntax 'topmost-intro-cont (c-point 'boi))) - )) + (when (c-major-mode-is 'objc-mode) + (setq placeholder (point)) + (while (and (c-forward-objc-directive) + (< (point) indent-point)) + (c-forward-syntactic-ws) + (setq placeholder (point))) + (goto-char placeholder)) + (c-add-syntax 'topmost-intro-cont (c-point 'boi))) + )) ;; (CASE 6 has been removed.) @@ -9614,576 +9614,576 @@ (cond ;; CASE 7A: we are looking at the arglist closing paren. - ;; C.f. case 7F. - ((memq char-after-ip '(?\) ?\])) - (goto-char containing-sexp) - (setq placeholder (c-point 'boi)) - (if (and (c-safe (backward-up-list 1) t) - (>= (point) placeholder)) - (progn - (forward-char) - (skip-chars-forward " \t")) - (goto-char placeholder)) - (c-add-stmt-syntax 'arglist-close (list containing-sexp) t + ;; C.f. case 7F. + ((memq char-after-ip '(?\) ?\])) + (goto-char containing-sexp) + (setq placeholder (c-point 'boi)) + (if (and (c-safe (backward-up-list 1) t) + (>= (point) placeholder)) + (progn + (forward-char) + (skip-chars-forward " \t")) + (goto-char placeholder)) + (c-add-stmt-syntax 'arglist-close (list containing-sexp) t (c-most-enclosing-brace paren-state (point)) paren-state)) - ;; CASE 19: line is an expression, not a statement, and is directly - ;; contained by a template delimiter. Most likely, we are in a - ;; template arglist within a statement. This case is based on CASE - ;; 7. At some point in the future, we may wish to create more - ;; syntactic symbols such as `template-intro', - ;; `template-cont-nonempty', etc., and distinguish between them as we - ;; do for `arglist-intro' etc. (2009-12-07). - ((and c-recognize-<>-arglists - (setq containing-< (c-up-list-backward indent-point containing-sexp)) - (eq (char-after containing-<) ?\<)) - (setq placeholder (c-point 'boi containing-<)) - (goto-char containing-sexp) ; Most nested Lbrace/Lparen (but not + ;; CASE 19: line is an expression, not a statement, and is directly + ;; contained by a template delimiter. Most likely, we are in a + ;; template arglist within a statement. This case is based on CASE + ;; 7. At some point in the future, we may wish to create more + ;; syntactic symbols such as `template-intro', + ;; `template-cont-nonempty', etc., and distinguish between them as we + ;; do for `arglist-intro' etc. (2009-12-07). + ((and c-recognize-<>-arglists + (setq containing-< (c-up-list-backward indent-point containing-sexp)) + (eq (char-after containing-<) ?\<)) + (setq placeholder (c-point 'boi containing-<)) + (goto-char containing-sexp) ; Most nested Lbrace/Lparen (but not ; '<') before indent-point. - (if (>= (point) placeholder) - (progn - (forward-char) - (skip-chars-forward " \t")) - (goto-char placeholder)) - (c-add-stmt-syntax 'template-args-cont (list containing-<) t - (c-most-enclosing-brace c-state-cache (point)) - paren-state)) + (if (>= (point) placeholder) + (progn + (forward-char) + (skip-chars-forward " \t")) + (goto-char placeholder)) + (c-add-stmt-syntax 'template-args-cont (list containing-<) t + (c-most-enclosing-brace c-state-cache (point)) + paren-state)) ;; CASE 7B: Looking at the opening brace of an ;; in-expression block or brace list. C.f. cases 4, 16A ;; and 17E. - ((and (eq char-after-ip ?{) - (progn - (setq placeholder (c-inside-bracelist-p (point) - paren-state)) - (if placeholder - (setq tmpsymbol '(brace-list-open . inexpr-class)) - (setq tmpsymbol '(block-open . inexpr-statement) - placeholder - (cdr-safe (c-looking-at-inexpr-block - (c-safe-position containing-sexp - paren-state) - containing-sexp))) - ;; placeholder is nil if it's a block directly in - ;; a function arglist. That makes us skip out of - ;; this case. - ))) - (goto-char placeholder) - (back-to-indentation) - (c-add-stmt-syntax (car tmpsymbol) nil t - (c-most-enclosing-brace paren-state (point)) - paren-state) - (if (/= (point) placeholder) - (c-add-syntax (cdr tmpsymbol)))) - - ;; CASE 7C: we are looking at the first argument in an empty - ;; argument list. Use arglist-close if we're actually - ;; looking at a close paren or bracket. - ((memq char-before-ip '(?\( ?\[)) + ((and (eq char-after-ip ?{) + (progn + (setq placeholder (c-inside-bracelist-p (point) + paren-state)) + (if placeholder + (setq tmpsymbol '(brace-list-open . inexpr-class)) + (setq tmpsymbol '(block-open . inexpr-statement) + placeholder + (cdr-safe (c-looking-at-inexpr-block + (c-safe-position containing-sexp + paren-state) + containing-sexp))) + ;; placeholder is nil if it's a block directly in + ;; a function arglist. That makes us skip out of + ;; this case. + ))) + (goto-char placeholder) + (back-to-indentation) + (c-add-stmt-syntax (car tmpsymbol) nil t + (c-most-enclosing-brace paren-state (point)) + paren-state) + (if (/= (point) placeholder) + (c-add-syntax (cdr tmpsymbol)))) + + ;; CASE 7C: we are looking at the first argument in an empty + ;; argument list. Use arglist-close if we're actually + ;; looking at a close paren or bracket. + ((memq char-before-ip '(?\( ?\[)) + (goto-char containing-sexp) + (setq placeholder (c-point 'boi)) + (if (and (c-safe (backward-up-list 1) t) + (>= (point) placeholder)) + (progn + (forward-char) + (skip-chars-forward " \t")) + (goto-char placeholder)) + (c-add-stmt-syntax 'arglist-intro (list containing-sexp) t + (c-most-enclosing-brace paren-state (point)) + paren-state)) + + ;; CASE 7D: we are inside a conditional test clause. treat + ;; these things as statements + ((progn (goto-char containing-sexp) - (setq placeholder (c-point 'boi)) - (if (and (c-safe (backward-up-list 1) t) - (>= (point) placeholder)) - (progn - (forward-char) - (skip-chars-forward " \t")) - (goto-char placeholder)) - (c-add-stmt-syntax 'arglist-intro (list containing-sexp) t - (c-most-enclosing-brace paren-state (point)) - paren-state)) - - ;; CASE 7D: we are inside a conditional test clause. treat - ;; these things as statements - ((progn - (goto-char containing-sexp) - (and (c-safe (c-forward-sexp -1) t) - (looking-at "\\[^_]"))) + (and (c-safe (c-forward-sexp -1) t) + (looking-at "\\[^_]"))) + (goto-char (1+ containing-sexp)) + (c-forward-syntactic-ws indent-point) + (if (eq char-before-ip ?\;) + (c-add-syntax 'statement (point)) + (c-add-syntax 'statement-cont (point)) + )) + + ;; CASE 7E: maybe a continued ObjC method call. This is the + ;; case when we are inside a [] bracketed exp, and what + ;; precede the opening bracket is not an identifier. + ((and c-opt-method-key + (eq (char-after containing-sexp) ?\[) + (progn + (goto-char (1- containing-sexp)) + (c-backward-syntactic-ws (c-point 'bod)) + (if (not (looking-at c-symbol-key)) + (c-add-syntax 'objc-method-call-cont containing-sexp)) + ))) + + ;; CASE 7F: we are looking at an arglist continuation line, + ;; but the preceding argument is on the same line as the + ;; opening paren. This case includes multi-line + ;; mathematical paren groupings, but we could be on a + ;; for-list continuation line. C.f. case 7A. + ((progn (goto-char (1+ containing-sexp)) + (< (save-excursion + (c-forward-syntactic-ws) + (point)) + (c-point 'bonl))) + (goto-char containing-sexp) ; paren opening the arglist + (setq placeholder (c-point 'boi)) + (if (and (c-safe (backward-up-list 1) t) + (>= (point) placeholder)) + (progn + (forward-char) + (skip-chars-forward " \t")) + (goto-char placeholder)) + (c-add-stmt-syntax 'arglist-cont-nonempty (list containing-sexp) t + (c-most-enclosing-brace c-state-cache (point)) + paren-state)) + + ;; CASE 7G: we are looking at just a normal arglist + ;; continuation line + (t (c-forward-syntactic-ws indent-point) + (c-add-syntax 'arglist-cont (c-point 'boi))) + )) + + ;; CASE 8: func-local multi-inheritance line + ((and (c-major-mode-is 'c++-mode) + (save-excursion + (goto-char indent-point) + (skip-chars-forward " \t") + (looking-at c-opt-postfix-decl-spec-key))) + (goto-char indent-point) + (skip-chars-forward " \t") + (cond + + ;; CASE 8A: non-hanging colon on an inher intro + ((eq char-after-ip ?:) + (c-backward-syntactic-ws lim) + (c-add-syntax 'inher-intro (c-point 'boi))) + + ;; CASE 8B: hanging colon on an inher intro + ((eq char-before-ip ?:) + (c-add-syntax 'inher-intro (c-point 'boi))) + + ;; CASE 8C: a continued inheritance line + (t + (c-beginning-of-inheritance-list lim) + (c-add-syntax 'inher-cont (point)) + ))) + + ;; CASE 9: we are inside a brace-list + ((and (not (c-major-mode-is 'awk-mode)) ; Maybe this isn't needed (ACM, 2002/3/29) + (setq special-brace-list + (or (and c-special-brace-lists ;;;; ALWAYS NIL FOR AWK!! + (save-excursion + (goto-char containing-sexp) + (c-looking-at-special-brace-list))) + (c-inside-bracelist-p containing-sexp paren-state)))) + (cond + + ;; CASE 9A: In the middle of a special brace list opener. + ((and (consp special-brace-list) + (save-excursion + (goto-char containing-sexp) + (eq (char-after) ?\()) + (eq char-after-ip (car (cdr special-brace-list)))) + (goto-char (car (car special-brace-list))) + (skip-chars-backward " \t") + (if (and (bolp) + (assoc 'statement-cont + (setq placeholder (c-guess-basic-syntax)))) + (setq c-syntactic-context placeholder) + (c-beginning-of-statement-1 + (c-safe-position (1- containing-sexp) paren-state)) + (c-forward-token-2 0) + (while (looking-at c-specifier-key) + (goto-char (match-end 1)) + (c-forward-syntactic-ws)) + (c-add-syntax 'brace-list-open (c-point 'boi)))) + + ;; CASE 9B: brace-list-close brace + ((if (consp special-brace-list) + ;; Check special brace list closer. + (progn + (goto-char (car (car special-brace-list))) + (save-excursion + (goto-char indent-point) + (back-to-indentation) + (or + ;; We were between the special close char and the `)'. + (and (eq (char-after) ?\)) + (eq (1+ (point)) (cdr (car special-brace-list)))) + ;; We were before the special close char. + (and (eq (char-after) (cdr (cdr special-brace-list))) + (zerop (c-forward-token-2)) + (eq (1+ (point)) (cdr (car special-brace-list))))))) + ;; Normal brace list check. + (and (eq char-after-ip ?}) + (c-safe (goto-char (c-up-list-backward (point))) t) + (= (point) containing-sexp))) + (if (eq (point) (c-point 'boi)) + (c-add-syntax 'brace-list-close (point)) + (setq lim (c-most-enclosing-brace c-state-cache (point))) + (c-beginning-of-statement-1 lim) + (c-add-stmt-syntax 'brace-list-close nil t lim paren-state))) + + (t + ;; Prepare for the rest of the cases below by going to the + ;; token following the opening brace + (if (consp special-brace-list) + (progn + (goto-char (car (car special-brace-list))) + (c-forward-token-2 1 nil indent-point)) + (goto-char containing-sexp)) + (forward-char) + (let ((start (point))) (c-forward-syntactic-ws indent-point) - (if (eq char-before-ip ?\;) - (c-add-syntax 'statement (point)) - (c-add-syntax 'statement-cont (point)) - )) - - ;; CASE 7E: maybe a continued ObjC method call. This is the - ;; case when we are inside a [] bracketed exp, and what - ;; precede the opening bracket is not an identifier. - ((and c-opt-method-key - (eq (char-after containing-sexp) ?\[) - (progn - (goto-char (1- containing-sexp)) - (c-backward-syntactic-ws (c-point 'bod)) - (if (not (looking-at c-symbol-key)) - (c-add-syntax 'objc-method-call-cont containing-sexp)) - ))) - - ;; CASE 7F: we are looking at an arglist continuation line, - ;; but the preceding argument is on the same line as the - ;; opening paren. This case includes multi-line - ;; mathematical paren groupings, but we could be on a - ;; for-list continuation line. C.f. case 7A. - ((progn - (goto-char (1+ containing-sexp)) - (< (save-excursion - (c-forward-syntactic-ws) - (point)) - (c-point 'bonl))) - (goto-char containing-sexp) ; paren opening the arglist - (setq placeholder (c-point 'boi)) - (if (and (c-safe (backward-up-list 1) t) - (>= (point) placeholder)) - (progn - (forward-char) - (skip-chars-forward " \t")) - (goto-char placeholder)) - (c-add-stmt-syntax 'arglist-cont-nonempty (list containing-sexp) t - (c-most-enclosing-brace c-state-cache (point)) - paren-state)) - - ;; CASE 7G: we are looking at just a normal arglist - ;; continuation line - (t (c-forward-syntactic-ws indent-point) - (c-add-syntax 'arglist-cont (c-point 'boi))) - )) - - ;; CASE 8: func-local multi-inheritance line - ((and (c-major-mode-is 'c++-mode) - (save-excursion - (goto-char indent-point) - (skip-chars-forward " \t") - (looking-at c-opt-postfix-decl-spec-key))) - (goto-char indent-point) - (skip-chars-forward " \t") - (cond - - ;; CASE 8A: non-hanging colon on an inher intro - ((eq char-after-ip ?:) - (c-backward-syntactic-ws lim) - (c-add-syntax 'inher-intro (c-point 'boi))) - - ;; CASE 8B: hanging colon on an inher intro - ((eq char-before-ip ?:) - (c-add-syntax 'inher-intro (c-point 'boi))) - - ;; CASE 8C: a continued inheritance line - (t - (c-beginning-of-inheritance-list lim) - (c-add-syntax 'inher-cont (point)) - ))) - - ;; CASE 9: we are inside a brace-list - ((and (not (c-major-mode-is 'awk-mode)) ; Maybe this isn't needed (ACM, 2002/3/29) - (setq special-brace-list - (or (and c-special-brace-lists ;;;; ALWAYS NIL FOR AWK!! - (save-excursion - (goto-char containing-sexp) - (c-looking-at-special-brace-list))) - (c-inside-bracelist-p containing-sexp paren-state)))) - (cond - - ;; CASE 9A: In the middle of a special brace list opener. - ((and (consp special-brace-list) - (save-excursion - (goto-char containing-sexp) - (eq (char-after) ?\()) - (eq char-after-ip (car (cdr special-brace-list)))) - (goto-char (car (car special-brace-list))) - (skip-chars-backward " \t") - (if (and (bolp) - (assoc 'statement-cont - (setq placeholder (c-guess-basic-syntax)))) - (setq c-syntactic-context placeholder) - (c-beginning-of-statement-1 - (c-safe-position (1- containing-sexp) paren-state)) - (c-forward-token-2 0) - (while (looking-at c-specifier-key) - (goto-char (match-end 1)) - (c-forward-syntactic-ws)) - (c-add-syntax 'brace-list-open (c-point 'boi)))) - - ;; CASE 9B: brace-list-close brace - ((if (consp special-brace-list) - ;; Check special brace list closer. - (progn - (goto-char (car (car special-brace-list))) - (save-excursion - (goto-char indent-point) - (back-to-indentation) - (or - ;; We were between the special close char and the `)'. - (and (eq (char-after) ?\)) - (eq (1+ (point)) (cdr (car special-brace-list)))) - ;; We were before the special close char. - (and (eq (char-after) (cdr (cdr special-brace-list))) - (zerop (c-forward-token-2)) - (eq (1+ (point)) (cdr (car special-brace-list))))))) - ;; Normal brace list check. - (and (eq char-after-ip ?}) - (c-safe (goto-char (c-up-list-backward (point))) t) - (= (point) containing-sexp))) + (goto-char (max start (c-point 'bol)))) + (c-skip-ws-forward indent-point) + (cond + + ;; CASE 9C: we're looking at the first line in a brace-list + ((= (point) indent-point) + (if (consp special-brace-list) + (goto-char (car (car special-brace-list))) + (goto-char containing-sexp)) (if (eq (point) (c-point 'boi)) - (c-add-syntax 'brace-list-close (point)) + (c-add-syntax 'brace-list-intro (point)) (setq lim (c-most-enclosing-brace c-state-cache (point))) (c-beginning-of-statement-1 lim) - (c-add-stmt-syntax 'brace-list-close nil t lim paren-state))) - - (t - ;; Prepare for the rest of the cases below by going to the - ;; token following the opening brace - (if (consp special-brace-list) - (progn - (goto-char (car (car special-brace-list))) - (c-forward-token-2 1 nil indent-point)) - (goto-char containing-sexp)) - (forward-char) - (let ((start (point))) - (c-forward-syntactic-ws indent-point) - (goto-char (max start (c-point 'bol)))) - (c-skip-ws-forward indent-point) - (cond - - ;; CASE 9C: we're looking at the first line in a brace-list - ((= (point) indent-point) - (if (consp special-brace-list) - (goto-char (car (car special-brace-list))) - (goto-char containing-sexp)) - (if (eq (point) (c-point 'boi)) - (c-add-syntax 'brace-list-intro (point)) - (setq lim (c-most-enclosing-brace c-state-cache (point))) - (c-beginning-of-statement-1 lim) - (c-add-stmt-syntax 'brace-list-intro nil t lim paren-state))) - - ;; CASE 9D: this is just a later brace-list-entry or - ;; brace-entry-open - (t (if (or (eq char-after-ip ?{) - (and c-special-brace-lists - (save-excursion - (goto-char indent-point) - (c-forward-syntactic-ws (c-point 'eol)) - (c-looking-at-special-brace-list (point))))) - (c-add-syntax 'brace-entry-open (point)) - (c-add-syntax 'brace-list-entry (point)) - )) - )))) - - ;; CASE 10: A continued statement or top level construct. - ((and (not (memq char-before-ip '(?\; ?:))) - (not (c-at-vsemi-p before-ws-ip)) - (or (not (eq char-before-ip ?})) - (c-looking-at-inexpr-block-backward c-state-cache)) - (> (point) - (save-excursion - (c-beginning-of-statement-1 containing-sexp) - (setq placeholder (point)))) - (/= placeholder containing-sexp)) - ;; This is shared with case 18. - (c-guess-continued-construct indent-point - char-after-ip - placeholder - containing-sexp - paren-state)) - - ;; CASE 16: block close brace, possibly closing the defun or - ;; the class - ((eq char-after-ip ?}) - ;; From here on we have the next containing sexp in lim. - (setq lim (c-most-enclosing-brace paren-state)) - (goto-char containing-sexp) - (cond - - ;; CASE 16E: Closing a statement block? This catches - ;; cases where it's preceded by a statement keyword, - ;; which works even when used in an "invalid" context, - ;; e.g. a macro argument. - ((c-after-conditional) - (c-backward-to-block-anchor lim) - (c-add-stmt-syntax 'block-close nil t lim paren-state)) - - ;; CASE 16A: closing a lambda defun or an in-expression - ;; block? C.f. cases 4, 7B and 17E. - ((setq placeholder (c-looking-at-inexpr-block - (c-safe-position containing-sexp paren-state) - nil)) - (setq tmpsymbol (if (eq (car placeholder) 'inlambda) - 'inline-close - 'block-close)) - (goto-char containing-sexp) - (back-to-indentation) - (if (= containing-sexp (point)) - (c-add-syntax tmpsymbol (point)) - (goto-char (cdr placeholder)) - (back-to-indentation) - (c-add-stmt-syntax tmpsymbol nil t - (c-most-enclosing-brace paren-state (point)) - paren-state) - (if (/= (point) (cdr placeholder)) - (c-add-syntax (car placeholder))))) - - ;; CASE 16B: does this close an inline or a function in - ;; a non-class declaration level block? - ((save-excursion - (and lim + (c-add-stmt-syntax 'brace-list-intro nil t lim paren-state))) + + ;; CASE 9D: this is just a later brace-list-entry or + ;; brace-entry-open + (t (if (or (eq char-after-ip ?{) + (and c-special-brace-lists + (save-excursion + (goto-char indent-point) + (c-forward-syntactic-ws (c-point 'eol)) + (c-looking-at-special-brace-list (point))))) + (c-add-syntax 'brace-entry-open (point)) + (c-add-syntax 'brace-list-entry (point)) + )) + )))) + + ;; CASE 10: A continued statement or top level construct. + ((and (not (memq char-before-ip '(?\; ?:))) + (not (c-at-vsemi-p before-ws-ip)) + (or (not (eq char-before-ip ?})) + (c-looking-at-inexpr-block-backward c-state-cache)) + (> (point) + (save-excursion + (c-beginning-of-statement-1 containing-sexp) + (setq placeholder (point)))) + (/= placeholder containing-sexp)) + ;; This is shared with case 18. + (c-guess-continued-construct indent-point + char-after-ip + placeholder + containing-sexp + paren-state)) + + ;; CASE 16: block close brace, possibly closing the defun or + ;; the class + ((eq char-after-ip ?}) + ;; From here on we have the next containing sexp in lim. + (setq lim (c-most-enclosing-brace paren-state)) + (goto-char containing-sexp) + (cond + + ;; CASE 16E: Closing a statement block? This catches + ;; cases where it's preceded by a statement keyword, + ;; which works even when used in an "invalid" context, + ;; e.g. a macro argument. + ((c-after-conditional) + (c-backward-to-block-anchor lim) + (c-add-stmt-syntax 'block-close nil t lim paren-state)) + + ;; CASE 16A: closing a lambda defun or an in-expression + ;; block? C.f. cases 4, 7B and 17E. + ((setq placeholder (c-looking-at-inexpr-block + (c-safe-position containing-sexp paren-state) + nil)) + (setq tmpsymbol (if (eq (car placeholder) 'inlambda) + 'inline-close + 'block-close)) + (goto-char containing-sexp) + (back-to-indentation) + (if (= containing-sexp (point)) + (c-add-syntax tmpsymbol (point)) + (goto-char (cdr placeholder)) + (back-to-indentation) + (c-add-stmt-syntax tmpsymbol nil t + (c-most-enclosing-brace paren-state (point)) + paren-state) + (if (/= (point) (cdr placeholder)) + (c-add-syntax (car placeholder))))) + + ;; CASE 16B: does this close an inline or a function in + ;; a non-class declaration level block? + ((save-excursion + (and lim + (progn + (goto-char lim) + (c-looking-at-decl-block + (c-most-enclosing-brace paren-state lim) + nil)) + (setq placeholder (point)))) + (c-backward-to-decl-anchor lim) + (back-to-indentation) + (if (save-excursion + (goto-char placeholder) + (looking-at c-other-decl-block-key)) + (c-add-syntax 'defun-close (point)) + (c-add-syntax 'inline-close (point)))) + + ;; CASE 16F: Can be a defun-close of a function declared + ;; in a statement block, e.g. in Pike or when using gcc + ;; extensions, but watch out for macros followed by + ;; blocks. Let it through to be handled below. + ;; C.f. cases B.3 and 17G. + ((save-excursion + (and (not (c-at-statement-start-p)) + (eq (c-beginning-of-statement-1 lim nil nil t) 'same) + (setq placeholder (point)) + (let ((c-recognize-typeless-decls nil)) + ;; Turn off recognition of constructs that + ;; lacks a type in this case, since that's more + ;; likely to be a macro followed by a block. + (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil)))) + (back-to-indentation) + (if (/= (point) containing-sexp) + (goto-char placeholder)) + (c-add-stmt-syntax 'defun-close nil t lim paren-state)) + + ;; CASE 16C: If there is an enclosing brace then this is + ;; a block close since defun closes inside declaration + ;; level blocks have been handled above. + (lim + ;; If the block is preceded by a case/switch label on + ;; the same line, we anchor at the first preceding label + ;; at boi. The default handling in c-add-stmt-syntax + ;; really fixes it better, but we do like this to keep + ;; the indentation compatible with version 5.28 and + ;; earlier. C.f. case 17H. + (while (and (/= (setq placeholder (point)) (c-point 'boi)) + (eq (c-beginning-of-statement-1 lim) 'label))) + (goto-char placeholder) + (if (looking-at c-label-kwds-regexp) + (c-add-syntax 'block-close (point)) + (goto-char containing-sexp) + ;; c-backward-to-block-anchor not necessary here; those + ;; situations are handled in case 16E above. + (c-add-stmt-syntax 'block-close nil t lim paren-state))) + + ;; CASE 16D: Only top level defun close left. + (t + (goto-char containing-sexp) + (c-backward-to-decl-anchor lim) + (c-add-stmt-syntax 'defun-close nil nil + (c-most-enclosing-brace paren-state) + paren-state)) + )) + + ;; CASE 17: Statement or defun catchall. + (t + (goto-char indent-point) + ;; Back up statements until we find one that starts at boi. + (while (let* ((prev-point (point)) + (last-step-type (c-beginning-of-statement-1 + containing-sexp))) + (if (= (point) prev-point) (progn - (goto-char lim) - (c-looking-at-decl-block - (c-most-enclosing-brace paren-state lim) - nil)) - (setq placeholder (point)))) - (c-backward-to-decl-anchor lim) - (back-to-indentation) - (if (save-excursion - (goto-char placeholder) - (looking-at c-other-decl-block-key)) - (c-add-syntax 'defun-close (point)) - (c-add-syntax 'inline-close (point)))) - - ;; CASE 16F: Can be a defun-close of a function declared - ;; in a statement block, e.g. in Pike or when using gcc - ;; extensions, but watch out for macros followed by - ;; blocks. Let it through to be handled below. - ;; C.f. cases B.3 and 17G. - ((save-excursion - (and (not (c-at-statement-start-p)) - (eq (c-beginning-of-statement-1 lim nil nil t) 'same) - (setq placeholder (point)) - (let ((c-recognize-typeless-decls nil)) - ;; Turn off recognition of constructs that - ;; lacks a type in this case, since that's more - ;; likely to be a macro followed by a block. - (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil)))) - (back-to-indentation) - (if (/= (point) containing-sexp) - (goto-char placeholder)) - (c-add-stmt-syntax 'defun-close nil t lim paren-state)) - - ;; CASE 16C: If there is an enclosing brace then this is - ;; a block close since defun closes inside declaration - ;; level blocks have been handled above. - (lim - ;; If the block is preceded by a case/switch label on - ;; the same line, we anchor at the first preceding label - ;; at boi. The default handling in c-add-stmt-syntax - ;; really fixes it better, but we do like this to keep - ;; the indentation compatible with version 5.28 and - ;; earlier. C.f. case 17H. - (while (and (/= (setq placeholder (point)) (c-point 'boi)) - (eq (c-beginning-of-statement-1 lim) 'label))) - (goto-char placeholder) - (if (looking-at c-label-kwds-regexp) - (c-add-syntax 'block-close (point)) - (goto-char containing-sexp) - ;; c-backward-to-block-anchor not necessary here; those - ;; situations are handled in case 16E above. - (c-add-stmt-syntax 'block-close nil t lim paren-state))) - - ;; CASE 16D: Only top level defun close left. - (t - (goto-char containing-sexp) - (c-backward-to-decl-anchor lim) - (c-add-stmt-syntax 'defun-close nil nil - (c-most-enclosing-brace paren-state) - paren-state)) - )) - - ;; CASE 17: Statement or defun catchall. + (setq step-type (or step-type last-step-type)) + nil) + (setq step-type last-step-type) + (/= (point) (c-point 'boi))))) + (cond + + ;; CASE 17B: continued statement + ((and (eq step-type 'same) + (/= (point) indent-point)) + (c-add-stmt-syntax 'statement-cont nil nil + containing-sexp paren-state)) + + ;; CASE 17A: After a case/default label? + ((progn + (while (and (eq step-type 'label) + (not (looking-at c-label-kwds-regexp))) + (setq step-type + (c-beginning-of-statement-1 containing-sexp))) + (eq step-type 'label)) + (c-add-stmt-syntax (if (eq char-after-ip ?{) + 'statement-case-open + 'statement-case-intro) + nil t containing-sexp paren-state)) + + ;; CASE 17D: any old statement + ((progn + (while (eq step-type 'label) + (setq step-type + (c-beginning-of-statement-1 containing-sexp))) + (eq step-type 'previous)) + (c-add-stmt-syntax 'statement nil t + containing-sexp paren-state) + (if (eq char-after-ip ?{) + (c-add-syntax 'block-open))) + + ;; CASE 17I: Inside a substatement block. + ((progn + ;; The following tests are all based on containing-sexp. + (goto-char containing-sexp) + ;; From here on we have the next containing sexp in lim. + (setq lim (c-most-enclosing-brace paren-state containing-sexp)) + (c-after-conditional)) + (c-backward-to-block-anchor lim) + (c-add-stmt-syntax 'statement-block-intro nil t + lim paren-state) + (if (eq char-after-ip ?{) + (c-add-syntax 'block-open))) + + ;; CASE 17E: first statement in an in-expression block. + ;; C.f. cases 4, 7B and 16A. + ((setq placeholder (c-looking-at-inexpr-block + (c-safe-position containing-sexp paren-state) + nil)) + (setq tmpsymbol (if (eq (car placeholder) 'inlambda) + 'defun-block-intro + 'statement-block-intro)) + (back-to-indentation) + (if (= containing-sexp (point)) + (c-add-syntax tmpsymbol (point)) + (goto-char (cdr placeholder)) + (back-to-indentation) + (c-add-stmt-syntax tmpsymbol nil t + (c-most-enclosing-brace c-state-cache (point)) + paren-state) + (if (/= (point) (cdr placeholder)) + (c-add-syntax (car placeholder)))) + (if (eq char-after-ip ?{) + (c-add-syntax 'block-open))) + + ;; CASE 17F: first statement in an inline, or first + ;; statement in a top-level defun. we can tell this is it + ;; if there are no enclosing braces that haven't been + ;; narrowed out by a class (i.e. don't use bod here). + ((save-excursion + (or (not (setq placeholder (c-most-enclosing-brace + paren-state))) + (and (progn + (goto-char placeholder) + (eq (char-after) ?{)) + (c-looking-at-decl-block (c-most-enclosing-brace + paren-state (point)) + nil)))) + (c-backward-to-decl-anchor lim) + (back-to-indentation) + (c-add-syntax 'defun-block-intro (point))) + + ;; CASE 17G: First statement in a function declared inside + ;; a normal block. This can occur in Pike and with + ;; e.g. the gcc extensions, but watch out for macros + ;; followed by blocks. C.f. cases B.3 and 16F. + ((save-excursion + (and (not (c-at-statement-start-p)) + (eq (c-beginning-of-statement-1 lim nil nil t) 'same) + (setq placeholder (point)) + (let ((c-recognize-typeless-decls nil)) + ;; Turn off recognition of constructs that lacks + ;; a type in this case, since that's more likely + ;; to be a macro followed by a block. + (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil)))) + (back-to-indentation) + (if (/= (point) containing-sexp) + (goto-char placeholder)) + (c-add-stmt-syntax 'defun-block-intro nil t + lim paren-state)) + + ;; CASE 17H: First statement in a block. (t - (goto-char indent-point) - ;; Back up statements until we find one that starts at boi. - (while (let* ((prev-point (point)) - (last-step-type (c-beginning-of-statement-1 - containing-sexp))) - (if (= (point) prev-point) - (progn - (setq step-type (or step-type last-step-type)) - nil) - (setq step-type last-step-type) - (/= (point) (c-point 'boi))))) - (cond - - ;; CASE 17B: continued statement - ((and (eq step-type 'same) - (/= (point) indent-point)) - (c-add-stmt-syntax 'statement-cont nil nil - containing-sexp paren-state)) - - ;; CASE 17A: After a case/default label? - ((progn - (while (and (eq step-type 'label) - (not (looking-at c-label-kwds-regexp))) - (setq step-type - (c-beginning-of-statement-1 containing-sexp))) - (eq step-type 'label)) - (c-add-stmt-syntax (if (eq char-after-ip ?{) - 'statement-case-open - 'statement-case-intro) - nil t containing-sexp paren-state)) - - ;; CASE 17D: any old statement - ((progn - (while (eq step-type 'label) - (setq step-type - (c-beginning-of-statement-1 containing-sexp))) - (eq step-type 'previous)) - (c-add-stmt-syntax 'statement nil t - containing-sexp paren-state) - (if (eq char-after-ip ?{) - (c-add-syntax 'block-open))) - - ;; CASE 17I: Inside a substatement block. - ((progn - ;; The following tests are all based on containing-sexp. - (goto-char containing-sexp) - ;; From here on we have the next containing sexp in lim. - (setq lim (c-most-enclosing-brace paren-state containing-sexp)) - (c-after-conditional)) - (c-backward-to-block-anchor lim) + ;; If the block is preceded by a case/switch label on the + ;; same line, we anchor at the first preceding label at + ;; boi. The default handling in c-add-stmt-syntax is + ;; really fixes it better, but we do like this to keep the + ;; indentation compatible with version 5.28 and earlier. + ;; C.f. case 16C. + (while (and (/= (setq placeholder (point)) (c-point 'boi)) + (eq (c-beginning-of-statement-1 lim) 'label))) + (goto-char placeholder) + (if (looking-at c-label-kwds-regexp) + (c-add-syntax 'statement-block-intro (point)) + (goto-char containing-sexp) + ;; c-backward-to-block-anchor not necessary here; those + ;; situations are handled in case 17I above. (c-add-stmt-syntax 'statement-block-intro nil t - lim paren-state) - (if (eq char-after-ip ?{) - (c-add-syntax 'block-open))) - - ;; CASE 17E: first statement in an in-expression block. - ;; C.f. cases 4, 7B and 16A. - ((setq placeholder (c-looking-at-inexpr-block - (c-safe-position containing-sexp paren-state) - nil)) - (setq tmpsymbol (if (eq (car placeholder) 'inlambda) - 'defun-block-intro - 'statement-block-intro)) - (back-to-indentation) - (if (= containing-sexp (point)) - (c-add-syntax tmpsymbol (point)) - (goto-char (cdr placeholder)) - (back-to-indentation) - (c-add-stmt-syntax tmpsymbol nil t - (c-most-enclosing-brace c-state-cache (point)) - paren-state) - (if (/= (point) (cdr placeholder)) - (c-add-syntax (car placeholder)))) - (if (eq char-after-ip ?{) - (c-add-syntax 'block-open))) - - ;; CASE 17F: first statement in an inline, or first - ;; statement in a top-level defun. we can tell this is it - ;; if there are no enclosing braces that haven't been - ;; narrowed out by a class (i.e. don't use bod here). - ((save-excursion - (or (not (setq placeholder (c-most-enclosing-brace - paren-state))) - (and (progn - (goto-char placeholder) - (eq (char-after) ?{)) - (c-looking-at-decl-block (c-most-enclosing-brace - paren-state (point)) - nil)))) - (c-backward-to-decl-anchor lim) - (back-to-indentation) - (c-add-syntax 'defun-block-intro (point))) - - ;; CASE 17G: First statement in a function declared inside - ;; a normal block. This can occur in Pike and with - ;; e.g. the gcc extensions, but watch out for macros - ;; followed by blocks. C.f. cases B.3 and 16F. - ((save-excursion - (and (not (c-at-statement-start-p)) - (eq (c-beginning-of-statement-1 lim nil nil t) 'same) - (setq placeholder (point)) - (let ((c-recognize-typeless-decls nil)) - ;; Turn off recognition of constructs that lacks - ;; a type in this case, since that's more likely - ;; to be a macro followed by a block. - (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil)))) - (back-to-indentation) - (if (/= (point) containing-sexp) - (goto-char placeholder)) - (c-add-stmt-syntax 'defun-block-intro nil t lim paren-state)) - - ;; CASE 17H: First statement in a block. - (t - ;; If the block is preceded by a case/switch label on the - ;; same line, we anchor at the first preceding label at - ;; boi. The default handling in c-add-stmt-syntax is - ;; really fixes it better, but we do like this to keep the - ;; indentation compatible with version 5.28 and earlier. - ;; C.f. case 16C. - (while (and (/= (setq placeholder (point)) (c-point 'boi)) - (eq (c-beginning-of-statement-1 lim) 'label))) - (goto-char placeholder) - (if (looking-at c-label-kwds-regexp) - (c-add-syntax 'statement-block-intro (point)) - (goto-char containing-sexp) - ;; c-backward-to-block-anchor not necessary here; those - ;; situations are handled in case 17I above. - (c-add-stmt-syntax 'statement-block-intro nil t - lim paren-state)) - (if (eq char-after-ip ?{) - (c-add-syntax 'block-open))) - )) - ) - - ;; now we need to look at any modifiers - (goto-char indent-point) - (skip-chars-forward " \t") - - ;; are we looking at a comment only line? - (when (and (looking-at c-comment-start-regexp) - (/= (c-forward-token-2 0 nil (c-point 'eol)) 0)) - (c-append-syntax 'comment-intro)) - - ;; we might want to give additional offset to friends (in C++). - (when (and c-opt-friend-key - (looking-at c-opt-friend-key)) - (c-append-syntax 'friend)) - - ;; Set syntactic-relpos. - (let ((p c-syntactic-context)) - (while (and p - (if (integerp (c-langelem-pos (car p))) - (progn - (setq syntactic-relpos (c-langelem-pos (car p))) - nil) - t)) - (setq p (cdr p)))) - - ;; Start of or a continuation of a preprocessor directive? - (if (and macro-start - (eq macro-start (c-point 'boi)) - (not (and (c-major-mode-is 'pike-mode) - (eq (char-after (1+ macro-start)) ?\")))) - (c-append-syntax 'cpp-macro) - (when (and c-syntactic-indentation-in-macros macro-start) - (if in-macro-expr - (when (or - (< syntactic-relpos macro-start) - (not (or - (assq 'arglist-intro c-syntactic-context) - (assq 'arglist-cont c-syntactic-context) - (assq 'arglist-cont-nonempty c-syntactic-context) - (assq 'arglist-close c-syntactic-context)))) - ;; If inside a cpp expression, i.e. anywhere in a - ;; cpp directive except a #define body, we only let - ;; through the syntactic analysis that is internal - ;; in the expression. That means the arglist - ;; elements, if they are anchored inside the cpp - ;; expression. - (setq c-syntactic-context nil) - (c-add-syntax 'cpp-macro-cont macro-start)) - (when (and (eq macro-start syntactic-relpos) - (not (assq 'cpp-define-intro c-syntactic-context)) - (save-excursion - (goto-char macro-start) - (or (not (c-forward-to-cpp-define-body)) - (<= (point) (c-point 'boi indent-point))))) - ;; Inside a #define body and the syntactic analysis is - ;; anchored on the start of the #define. In this case - ;; we add cpp-define-intro to get the extra - ;; indentation of the #define body. - (c-add-syntax 'cpp-define-intro))))) - - ;; return the syntax - c-syntactic-context))) + (if (eq char-after-ip ?{) + (c-add-syntax 'block-open))) + )) + ) + + ;; now we need to look at any modifiers + (goto-char indent-point) + (skip-chars-forward " \t") + + ;; are we looking at a comment only line? + (when (and (looking-at c-comment-start-regexp) + (/= (c-forward-token-2 0 nil (c-point 'eol)) 0)) + (c-append-syntax 'comment-intro)) + + ;; we might want to give additional offset to friends (in C++). + (when (and c-opt-friend-key + (looking-at c-opt-friend-key)) + (c-append-syntax 'friend)) + + ;; Set syntactic-relpos. + (let ((p c-syntactic-context)) + (while (and p + (if (integerp (c-langelem-pos (car p))) + (progn + (setq syntactic-relpos (c-langelem-pos (car p))) + nil) + t)) + (setq p (cdr p)))) + + ;; Start of or a continuation of a preprocessor directive? + (if (and macro-start + (eq macro-start (c-point 'boi)) + (not (and (c-major-mode-is 'pike-mode) + (eq (char-after (1+ macro-start)) ?\")))) + (c-append-syntax 'cpp-macro) + (when (and c-syntactic-indentation-in-macros macro-start) + (if in-macro-expr + (when (or + (< syntactic-relpos macro-start) + (not (or + (assq 'arglist-intro c-syntactic-context) + (assq 'arglist-cont c-syntactic-context) + (assq 'arglist-cont-nonempty c-syntactic-context) + (assq 'arglist-close c-syntactic-context)))) + ;; If inside a cpp expression, i.e. anywhere in a + ;; cpp directive except a #define body, we only let + ;; through the syntactic analysis that is internal + ;; in the expression. That means the arglist + ;; elements, if they are anchored inside the cpp + ;; expression. + (setq c-syntactic-context nil) + (c-add-syntax 'cpp-macro-cont macro-start)) + (when (and (eq macro-start syntactic-relpos) + (not (assq 'cpp-define-intro c-syntactic-context)) + (save-excursion + (goto-char macro-start) + (or (not (c-forward-to-cpp-define-body)) + (<= (point) (c-point 'boi indent-point))))) + ;; Inside a #define body and the syntactic analysis is + ;; anchored on the start of the #define. In this case + ;; we add cpp-define-intro to get the extra + ;; indentation of the #define body. + (c-add-syntax 'cpp-define-intro))))) + + ;; return the syntax + c-syntactic-context))) ;; Indentation calculation. ------------------------------------------------------------ revno: 103561 committer: Chong Yidong branch nick: trunk timestamp: Sun 2011-03-06 10:54:36 -0500 message: Improve packaging documentation. * package.texi (Packaging, Packaging Basics, Simple Packages) (Multi-file Packages): Expand and clarify. (Package Archives): Temporary placeholder node. * elisp.texi (Top): Update node listing. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2011-03-06 05:34:35 +0000 +++ doc/lispref/ChangeLog 2011-03-06 15:54:36 +0000 @@ -1,5 +1,11 @@ 2011-03-06 Chong Yidong + * package.texi (Packaging, Packaging Basics, Simple Packages) + (Multi-file Packages): Expand and clarify. + (Package Archives): Temporary placeholder node. + + * elisp.texi (Top): Update node listing. + * Makefile.in (srcs): Add package.texi. 2011-03-05 Chong Yidong === modified file 'doc/lispref/elisp.texi' --- doc/lispref/elisp.texi 2011-02-19 19:40:59 +0000 +++ doc/lispref/elisp.texi 2011-03-06 15:54:36 +0000 @@ -1399,6 +1399,7 @@ * Packaging Basics:: The basic concepts of Emacs Lisp packages. * Simple Packages:: How to package a single .el file. * Multi-file Packages:: How to package multiple files. +* Package Archives:: Maintaining package archives. Starting Up Emacs === modified file 'doc/lispref/package.texi' --- doc/lispref/package.texi 2011-01-26 08:36:39 +0000 +++ doc/lispref/package.texi 2011-03-06 15:54:36 +0000 @@ -7,186 +7,223 @@ @chapter Preparing Lisp code for distribution @cindex packaging - Emacs provides a standard way for Emacs Lisp code to be distributed -to users. This approach lets users easily download, install, -uninstall, and upgrade Lisp code that they might want to use. + Emacs provides a standard way to distribute Emacs Lisp code to +users. A @dfn{package} is a collection of one or more files, +formatted and bundled in such a way that users can easily download, +install, uninstall, and upgrade it. - A @dfn{package} is simply one or more files, formatted and bundled -in a particular way. Typically a package includes primarily Emacs -Lisp code, but it is possible to create other kinds of packages as -well. + The following sections describe how to create a package, and how to +put it in a @dfn{package archive} for others to download. @menu * Packaging Basics:: The basic concepts of Emacs Lisp packages. * Simple Packages:: How to package a single .el file. * Multi-file Packages:: How to package multiple files. +* Package Archives:: Maintaining package archives. @end menu @node Packaging Basics @section Packaging Basics @cindex packaging basics - - A package has a few attributes: @cindex package attributes + A package is either a @dfn{simple package} or a @dfn{multi-file +package}. A simple package is stored in a package archive as a single +Emacs Lisp file, while a multi-file package is stored as a tar file +(containing multiple Lisp files, and possibly non-Lisp files such as a +manual). + + In ordinary usage, the difference between simple packages and +multi-file packages is relatively unimportant; the Package Menu +interface makes no distinction between them. However, the procedure +for creating them differs, as explained in the following sections. + + Each package (whether simple or multi-file) has certain +@dfn{attributes}: + @table @asis @item Name -A string, the name of the package. This attribute is mandatory. If -it does not exist, the package cannot be installed by the package -manager. +A short word (e.g. @samp{auctex}). This is usually also the symbol +prefix used in the program (@pxref{Coding Conventions}). @item Version -A version number, which is anything that can be parsed by -@code{version-to-list}. This attribute is mandatory. If it does not -exist, the package cannot be installed by the package manager. +A version number, in a form that the function @code{version-to-list} +understands (e.g. @samp{11.86}). Each release of a package should be +accompanied by an increase in the version number. @item Brief description -This is shown to the user in the package menu buffer. It is just a -single line. On a terminal with 80 characters per line, there are -only 36 characters available in the package menu mode for showing the -brief description, so it is best to keep it very brief. If no brief -name is given, an empty string is used. +This is shown when the package is listed in the Package Menu. It +should occupy a single line, ideally in 36 characters or less. @item Long description -This can be a @file{README} file or the like. This is available to -the user before the package is installed, via the package menu. It -should more fully describe the package and its capabilities, so a user -can read it to decide whether he wants to install the package. This -attribute is optional. +This is shown in the buffer created by @kbd{C-h P} +(@code{describe-package}), following the package's brief description +and installation status. It normally spans multiple lines, and should +fully describe the package and its capabilities. @item Dependencies -This is a list of other packages and their minimal acceptable -versions. This is used both at download time (to make sure all the -needed code is available) and at activation time (to ensure a package -is only activated if all its dependencies have been successfully -activated). This attribute is optional. - -@item Manual -A package can optionally include an Info manual. -@end table - - Conceptually, a package goes through several state transitions (in -reality some of these transitions are grouped together): - -@table @asis -@item Download -Fetch the package from somewhere. - -@item Install -Unpack the package, or write a @file{.el} file into the appropriate -install directory. This step also includes extracting autoloads and -byte-compiling the Emacs Lisp code. - -@item Activate -Update @code{load-path} and @code{Info-directory-list} and evaluate -the autoloads, so that the package is ready for the user to use. -@end table - - It is best for users if packages do not do too much work at -activation time. The best approach is to have activation consist of -some autoloads and little more. +A list of other packages (possibly including minimal acceptable +version numbers) on which this package depends. The list may be +empty, meaning this package has no dependencies. Otherwise, +installing this package also automatically installs its dependencies; +if any dependency cannot be found, the package cannot be installed. +@end table + + Installing a package, either via the Package Menu, or via the +command @code{package-install-file}, creates a subdirectory of +@code{package-user-dir} named @file{@var{name}-@var{version}}, where +@var{name} is the package's name and @var{version} its version +(e.g. @file{~/.emacs.d/elpa/auctex-11.86/}). We call this the +package's @dfn{content directory}. It is where Emacs puts the +package's contents (the single Lisp file for a simple package, or the +files extracted from a multi-file package). + + Emacs then searches every Lisp file in the content directory for +autoload magic comments (@pxref{Autoload}). These autoload +definitions are saved to a file named @file{@var{name}-autoloads.el} +in the content directory. They are typically used to autoload the +principal user commands defined in the package, but they can also +perform other tasks, such as adding an element to +@code{auto-mode-alist} (@pxref{Auto Major Mode}). During this time, +Emacs will also byte-compile the Lisp files. + + After installation, and (by default) each time Emacs is started, the +installed package is @dfn{activated}. During activation, Emacs adds +the package's content directory to @code{load-path}, and evaluates the +autoload definitions in @file{@var{name}-autoloads.el}. + + Note that a package typically does @emph{not} autoload every +function and variable defined within it---only the handful of commands +typically called to begin using the package. @node Simple Packages @section Simple Packages @cindex single file packages - The simplest package consists of a single Emacs Lisp source file. -In this case, all the attributes of the package (@pxref{Packaging -Basics}) are taken from this file. - - The package system expects this @file{.el} file to conform to the -Emacs Lisp library header conventions. @xref{Library Headers}. - - The name of the package is the same as the base name of the -@file{.el} file, as written in the first comment line. For example, -given the header line: - -@smallexample -;;; superfrobnicator.el --- frobnicate and bifurcate flanges -@end smallexample - -the package name will be @samp{superfrobnicator}. - - The short description of the package is also taken from the first -line of the file. - - If the file has a ``Commentary'' header, then it is used as the long -description. - - The version of the package comes either from the ``Package-Version'' -header, if it exists, or from the ``Version'' header. A package is -required to have a version number. Each release of a package must be -accompanied by an increase in the version number. - - If the file has a ``Package-Requires'' header, then that is used as -the package dependencies. Otherwise, the package is assumed not to -have any dependencies. - - A single-file package cannot have an Info manual. - - The file will be scanned for autoload cookies at install time. -@xref{Autoload}. + A simple package consists of a single Emacs Lisp source file. The +file must conform to the Emacs Lisp library header conventions +(@pxref{Library Headers}). The package's attributes are taken from +the various headers, as illustrated by the following example: + +@example +@group +;;; superfrobnicator.el --- Frobnicate and bifurcate flanges + +;; Copyright (C) 2011 Free Software Foundation, Inc. +@end group + +;; Author: J. R. Hacker +;; Version: 1.3 +;; Package-Requires: ((flange "1.0")) +;; Keywords: frobnicate + +@dots{} + +;;; Commentary: + +;; This package provides a minor mode to frobnicate and/or +;; bifurcate any flanges you desire. To activate it, just type +@dots{} + +;;;###autoload +(define-minor-mode superfrobnicator-mode +@dots{} +@end example + + The name of the package is the same as the base name of the file, as +written on the first line. Here, it is @samp{superfrobnicator}. + + The brief description is also taken from the first line. Here, it +is @samp{Frobnicate and bifurcate flanges}. + + The version number comes from the @samp{Package-Version} header, if +it exists, or from the @samp{Version} header otherwise. One or the +other @emph{must} be present. Here, the version number is 1.3. + + If the file has a @samp{;;; Commentary:} section, this section is +used as the long description. (When displaying the description, Emacs +omits the @samp{;;; Commentary:} line, as well as the leading comment +characters in the commentary itself.) + + If the file has a @samp{Package-Requires} header, that is used as +the package dependencies. In the above example, the package depends +on the @samp{flange} package, version 1.0 or higher. @xref{Library +Headers}, for a description of the @samp{Package-Requires} header. If +the header is omitted, the package has no dependencies. + + The file ought to also contain one or more autoload magic comments, +as explained in @ref{Packaging Basics}. In the above example, a magic +comment autoloads @code{superfrobnicator-mode}. + + @xref{Package Archives}, for a explanation of how to add a +single-file package to a package archive. @node Multi-file Packages @section Multi-file Packages @cindex multi-file packages - A multi-file package is just a @file{.tar} file. While less -convenient to create than a single-file package, a multi-file package -also offers more features: it can include an Info manual, multiple -Emacs Lisp files, and also other data files needed by a package. - - The contents of the @file{.tar} file must all appear beneath a -single directory, named after the package and version. Files can -appear in subdirectories of this top-most directory, but Emacs Lisp -code will only be found (and thus byte-compiled) at the top-most -level. Also, the @file{.tar} file is typically also given this same -name. For example, if you are distributing version 1.3 of the -superfrobnicator, the package file would be named -``superfrobnicator-1.3.tar'' and the contents would all appear in the -directory @file{superfrobnicator-1.3} in that @file{.tar}. - - The package must include a @file{-pkg.el} file, named after the -package. In our example above, this file would be called -@file{superfrobnicator-pkg.el}. This file must have a single form in -it, a call to @code{define-package}. The package dependencies and -brief description are taken from this form. + A multi-file package is less convenient to create than a single-file +package, but it offers more features: it can include multiple Emacs +Lisp files, an Info manual, and other file types (such as images). + + Prior to installation, a multi-file package is stored in a package +archive as a tar file. The tar file must be named +@file{@var{name}-@var{version}.tar}, where @var{name} is the package +name and @var{version} is the version number. Its contents, once +extracted, must all appear in a directory named +@file{@var{name}-@var{version}}, the @dfn{content directory} +(@pxref{Packaging Basics}). Files may also extract into +subdirectories of the content directory. + + One of the files in the content directory must be named +@file{@var{name}-pkg.el}. It must contain a single Lisp form, +consisting of a call to the function @code{define-package}, described +below. This defines the package's version, brief description, and +requirements. + + For example, if we distribute version 1.3 of the superfrobnicator as +a multi-file package, the tar file would be +@file{superfrobnicator-1.3.tar}. Its contents would extract into the +directory @file{superfrobnicator-1.3}, and one of these would be the +file @file{superfrobnicator-pkg.el}. @defun define-package name version &optional docstring requirements -Define a package. @var{name} is the name of the package, a string. -@var{version} is the package's version, a string. It must be in a -form that can be understood by @code{version-to-list}. -@var{docstring} is the short description of the package. +This function defines a package. @var{name} is the package name, a +string. @var{version} is the version, as a string of a form that can +be understood by the function @code{version-to-list}. @var{docstring} +is the brief description. + @var{requirements} is a list of required packages and their versions. +Each element in this list should have the form @code{(@var{dep-name} +@var{dep-version})}, where @var{dep-name} is a symbol whose name is +the dependency's package name, and @var{dep-version} is the +dependency's version (a string). @end defun - If a @file{README} file exists in the content directory, then it is -used as the long description. + If the content directory contains a file named @file{README}, this +file is used as the long description. - If the package has an Info manual, you should distribute the needed -info files, plus a @file{dir} file made with @command{install-info}. + If the content directory contains a file named @file{dir}, this is +assumed to be an Info directory file made with @command{install-info}. @xref{Invoking install-info, Invoking install-info, Invoking -install-info, texinfo, Texinfo}. - - Do not include any @file{.elc} files in the package. Those will be -created at install time. Note that there is no way to control the -order in which files are byte-compiled; your package must be robust -here. - - The installation process will scan all the @file{.el} files in the -package for autoload cookies. @xref{Autoload}. They are extracted -into a @file{-autoloads.el} file (e.g., -@file{superfrobnicator-autoloads.el}), so do not include a file of -that name in your package. - - Any other files in the @file{.tar} file are simply unpacked when the -package is installed. This can be useful if your package needs -auxiliary data files --- e.g., icons or sounds. - - Emacs Lisp code installed via the package manager must take special -care to be location-independent. One easy way to do this is to make -references to auxiliary data files relative to @var{load-file-name}. -For example: +install-info, texinfo, Texinfo}. The Info files listed in this +directory file should also be present in the content directory. In +this case, Emacs will automatically add the content directory to +@code{Info-directory-list} when the package is activated. + + Do not include any @file{.elc} files in the package. Those are +created when the package is installed. Note that there is no way to +control the order in which files are byte-compiled. + + Do not include any file named @file{@var{name}-autoloads.el}. This +file is reserved for the package's autoload definitions +(@pxref{Packaging Basics}). It is created automatically when the +package is installed, by searching all the Lisp files in the package +for autoload magic comments. + + If the multi-file package contains auxiliary data files (such as +images), the package's Lisp code can refer to these files via the +variable @code{load-file-name} (@pxref{Loading}). Here is an example: @smallexample (defconst superfrobnicator-base (file-name-directory load-file-name)) @@ -194,3 +231,8 @@ (defun superfrobnicator-fetch-image (file) (expand-file-name file superfrobnicator-base)) @end smallexample + +@node Package Archives +@section Creating and Maintaining Package Archives + +To be done. ------------------------------------------------------------ revno: 103560 [merge] committer: Paul Eggert branch nick: trunk timestamp: Sun 2011-03-06 02:53:51 -0800 message: Merge: current_column: Now returns EMACS_INT, fixing some iftc that was introduced in the 2002-06-02 change "temporarily"; see . * bytecode.c (Fbyte_code): Don't cast current_column () to int. * cmds.c (internal_self_insert): Likewise. * indent.c (Fcurrent_column): Likewise. * keymap.c (describe_command): Likewise. * minibuf.c (read_minibuf): Likewise. * indent.c (Fcurrent_indentation): Don't cast position_indentation () to int. * xdisp.c (redisplay_internal, redisplay_window, decode_mode_spec): Likewise. * cmds.c (internal_self_insert): Declare locals to be EMACS_INT, not int or double, if they might contain a column number. * indent.c (current_column, Findent_to, indented_beyond_p): (compute_motion, vmotion): Likewise. * keymap.c (describe_command): Likewise. * xdisp.c (pint2str): Likewise. * indent.c (last_known_column): Now EMACS_INT, not int. * minibuf.c (minibuf_prompt_width): Likewise. * indent.c (current_column, current_column_1, position_indentation): Return EMACS_INT, not double. * lisp.h (current_column): Likewise. * indent.c (indented_beyond_p): Last arg is now EMACS_INT, not double. All callers changed. * lisp.h (indented_beyond_p): Likewise. * minibuf.c (minibuf_prompt, minibuf_prompt_width): Move here from xdisp.c, and make static, since these are used only here. * window.h, xdisp.c (minibuf_prompt, minibuf_prompt_width): Remove decls. * xdisp.c (redisplay_window): Reindent to match Emacs style. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-03-06 09:00:53 +0000 +++ src/ChangeLog 2011-03-06 10:53:51 +0000 @@ -1,6 +1,39 @@ 2011-03-06 Paul Eggert + current_column: Now returns EMACS_INT, fixing some iftc + that was introduced in the 2002-06-02 change "temporarily"; see + . + * bytecode.c (Fbyte_code): Don't cast current_column () to int. + * cmds.c (internal_self_insert): Likewise. + * indent.c (Fcurrent_column): Likewise. + * keymap.c (describe_command): Likewise. + * minibuf.c (read_minibuf): Likewise. + * indent.c (Fcurrent_indentation): Don't cast position_indentation () + to int. + * xdisp.c (redisplay_internal, redisplay_window, decode_mode_spec): + Likewise. + * cmds.c (internal_self_insert): Declare locals to be EMACS_INT, + not int or double, if they might contain a column number. + * indent.c (current_column, Findent_to, indented_beyond_p): + (compute_motion, vmotion): Likewise. + * keymap.c (describe_command): Likewise. + * xdisp.c (pint2str): Likewise. + * indent.c (last_known_column): Now EMACS_INT, not int. + * minibuf.c (minibuf_prompt_width): Likewise. + * indent.c (current_column, current_column_1, position_indentation): + Return EMACS_INT, not double. + * lisp.h (current_column): Likewise. + * indent.c (indented_beyond_p): Last arg is now EMACS_INT, not double. + All callers changed. + * lisp.h (indented_beyond_p): Likewise. + + * minibuf.c (minibuf_prompt, minibuf_prompt_width): Move here + from xdisp.c, and make static, since these are used only here. + * window.h, xdisp.c (minibuf_prompt, minibuf_prompt_width): + Remove decls. + * cmds.c (internal_self_insert): Reindent to match Emacs style. + * xdisp.c (redisplay_window): Likewise. * xdisp.c: Rename or move local decls to avoid shadowing. (init_iterator, handle_fontified_prop, handle_single_display_spec): === modified file 'src/bytecode.c' --- src/bytecode.c 2011-02-18 02:07:36 +0000 +++ src/bytecode.c 2011-03-06 10:27:06 +0000 @@ -1323,7 +1323,7 @@ { Lisp_Object v1; BEFORE_POTENTIAL_GC (); - XSETFASTINT (v1, (int) current_column ()); /* iftc */ + XSETFASTINT (v1, current_column ()); AFTER_POTENTIAL_GC (); PUSH (v1); break; === modified file 'src/cmds.c' --- src/cmds.c 2011-03-06 09:00:53 +0000 +++ src/cmds.c 2011-03-06 10:27:06 +0000 @@ -381,19 +381,22 @@ { EMACS_INT pos = PT; EMACS_INT pos_byte = PT_BYTE; + + /* FIXME: Check for integer overflow when calculating + target_clm and actual_clm. */ + /* Column the cursor should be placed at after this insertion. The correct value should be calculated only when necessary. */ - int target_clm = ((int) current_column () /* iftc */ - + n * (int) XINT (Fchar_width (make_number (c)))); + EMACS_INT target_clm = (current_column () + + n * XINT (Fchar_width (make_number (c)))); /* The actual cursor position after the trial of moving to column TARGET_CLM. It is greater than TARGET_CLM if the TARGET_CLM is middle of multi-column character. In that case, the new point is set after that character. */ - int actual_clm - = (int) XFASTINT (Fmove_to_column (make_number (target_clm), - Qnil)); + EMACS_INT actual_clm + = XFASTINT (Fmove_to_column (make_number (target_clm), Qnil)); chars_to_delete = PT - pos; === modified file 'src/indent.c' --- src/indent.c 2011-02-16 15:02:50 +0000 +++ src/indent.c 2011-03-06 10:27:06 +0000 @@ -45,7 +45,7 @@ Some things in set last_known_column_point to -1 to mark the memorized value as invalid. */ -static double last_known_column; +static EMACS_INT last_known_column; /* Value of point when current_column was called. */ @@ -55,8 +55,8 @@ static int last_known_column_modified; -static double current_column_1 (void); -static double position_indentation (int); +static EMACS_INT current_column_1 (void); +static EMACS_INT position_indentation (int); /* Cache of beginning of line found by the last call of current_column. */ @@ -309,7 +309,7 @@ (void) { Lisp_Object temp; - XSETFASTINT (temp, (int) current_column ()); /* iftc */ + XSETFASTINT (temp, current_column ()); return temp; } @@ -321,15 +321,15 @@ last_known_column_point = 0; } -double +EMACS_INT current_column (void) { - register int col; + register EMACS_INT col; register unsigned char *ptr, *stop; register int tab_seen; - int post_tab; + EMACS_INT post_tab; register int c; - register int tab_width = XINT (BVAR (current_buffer, tab_width)); + register EMACS_INT tab_width = XINT (BVAR (current_buffer, tab_width)); int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow)); register struct Lisp_Char_Table *dp = buffer_display_table (); @@ -705,7 +705,7 @@ This function handles characters that are invisible due to text properties or overlays. */ -static double +static EMACS_INT current_column_1 (void) { EMACS_INT col = MOST_POSITIVE_FIXNUM; @@ -807,9 +807,9 @@ The return value is COLUMN. */) (Lisp_Object column, Lisp_Object minimum) { - int mincol; - register int fromcol; - register int tab_width = XINT (BVAR (current_buffer, tab_width)); + EMACS_INT mincol; + register EMACS_INT fromcol; + register EMACS_INT tab_width = XINT (BVAR (current_buffer, tab_width)); CHECK_NUMBER (column); if (NILP (minimum)) @@ -849,8 +849,6 @@ } -static double position_indentation (int); - DEFUN ("current-indentation", Fcurrent_indentation, Scurrent_indentation, 0, 0, 0, doc: /* Return the indentation of the current line. @@ -863,12 +861,12 @@ scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1); - XSETFASTINT (val, (int) position_indentation (PT_BYTE)); /* iftc */ + XSETFASTINT (val, position_indentation (PT_BYTE)); SET_PT_BOTH (opoint, opoint_byte); return val; } -static double +static EMACS_INT position_indentation (register int pos_byte) { register EMACS_INT column = 0; @@ -958,9 +956,9 @@ preceding line. */ int -indented_beyond_p (EMACS_INT pos, EMACS_INT pos_byte, double column) +indented_beyond_p (EMACS_INT pos, EMACS_INT pos_byte, EMACS_INT column) { - double val; + EMACS_INT val; EMACS_INT opoint = PT, opoint_byte = PT_BYTE; SET_PT_BOTH (pos, pos_byte); @@ -969,7 +967,7 @@ val = position_indentation (PT_BYTE); SET_PT_BOTH (opoint, opoint_byte); - return val >= column; /* hmm, float comparison */ + return val >= column; } DEFUN ("move-to-column", Fmove_to_column, Smove_to_column, 1, 2, "p", @@ -1126,7 +1124,7 @@ register EMACS_INT tab_width = XFASTINT (BVAR (current_buffer, tab_width)); register int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow)); register struct Lisp_Char_Table *dp = window_display_table (win); - int selective + EMACS_INT selective = (INTEGERP (BVAR (current_buffer, selective_display)) ? XINT (BVAR (current_buffer, selective_display)) : !NILP (BVAR (current_buffer, selective_display)) ? -1 : 0); @@ -1590,8 +1588,7 @@ else if (c == '\n') { if (selective > 0 - && indented_beyond_p (pos, pos_byte, - (double) selective)) /* iftc */ + && indented_beyond_p (pos, pos_byte, selective)) { /* If (pos == to), we don't have to take care of selective display. */ @@ -1607,7 +1604,7 @@ } while (pos < to && indented_beyond_p (pos, pos_byte, - (double) selective)); /* iftc */ + selective)); /* Allow for the " ..." that is displayed for them. */ if (selective_rlen) { @@ -1837,7 +1834,7 @@ register EMACS_INT first; EMACS_INT from_byte; EMACS_INT lmargin = hscroll > 0 ? 1 - hscroll : 0; - int selective + EMACS_INT selective = (INTEGERP (BVAR (current_buffer, selective_display)) ? XINT (BVAR (current_buffer, selective_display)) : !NILP (BVAR (current_buffer, selective_display)) ? -1 : 0); @@ -1872,7 +1869,7 @@ && ((selective > 0 && indented_beyond_p (prevline, CHAR_TO_BYTE (prevline), - (double) selective)) /* iftc */ + selective)) /* Watch out for newlines with `invisible' property. When moving upward, check the newline before. */ || (propval = Fget_char_property (make_number (prevline - 1), @@ -1929,7 +1926,7 @@ && ((selective > 0 && indented_beyond_p (prevline, CHAR_TO_BYTE (prevline), - (double) selective)) /* iftc */ + selective)) /* Watch out for newlines with `invisible' property. When moving downward, check the newline after. */ || (propval = Fget_char_property (make_number (prevline), === modified file 'src/keymap.c' --- src/keymap.c 2011-02-28 01:07:29 +0000 +++ src/keymap.c 2011-03-06 10:27:06 +0000 @@ -3219,7 +3219,7 @@ describe_command (Lisp_Object definition, Lisp_Object args) { register Lisp_Object tem1; - int column = (int) current_column (); /* iftc */ + EMACS_INT column = current_column (); int description_column; /* If column 16 is no good, go to col 32; === modified file 'src/lisp.h' --- src/lisp.h 2011-02-18 07:44:39 +0000 +++ src/lisp.h 2011-03-06 10:27:06 +0000 @@ -3145,9 +3145,9 @@ EXFUN (Fvertical_motion, 2); EXFUN (Findent_to, 2); EXFUN (Fmove_to_column, 2); -extern double current_column (void); +extern EMACS_INT current_column (void); extern void invalidate_current_column (void); -extern int indented_beyond_p (EMACS_INT, EMACS_INT, double); +extern int indented_beyond_p (EMACS_INT, EMACS_INT, EMACS_INT); extern void syms_of_indent (void); /* Defined in frame.c */ === modified file 'src/minibuf.c' --- src/minibuf.c 2011-02-16 15:02:50 +0000 +++ src/minibuf.c 2011-03-06 10:27:06 +0000 @@ -82,6 +82,15 @@ Lisp_Object Qread_expression_history; +/* Prompt to display in front of the mini-buffer contents. */ + +static Lisp_Object minibuf_prompt; + +/* Width of current mini-buffer prompt. Only set after display_line + of the line that contains the prompt. */ + +static EMACS_INT minibuf_prompt_width; + /* Put minibuf on currently selected frame's minibuffer. We do this whenever the user starts a new minibuffer @@ -623,7 +632,7 @@ unbind_to (count1, Qnil); } - minibuf_prompt_width = (int) current_column (); /* iftc */ + minibuf_prompt_width = current_column (); /* Put in the initial input. */ if (!NILP (initial)) === modified file 'src/window.h' --- src/window.h 2011-01-25 04:08:28 +0000 +++ src/window.h 2011-03-06 09:52:06 +0000 @@ -788,14 +788,6 @@ void set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int keep_margins_p); -/* Prompt to display in front of the minibuffer contents. */ - -extern Lisp_Object minibuf_prompt; - -/* The visual width of the above. */ - -extern int minibuf_prompt_width; - /* This is the window where the echo area message was displayed. It is always a minibuffer window, but it may not be the same window currently active as a minibuffer. */ @@ -878,4 +870,3 @@ extern int window_box_text_cols (struct window *w); #endif /* not WINDOW_H_INCLUDED */ - === modified file 'src/xdisp.c' --- src/xdisp.c 2011-03-06 08:17:04 +0000 +++ src/xdisp.c 2011-03-06 10:27:06 +0000 @@ -483,15 +483,6 @@ static Lisp_Object default_invis_vector[3]; -/* Prompt to display in front of the mini-buffer contents. */ - -Lisp_Object minibuf_prompt; - -/* Width of current mini-buffer prompt. Only set after display_line - of the line that contains the prompt. */ - -int minibuf_prompt_width; - /* This is the window where the echo area message was displayed. It is always a mini-buffer window, but it may not be the same window currently active as a mini-buffer. */ @@ -771,7 +762,7 @@ static void handle_line_prefix (struct it *); -static void pint2str (char *, int, int); +static void pint2str (char *, int, EMACS_INT); static void pint2hrstr (char *, int, int); static struct text_pos run_window_scroll_functions (Lisp_Object, struct text_pos); @@ -11588,8 +11579,7 @@ && !(PT == XFASTINT (w->last_point) && XFASTINT (w->last_modified) >= MODIFF && XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF) - && (XFASTINT (w->column_number_displayed) - != (int) current_column ())) /* iftc */ + && (XFASTINT (w->column_number_displayed) != current_column ())) w->update_mode_line = Qt; unbind_to (count1, Qnil); @@ -13828,8 +13818,7 @@ && !(PT == XFASTINT (w->last_point) && XFASTINT (w->last_modified) >= MODIFF && XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF) - && (XFASTINT (w->column_number_displayed) - != (int) current_column ())) /* iftc */ + && (XFASTINT (w->column_number_displayed) != current_column ())) update_mode_line = 1; /* Count number of windows showing the selected buffer. An indirect @@ -14337,11 +14326,10 @@ || INTEGERP (w->base_line_pos) /* Column number is displayed and different from the one displayed. */ || (!NILP (w->column_number_displayed) - && (XFASTINT (w->column_number_displayed) - != (int) current_column ()))) /* iftc */ - /* This means that the window has a mode line. */ - && (WINDOW_WANTS_MODELINE_P (w) - || WINDOW_WANTS_HEADER_LINE_P (w))) + && (XFASTINT (w->column_number_displayed) != current_column ()))) + /* This means that the window has a mode line. */ + && (WINDOW_WANTS_MODELINE_P (w) + || WINDOW_WANTS_HEADER_LINE_P (w))) { display_mode_lines (w); @@ -18992,7 +18980,7 @@ the positive integer D to BUF using a minimal field width WIDTH. */ static void -pint2str (register char *buf, register int width, register int d) +pint2str (register char *buf, register int width, register EMACS_INT d) { register char *p = buf; @@ -19321,7 +19309,7 @@ return ""; else { - int col = (int) current_column (); /* iftc */ + EMACS_INT col = current_column (); w->column_number_displayed = make_number (col); pint2str (decode_mode_spec_buf, field_width, col); return decode_mode_spec_buf; ------------------------------------------------------------ revno: 103559 committer: Paul Eggert branch nick: trunk timestamp: Sun 2011-03-06 01:00:53 -0800 message: * cmds.c (internal_self_insert): Reindent to match Emacs style. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-03-06 08:17:04 +0000 +++ src/ChangeLog 2011-03-06 09:00:53 +0000 @@ -1,5 +1,7 @@ 2011-03-06 Paul Eggert + * cmds.c (internal_self_insert): Reindent to match Emacs style. + * xdisp.c: Rename or move local decls to avoid shadowing. (init_iterator, handle_fontified_prop, handle_single_display_spec): (message_dolog, message_with_string, redisplay_internal): === modified file 'src/cmds.c' --- src/cmds.c 2011-02-16 16:35:16 +0000 +++ src/cmds.c 2011-03-06 09:00:53 +0000 @@ -386,28 +386,29 @@ int target_clm = ((int) current_column () /* iftc */ + n * (int) XINT (Fchar_width (make_number (c)))); - /* The actual cursor position after the trial of moving - to column TARGET_CLM. It is greater than TARGET_CLM - if the TARGET_CLM is middle of multi-column - character. In that case, the new point is set after - that character. */ - int actual_clm - = (int) XFASTINT (Fmove_to_column (make_number (target_clm), - Qnil)); - - chars_to_delete = PT - pos; - - if (actual_clm > target_clm) - { /* We will delete too many columns. Let's fill columns - by spaces so that the remaining text won't move. */ + /* The actual cursor position after the trial of moving + to column TARGET_CLM. It is greater than TARGET_CLM + if the TARGET_CLM is middle of multi-column + character. In that case, the new point is set after + that character. */ + int actual_clm + = (int) XFASTINT (Fmove_to_column (make_number (target_clm), + Qnil)); + + chars_to_delete = PT - pos; + + if (actual_clm > target_clm) + { + /* We will delete too many columns. Let's fill columns + by spaces so that the remaining text won't move. */ EMACS_INT actual = PT_BYTE; DEC_POS (actual); if (FETCH_CHAR (actual) == '\t') /* Rather than add spaces, let's just keep the tab. */ chars_to_delete--; else - spaces_to_insert = actual_clm - target_clm; - } + spaces_to_insert = actual_clm - target_clm; + } SET_PT_BOTH (pos, pos_byte); } ------------------------------------------------------------ revno: 103558 [merge] committer: Paul Eggert branch nick: trunk timestamp: Sun 2011-03-06 00:31:32 -0800 message: * xdisp.c: Rename or move local decls to avoid shadowing. Also: (BUILD_GLYPHLESS_GLYPH_STRING): Omit unused local var. (produce_glyphless_glyph): Make a pointer "const". (update_window_cursor): Now static, since it's not used elsewhere. (SKIP_GLYPHS): Removed unused macro. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-03-06 02:43:19 +0000 +++ src/ChangeLog 2011-03-06 08:17:04 +0000 @@ -1,3 +1,19 @@ +2011-03-06 Paul Eggert + + * xdisp.c: Rename or move local decls to avoid shadowing. + (init_iterator, handle_fontified_prop, handle_single_display_spec): + (message_dolog, message_with_string, redisplay_internal): + (redisplay_window, try_window_reusing_current_matrix, try_window_id): + (compute_line_metrics, highlight_trailing_whitespace, cursor_row_p): + (display_line, display_string, rows_from_pos_range): + (mouse_face_from_buffer_pos, note_mouse_highlight, expose_frame): + Rename or move local decls. + * xdisp.c (BUILD_GLYPHLESS_GLYPH_STRING): Omit unused local var. + (produce_glyphless_glyph): Make a pointer "const" + since it might point to immutable storage. + (update_window_cursor): Now static, since it's not used elsewhere. + (SKIP_GLYPHS): Removed unused macro. + 2011-03-06 Michael Shields (tiny change) * window.c (Fnext_window): Doc fix. (Bug#5567) === modified file 'src/xdisp.c' --- src/xdisp.c 2011-02-23 20:41:43 +0000 +++ src/xdisp.c 2011-03-06 08:17:04 +0000 @@ -2477,9 +2477,9 @@ && WINDOWP (minibuf_selected_window) && w == XWINDOW (minibuf_selected_window)))) { - EMACS_INT charpos = marker_position (BVAR (current_buffer, mark)); - it->region_beg_charpos = min (PT, charpos); - it->region_end_charpos = max (PT, charpos); + EMACS_INT markpos = marker_position (BVAR (current_buffer, mark)); + it->region_beg_charpos = min (PT, markpos); + it->region_end_charpos = max (PT, markpos); } else it->region_beg_charpos = it->region_end_charpos = -1; @@ -3183,11 +3183,11 @@ safe_call1 (val, pos); else { - Lisp_Object globals, fn; + Lisp_Object fns, fn; struct gcpro gcpro1, gcpro2; - globals = Qnil; - GCPRO2 (val, globals); + fns = Qnil; + GCPRO2 (val, fns); for (; CONSP (val); val = XCDR (val)) { @@ -3200,11 +3200,11 @@ In a global value, t should not occur. If it does, we must ignore it to avoid an endless loop. */ - for (globals = Fdefault_value (Qfontification_functions); - CONSP (globals); - globals = XCDR (globals)) + for (fns = Fdefault_value (Qfontification_functions); + CONSP (fns); + fns = XCDR (fns)) { - fn = XCAR (globals); + fn = XCAR (fns); if (!EQ (fn, Qt)) safe_call1 (fn, pos); } @@ -3989,12 +3989,12 @@ else if (NUMBERP (it->font_height)) { /* Value is a multiple of the canonical char height. */ - struct face *face; + struct face *f; - face = FACE_FROM_ID (it->f, - lookup_basic_face (it->f, DEFAULT_FACE_ID)); + f = FACE_FROM_ID (it->f, + lookup_basic_face (it->f, DEFAULT_FACE_ID)); new_height = (XFLOATINT (it->font_height) - * XINT (face->lface[LFACE_HEIGHT_INDEX])); + * XINT (f->lface[LFACE_HEIGHT_INDEX])); } else { @@ -7982,7 +7982,7 @@ if (nlflag) { EMACS_INT this_bol, this_bol_byte, prev_bol, prev_bol_byte; - int dup; + int dups; insert_1 ("\n", 1, 1, 0, 0); scan_newline (Z, Z_BYTE, BEG, BEG_BYTE, -2, 0); @@ -7997,20 +7997,20 @@ prev_bol = PT; prev_bol_byte = PT_BYTE; - dup = message_log_check_duplicate (prev_bol, prev_bol_byte, - this_bol, this_bol_byte); - if (dup) + dups = message_log_check_duplicate (prev_bol, prev_bol_byte, + this_bol, this_bol_byte); + if (dups) { del_range_both (prev_bol, prev_bol_byte, this_bol, this_bol_byte, 0); - if (dup > 1) + if (dups > 1) { char dupstr[40]; int duplen; /* If you change this format, don't forget to also change message_log_check_duplicate. */ - sprintf (dupstr, " [%d times]", dup); + sprintf (dupstr, " [%d times]", dups); duplen = strlen (dupstr); TEMP_SET_PT_BOTH (Z - 1, Z_BYTE - 1); insert_1 (dupstr, duplen, 1, 0, 1); @@ -8340,20 +8340,20 @@ cmd_error, so this must be just an informative message; toss it. */ if (FRAME_MESSAGE_BUF (f)) { - Lisp_Object args[2], message; + Lisp_Object args[2], msg; struct gcpro gcpro1, gcpro2; args[0] = build_string (m); - args[1] = message = string; - GCPRO2 (args[0], message); + args[1] = msg = string; + GCPRO2 (args[0], msg); gcpro1.nvars = 2; - message = Fformat (2, args); + msg = Fformat (2, args); if (log) - message3 (message, SBYTES (message), STRING_MULTIBYTE (message)); + message3 (msg, SBYTES (msg), STRING_MULTIBYTE (msg)); else - message3_nolog (message, SBYTES (message), STRING_MULTIBYTE (message)); + message3_nolog (msg, SBYTES (msg), STRING_MULTIBYTE (msg)); UNGCPRO; @@ -11420,8 +11420,8 @@ { struct window *w = XWINDOW (selected_window); struct window *sw; - struct frame *f; - int pause; + struct frame *fr; + int pending; int must_finish = 0; struct text_pos tlbufpos, tlendpos; int number_of_visible_frames; @@ -11446,10 +11446,10 @@ /* Don't examine these until after testing Vinhibit_redisplay. When Emacs is shutting down, perhaps because its connection to X has dropped, we should not look at them at all. */ - f = XFRAME (w->frame); + fr = XFRAME (w->frame); sf = SELECTED_FRAME (); - if (!f->glyphs_initialized_p) + if (!fr->glyphs_initialized_p) return; #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) @@ -11491,7 +11491,7 @@ may need to run Elisp code (via prepare_menu_bars). */ select_frame_for_redisplay (old_frame); - pause = 0; + pending = 0; reconsider_clip_changes (w, current_buffer); last_escape_glyph_frame = NULL; last_escape_glyph_face_id = (1 << FACE_ID_BITS); @@ -11963,7 +11963,7 @@ /* Update the display. */ set_window_update_flags (XWINDOW (f->root_window), 1); - pause |= update_frame (f, 0, 0); + pending |= update_frame (f, 0, 0); f->updated_p = 1; } } @@ -11977,7 +11977,7 @@ select_frame_for_redisplay (old_frame); eassert (EQ (XFRAME (selected_frame)->selected_window, selected_window)); - if (!pause) + if (!pending) { /* Do the mark_window_display_accurate after all windows have been redisplayed because this call resets flags in buffers @@ -12026,7 +12026,7 @@ goto retry; XWINDOW (selected_window)->must_be_updated_p = 1; - pause = update_frame (sf, 0, 0); + pending = update_frame (sf, 0, 0); } /* We may have called echo_area_display at the top of this @@ -12040,15 +12040,15 @@ if (mini_frame != sf && FRAME_WINDOW_P (mini_frame)) { XWINDOW (mini_window)->must_be_updated_p = 1; - pause |= update_frame (mini_frame, 0, 0); - if (!pause && hscroll_windows (mini_window)) + pending |= update_frame (mini_frame, 0, 0); + if (!pending && hscroll_windows (mini_window)) goto retry; } } /* If display was paused because of pending input, make sure we do a thorough update the next time. */ - if (pause) + if (pending) { /* Prevent the optimization at the beginning of redisplay_internal that tries a single-line update of the @@ -12098,7 +12098,7 @@ redisplay constructing glyphs, so simply exposing a frame won't display anything in this case. So, we have to display these frames here explicitly. */ - if (!pause) + if (!pending) { Lisp_Object tail, frame; int new_count = 0; @@ -12126,7 +12126,7 @@ /* If we just did a pending size change, or have additional visible frames, or selected_window changed, redisplay again. */ - if ((windows_or_buffers_changed && !pause) + if ((windows_or_buffers_changed && !pending) || (WINDOWP (selected_window) && (w = XWINDOW (selected_window)) != sw)) goto retry; @@ -12382,18 +12382,6 @@ } -/* Increment GLYPH until it reaches END or CONDITION fails while - adding (GLYPH)->pixel_width to X. */ - -#define SKIP_GLYPHS(glyph, end, x, condition) \ - do \ - { \ - (x) += (glyph)->pixel_width; \ - ++(glyph); \ - } \ - while ((glyph) < (end) && (condition)) - - /* Set cursor position of W. PT is assumed to be displayed in ROW. DELTA and DELTA_BYTES are the numbers of characters and bytes by which positions recorded in ROW differ from current buffer @@ -13719,7 +13707,6 @@ int buffer_unchanged_p = 0; int temp_scroll_step = 0; int count = SPECPDL_INDEX (); - int rc; int centering_position = -1; int last_line_misfit = 0; EMACS_INT beg_unchanged, end_unchanged; @@ -14032,12 +14019,15 @@ /* Handle case where text has not changed, only point, and it has not moved off the frame, and we are not retrying after hscroll. (current_matrix_up_to_date_p is nonzero when retrying.) */ - if (current_matrix_up_to_date_p - && (rc = try_cursor_movement (window, startp, &temp_scroll_step), - rc != CURSOR_MOVEMENT_CANNOT_BE_USED)) + if (current_matrix_up_to_date_p) { + int rc = try_cursor_movement (window, startp, &temp_scroll_step); + switch (rc) { + case CURSOR_MOVEMENT_CANNOT_BE_USED: + break; + case CURSOR_MOVEMENT_SUCCESS: used_current_matrix_p = 1; goto done; @@ -14597,7 +14587,7 @@ try_window_reusing_current_matrix (struct window *w) { struct frame *f = XFRAME (w->frame); - struct glyph_row *row, *bottom_row; + struct glyph_row *bottom_row; struct it it; struct run run; struct text_pos start, new_start; @@ -14706,6 +14696,8 @@ have at least one reusable row. */ if (it.current_y < it.last_visible_y) { + struct glyph_row *row; + /* IT.vpos always starts from 0; it counts text lines. */ nrows_scrolled = it.vpos - (start_row - MATRIX_FIRST_TEXT_ROW (w->current_matrix)); @@ -15491,41 +15483,41 @@ || (last_changed_charpos < CHARPOS (start) - 1 && FETCH_BYTE (BYTEPOS (start) - 1) == '\n'))) { - EMACS_INT Z_old, delta, Z_BYTE_old, delta_bytes; + EMACS_INT Z_old, Z_delta, Z_BYTE_old, Z_delta_bytes; struct glyph_row *r0; /* Compute how many chars/bytes have been added to or removed from the buffer. */ Z_old = MATRIX_ROW_END_CHARPOS (row) + XFASTINT (w->window_end_pos); Z_BYTE_old = MATRIX_ROW_END_BYTEPOS (row) + w->window_end_bytepos; - delta = Z - Z_old; - delta_bytes = Z_BYTE - Z_BYTE_old; + Z_delta = Z - Z_old; + Z_delta_bytes = Z_BYTE - Z_BYTE_old; /* Give up if PT is not in the window. Note that it already has been checked at the start of try_window_id that PT is not in front of the window start. */ - if (PT >= MATRIX_ROW_END_CHARPOS (row) + delta) + if (PT >= MATRIX_ROW_END_CHARPOS (row) + Z_delta) GIVE_UP (13); /* If window start is unchanged, we can reuse the whole matrix as is, after adjusting glyph positions. No need to compute the window end again, since its offset from Z hasn't changed. */ r0 = MATRIX_FIRST_TEXT_ROW (current_matrix); - if (CHARPOS (start) == MATRIX_ROW_START_CHARPOS (r0) + delta - && BYTEPOS (start) == MATRIX_ROW_START_BYTEPOS (r0) + delta_bytes + if (CHARPOS (start) == MATRIX_ROW_START_CHARPOS (r0) + Z_delta + && BYTEPOS (start) == MATRIX_ROW_START_BYTEPOS (r0) + Z_delta_bytes /* PT must not be in a partially visible line. */ - && !(PT >= MATRIX_ROW_START_CHARPOS (row) + delta + && !(PT >= MATRIX_ROW_START_CHARPOS (row) + Z_delta && MATRIX_ROW_BOTTOM_Y (row) > window_text_bottom_y (w))) { /* Adjust positions in the glyph matrix. */ - if (delta || delta_bytes) + if (Z_delta || Z_delta_bytes) { struct glyph_row *r1 = MATRIX_BOTTOM_TEXT_ROW (current_matrix, w); increment_matrix_positions (w->current_matrix, MATRIX_ROW_VPOS (r0, current_matrix), MATRIX_ROW_VPOS (r1, current_matrix), - delta, delta_bytes); + Z_delta, Z_delta_bytes); } /* Set the cursor. */ @@ -15841,9 +15833,9 @@ { /* Terminal frame. In this case, dvpos gives the number of lines to scroll by; dvpos < 0 means scroll up. */ - int first_unchanged_at_end_vpos + int from_vpos = MATRIX_ROW_VPOS (first_unchanged_at_end_row, w->current_matrix); - int from = WINDOW_TOP_EDGE_LINE (w) + first_unchanged_at_end_vpos; + int from = WINDOW_TOP_EDGE_LINE (w) + from_vpos; int end = (WINDOW_TOP_EDGE_LINE (w) + (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0) + window_internal_height (w)); @@ -16574,7 +16566,6 @@ compute_line_metrics (struct it *it) { struct glyph_row *row = it->glyph_row; - int area, i; if (FRAME_WINDOW_P (it->f)) { @@ -16639,14 +16630,17 @@ } /* Compute a hash code for this row. */ - row->hash = 0; - for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area) - for (i = 0; i < row->used[area]; ++i) - row->hash = ((((row->hash << 4) + (row->hash >> 24)) & 0x0fffffff) - + row->glyphs[area][i].u.val - + row->glyphs[area][i].face_id - + row->glyphs[area][i].padding_p - + (row->glyphs[area][i].type << 2)); + { + int area, i; + row->hash = 0; + for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area) + for (i = 0; i < row->used[area]; ++i) + row->hash = ((((row->hash << 4) + (row->hash >> 24)) & 0x0fffffff) + + row->glyphs[area][i].u.val + + row->glyphs[area][i].face_id + + row->glyphs[area][i].padding_p + + (row->glyphs[area][i].type << 2)); + } it->max_ascent = it->max_descent = 0; it->max_phys_ascent = it->max_phys_descent = 0; @@ -16979,7 +16973,7 @@ static int cursor_row_p (struct window *w, struct glyph_row *row) { - int cursor_row_p = 1; + int result = 1; if (PT == CHARPOS (row->end.pos)) { @@ -16992,7 +16986,7 @@ if (CHARPOS (row->end.string_pos) >= 0) { if (row->continued_p) - cursor_row_p = 1; + result = 1; else { /* Check for `display' property. */ @@ -17000,14 +16994,14 @@ struct glyph *end = beg + row->used[TEXT_AREA] - 1; struct glyph *glyph; - cursor_row_p = 0; + result = 0; for (glyph = end; glyph >= beg; --glyph) if (STRINGP (glyph->object)) { Lisp_Object prop = Fget_char_property (make_number (PT), Qdisplay, Qnil); - cursor_row_p = + result = (!NILP (prop) && display_prop_string_p (prop, glyph->object)); break; @@ -17021,23 +17015,23 @@ That's because CHARPOS (ROW->end.pos) would equal PT if PT is before the character. */ if (!row->ends_in_ellipsis_p) - cursor_row_p = row->continued_p; + result = row->continued_p; else /* If the row ends in an ellipsis, then CHARPOS (ROW->end.pos) will equal point after the invisible text. We want that position to be displayed after the ellipsis. */ - cursor_row_p = 0; + result = 0; } /* If the row ends at ZV, display the cursor at the end of that row instead of at the start of the row below. */ else if (row->ends_at_zv_p) - cursor_row_p = 1; + result = 1; else - cursor_row_p = 0; + result = 0; } - return cursor_row_p; + return result; } @@ -17345,7 +17339,7 @@ while (1) { int n_glyphs_before, hpos_before, x_before; - int x, i, nglyphs; + int x, nglyphs; int ascent = 0, descent = 0, phys_ascent = 0, phys_descent = 0; /* Retrieve the next thing to display. Value is zero if end of @@ -17470,7 +17464,7 @@ } else { - int new_x; + int i, new_x; struct glyph *glyph; for (i = 0; i < nglyphs; ++i, x = new_x) @@ -19924,16 +19918,16 @@ { if (!FRAME_WINDOW_P (it->f)) { - int i, n; + int ii, n; if (it->current_x > it->last_visible_x) { - for (i = row->used[TEXT_AREA] - 1; i > 0; --i) - if (!CHAR_GLYPH_PADDING_P (row->glyphs[TEXT_AREA][i])) + for (ii = row->used[TEXT_AREA] - 1; ii > 0; --ii) + if (!CHAR_GLYPH_PADDING_P (row->glyphs[TEXT_AREA][ii])) break; - for (n = row->used[TEXT_AREA]; i < n; ++i) + for (n = row->used[TEXT_AREA]; ii < n; ++ii) { - row->used[TEXT_AREA] = i; + row->used[TEXT_AREA] = ii; produce_special_glyphs (it, IT_TRUNCATION); } } @@ -21165,7 +21159,6 @@ do \ { \ int face_id; \ - XChar2b *char2b; \ \ face_id = (row)->glyphs[area][START].face_id; \ \ @@ -22262,7 +22255,8 @@ } else { - char buf[7], *str; + char buf[7]; + const char *str; unsigned int code[6]; int upper_len; int ascent, descent; @@ -23783,7 +23777,7 @@ /* Switch the display of W's cursor on or off, according to the value of ON. */ -void +static void update_window_cursor (struct window *w, int on) { /* Don't update cursor in windows whose frame is in the process @@ -24197,7 +24191,7 @@ for the overlay or run of text properties specifying the mouse face. BEFORE_STRING and AFTER_STRING, if non-nil, are a before-string and after-string that must also be highlighted. - DISPLAY_STRING, if non-nil, is a display string that may cover some + COVER_STRING, if non-nil, is a display string that may cover some or all of the highlighted text. */ static void @@ -24208,7 +24202,7 @@ EMACS_INT end_charpos, Lisp_Object before_string, Lisp_Object after_string, - Lisp_Object display_string) + Lisp_Object cover_string) { struct window *w = XWINDOW (window); struct glyph_row *first = MATRIX_FIRST_TEXT_ROW (w->current_matrix); @@ -24217,7 +24211,7 @@ EMACS_INT ignore, pos; int x; - xassert (NILP (display_string) || STRINGP (display_string)); + xassert (NILP (cover_string) || STRINGP (cover_string)); xassert (NILP (before_string) || STRINGP (before_string)); xassert (NILP (after_string) || STRINGP (after_string)); @@ -24227,7 +24221,7 @@ r1 = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos)); /* If the before-string or display-string contains newlines, rows_from_pos_range skips to its last row. Move back. */ - if (!NILP (before_string) || !NILP (display_string)) + if (!NILP (before_string) || !NILP (cover_string)) { struct glyph_row *prev; while ((prev = r1 - 1, prev >= first) @@ -24239,7 +24233,7 @@ while (--glyph >= beg && INTEGERP (glyph->object)); if (glyph < beg || !(EQ (glyph->object, before_string) - || EQ (glyph->object, display_string))) + || EQ (glyph->object, cover_string))) break; r1 = prev; } @@ -24282,7 +24276,7 @@ hlinfo->mouse_face_end_row = MATRIX_ROW_VPOS (r2, w->current_matrix); /* For a bidi-reordered row, the positions of BEFORE_STRING, - AFTER_STRING, DISPLAY_STRING, START_CHARPOS, and END_CHARPOS + AFTER_STRING, COVER_STRING, START_CHARPOS, and END_CHARPOS could be anywhere in the row and in any order. The strategy below is to find the leftmost and the rightmost glyph that belongs to either of these 3 strings, or whose position is @@ -24308,11 +24302,11 @@ x += glyph->pixel_width; /* Scan the glyph row, looking for BEFORE_STRING, AFTER_STRING, - or DISPLAY_STRING, and the first glyph from buffer whose + or COVER_STRING, and the first glyph from buffer whose position is between START_CHARPOS and END_CHARPOS. */ for (; glyph < end && !INTEGERP (glyph->object) - && !EQ (glyph->object, display_string) + && !EQ (glyph->object, cover_string) && !(BUFFERP (glyph->object) && (glyph->charpos >= start_charpos && glyph->charpos < end_charpos)); @@ -24359,11 +24353,11 @@ ; /* Scan the glyph row, looking for BEFORE_STRING, AFTER_STRING, - or DISPLAY_STRING, and the first glyph from buffer whose + or COVER_STRING, and the first glyph from buffer whose position is between START_CHARPOS and END_CHARPOS. */ for (; glyph > end && !INTEGERP (glyph->object) - && !EQ (glyph->object, display_string) + && !EQ (glyph->object, cover_string) && !(BUFFERP (glyph->object) && (glyph->charpos >= start_charpos && glyph->charpos < end_charpos)); @@ -24424,12 +24418,12 @@ --end; /* Scan the rest of the glyph row from the end, looking for the first glyph that comes from BEFORE_STRING, AFTER_STRING, or - DISPLAY_STRING, or whose position is between START_CHARPOS + COVER_STRING, or whose position is between START_CHARPOS and END_CHARPOS */ for (--end; end > glyph && !INTEGERP (end->object) - && !EQ (end->object, display_string) + && !EQ (end->object, cover_string) && !(BUFFERP (end->object) && (end->charpos >= start_charpos && end->charpos < end_charpos)); @@ -24474,12 +24468,12 @@ } /* Scan the rest of the glyph row from the end, looking for the first glyph that comes from BEFORE_STRING, AFTER_STRING, or - DISPLAY_STRING, or whose position is between START_CHARPOS + COVER_STRING, or whose position is between START_CHARPOS and END_CHARPOS */ for ( ; end < glyph && !INTEGERP (end->object) - && !EQ (end->object, display_string) + && !EQ (end->object, cover_string) && !(BUFFERP (end->object) && (end->charpos >= start_charpos && end->charpos < end_charpos)); @@ -25285,7 +25279,7 @@ EMACS_INT pos; struct glyph *glyph; Lisp_Object object; - Lisp_Object mouse_face = Qnil, overlay = Qnil, position; + Lisp_Object mouse_face = Qnil, position; Lisp_Object *overlay_vec = NULL; int noverlays; struct buffer *obuf; @@ -25418,7 +25412,7 @@ && mouse_face_overlay_overlaps (hlinfo->mouse_face_overlay))) { /* Find the highest priority overlay with a mouse-face. */ - overlay = Qnil; + Lisp_Object overlay = Qnil; for (i = noverlays - 1; i >= 0 && NILP (overlay); --i) { mouse_face = Foverlay_get (overlay_vec[i], Qmouse_face); @@ -25446,19 +25440,19 @@ { /* The mouse-highlighting comes from a display string with a mouse-face. */ - Lisp_Object b, e; + Lisp_Object s, e; EMACS_INT ignore; - b = Fprevious_single_property_change + s = Fprevious_single_property_change (make_number (pos + 1), Qmouse_face, object, Qnil); e = Fnext_single_property_change (position, Qmouse_face, object, Qnil); - if (NILP (b)) - b = make_number (0); + if (NILP (s)) + s = make_number (0); if (NILP (e)) e = make_number (SCHARS (object) - 1); mouse_face_from_string_pos (w, hlinfo, object, - XINT (b), XINT (e)); + XINT (s), XINT (e)); hlinfo->mouse_face_past_end = 0; hlinfo->mouse_face_window = window; hlinfo->mouse_face_face_id @@ -25471,7 +25465,7 @@ { /* The mouse-highlighting, if any, comes from an overlay or text property in the buffer. */ - Lisp_Object buffer, display_string; + Lisp_Object buffer, cover_string; if (STRINGP (object)) { @@ -25485,13 +25479,13 @@ mouse_face = get_char_property_and_overlay (make_number (pos), Qmouse_face, w->buffer, &overlay); buffer = w->buffer; - display_string = object; + cover_string = object; } } else { buffer = object; - display_string = Qnil; + cover_string = Qnil; } if (!NILP (mouse_face)) @@ -25543,7 +25537,7 @@ XFASTINT (before), XFASTINT (after), before_string, after_string, - display_string); + cover_string); cursor = No_Cursor; } } @@ -25572,16 +25566,16 @@ } else { - Lisp_Object object = glyph->object; + Lisp_Object obj = glyph->object; EMACS_INT charpos = glyph->charpos; /* Try text properties. */ - if (STRINGP (object) + if (STRINGP (obj) && charpos >= 0 - && charpos < SCHARS (object)) + && charpos < SCHARS (obj)) { help = Fget_text_property (make_number (charpos), - Qhelp_echo, object); + Qhelp_echo, obj); if (NILP (help)) { /* If the string itself doesn't specify a help-echo, @@ -25589,30 +25583,30 @@ struct glyph_row *r = MATRIX_ROW (w->current_matrix, vpos); EMACS_INT start = MATRIX_ROW_START_CHARPOS (r); - EMACS_INT pos = string_buffer_position (w, object, start); - if (pos > 0) + EMACS_INT p = string_buffer_position (w, obj, start); + if (p > 0) { - help = Fget_char_property (make_number (pos), + help = Fget_char_property (make_number (p), Qhelp_echo, w->buffer); if (!NILP (help)) { - charpos = pos; - object = w->buffer; + charpos = p; + obj = w->buffer; } } } } - else if (BUFFERP (object) + else if (BUFFERP (obj) && charpos >= BEGV && charpos < ZV) help = Fget_text_property (make_number (charpos), Qhelp_echo, - object); + obj); if (!NILP (help)) { help_echo_string = help; help_echo_window = window; - help_echo_object = object; + help_echo_object = obj; help_echo_pos = charpos; } } @@ -25628,16 +25622,16 @@ if (NILP (pointer)) { - Lisp_Object object = glyph->object; + Lisp_Object obj = glyph->object; EMACS_INT charpos = glyph->charpos; /* Try text properties. */ - if (STRINGP (object) + if (STRINGP (obj) && charpos >= 0 - && charpos < SCHARS (object)) + && charpos < SCHARS (obj)) { pointer = Fget_text_property (make_number (charpos), - Qpointer, object); + Qpointer, obj); if (NILP (pointer)) { /* If the string itself doesn't specify a pointer, @@ -25645,18 +25639,17 @@ struct glyph_row *r = MATRIX_ROW (w->current_matrix, vpos); EMACS_INT start = MATRIX_ROW_START_CHARPOS (r); - EMACS_INT pos = string_buffer_position (w, object, - start); - if (pos > 0) - pointer = Fget_char_property (make_number (pos), + EMACS_INT p = string_buffer_position (w, obj, start); + if (p > 0) + pointer = Fget_char_property (make_number (p), Qpointer, w->buffer); } } - else if (BUFFERP (object) + else if (BUFFERP (obj) && charpos >= BEGV && charpos < ZV) pointer = Fget_text_property (make_number (charpos), - Qpointer, object); + Qpointer, obj); } } #endif /* HAVE_WINDOW_SYSTEM */ @@ -26177,10 +26170,10 @@ Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); if (f == hlinfo->mouse_face_mouse_frame) { - int x = hlinfo->mouse_face_mouse_x; - int y = hlinfo->mouse_face_mouse_y; + int mouse_x = hlinfo->mouse_face_mouse_x; + int mouse_y = hlinfo->mouse_face_mouse_y; clear_mouse_face (hlinfo); - note_mouse_highlight (f, x, y); + note_mouse_highlight (f, mouse_x, mouse_y); } } } ------------------------------------------------------------ revno: 103557 committer: Chong Yidong branch nick: trunk timestamp: Sun 2011-03-06 00:34:35 -0500 message: Add package.texi to doc/lispref/Makefile.in. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2011-03-05 20:45:09 +0000 +++ doc/lispref/ChangeLog 2011-03-06 05:34:35 +0000 @@ -1,3 +1,7 @@ +2011-03-06 Chong Yidong + + * Makefile.in (srcs): Add package.texi. + 2011-03-05 Chong Yidong * processes.texi (Synchronous Processes): Minor clarification === modified file 'doc/lispref/Makefile.in' --- doc/lispref/Makefile.in 2011-01-26 08:36:39 +0000 +++ doc/lispref/Makefile.in 2011-03-06 05:34:35 +0000 @@ -80,6 +80,7 @@ $(srcdir)/numbers.texi \ $(srcdir)/objects.texi \ $(srcdir)/os.texi \ + $(srcdir)/package.texi \ $(srcdir)/positions.texi \ $(srcdir)/processes.texi \ $(srcdir)/searching.texi \ ------------------------------------------------------------ Use --include-merges or -n0 to see merged revisions.