Using saved parent location: http://bzr.savannah.gnu.org/r/emacs/trunk/ Now on revision 104508. ------------------------------------------------------------ revno: 104508 fixes bug(s): http://debbugs.gnu.org/8800 committer: Paul Eggert branch nick: trunk timestamp: Sun 2011-06-05 21:54:23 -0700 message: * alloc.c (memory_full) [SYSTEM_MALLOC]: Port to MacO). diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-06-05 22:46:26 +0000 +++ src/ChangeLog 2011-06-06 04:54:23 +0000 @@ -1,3 +1,11 @@ +2011-06-06 Paul Eggert + + * alloc.c (memory_full) [SYSTEM_MALLOC]: Port to MacOS (Bug#8800). + Do not assume that spare memory exists; that assumption is valid + only if SYSTEM_MALLOC. + (LARGE_REQUEST): New macro, so that the issue of large requests + is separated from the issue of spare memory. + 2011-06-05 Andreas Schwab * editfns.c (Fformat): Correctly handle zero flag with hexadecimal === modified file 'src/alloc.c' --- src/alloc.c 2011-06-02 08:35:28 +0000 +++ src/alloc.c 2011-06-06 04:54:23 +0000 @@ -196,6 +196,12 @@ #define SPARE_MEMORY (1 << 14) #endif +#ifdef SYSTEM_MALLOC +# define LARGE_REQUEST (1 << 14) +#else +# define LARGE_REQUEST SPARE_MEMORY +#endif + /* Number of extra blocks malloc should get when it needs more core. */ static int malloc_hysteresis; @@ -3283,15 +3289,12 @@ { /* Do not go into hysterics merely because a large request failed. */ int enough_free_memory = 0; - if (SPARE_MEMORY < nbytes) + if (LARGE_REQUEST < nbytes) { - void *p = malloc (SPARE_MEMORY); + void *p = malloc (LARGE_REQUEST); if (p) { - if (spare_memory[0]) - free (p); - else - spare_memory[0] = p; + free (p); enough_free_memory = 1; } } ------------------------------------------------------------ revno: 104507 committer: Andreas Schwab branch nick: emacs timestamp: Mon 2011-06-06 01:20:16 +0200 message: * lisp/comint.el (comint-dynamic-complete-as-filename) (comint-dynamic-complete-filename): Correctly call completion-in-region. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-05 19:39:17 +0000 +++ lisp/ChangeLog 2011-06-05 23:20:16 +0000 @@ -1,3 +1,9 @@ +2011-06-05 Andreas Schwab + + * comint.el (comint-dynamic-complete-as-filename) + (comint-dynamic-complete-filename): Correctly call + completion-in-region. + 2011-06-05 Deniz Dogan * net/rcirc.el (rcirc-prompt-for-encryption): Fix bug introduced === modified file 'lisp/comint.el' --- lisp/comint.el 2011-05-24 02:45:50 +0000 +++ lisp/comint.el 2011-06-05 23:20:16 +0000 @@ -3035,7 +3035,8 @@ (when (comint--match-partial-filename) (unless (window-minibuffer-p (selected-window)) (message "Completing file name...")) - (apply #'completion-in-region (comint--complete-file-name-data)))) + (let ((data (comint--complete-file-name-data))) + (completion-in-region (nth 0 data) (nth 1 data) (nth 2 data))))) (defun comint-filename-completion () "Return completion data for filename at point, if any." @@ -3152,7 +3153,8 @@ (defun comint-dynamic-complete-as-filename () "Dynamically complete at point as a filename. See `comint-dynamic-complete-filename'. Returns t if successful." - (apply #'completion-in-region (comint--complete-file-name-data))) + (let ((data (comint--complete-file-name-data))) + (completion-in-region (nth 0 data) (nth 1 data) (nth 2 data)))) (make-obsolete 'comint-dynamic-complete-as-filename 'comint-filename-completion "24.1") ------------------------------------------------------------ revno: 104506 committer: Andreas Schwab branch nick: emacs timestamp: Mon 2011-06-06 00:46:26 +0200 message: Fixes: debbugs:8806 * src/editfns.c (Fformat): Correctly handle zero flag with hexadecimal format. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-06-05 22:20:42 +0000 +++ src/ChangeLog 2011-06-05 22:46:26 +0000 @@ -1,5 +1,8 @@ 2011-06-05 Andreas Schwab + * editfns.c (Fformat): Correctly handle zero flag with hexadecimal + format. (Bug#8806) + * gtkutil.c (xg_get_default_scrollbar_width): Avoid warning. * xfns.c (x_set_scroll_bar_default_width): Move declarations === modified file 'src/editfns.c' --- src/editfns.c 2011-05-30 16:47:35 +0000 +++ src/editfns.c 2011-06-05 22:46:26 +0000 @@ -4083,7 +4083,10 @@ int exponent_bytes = 0; int signedp = src0 == '-' || src0 == '+' || src0 == ' '; int significand_bytes; - if (zero_flag && '0' <= src[signedp] && src[signedp] <= '9') + if (zero_flag + && ((src[signedp] >= '0' && src[signedp] <= '9') + || (src[signedp] >= 'a' && src[signedp] <= 'f') + || (src[signedp] >= 'A' && src[signedp] <= 'F'))) { leading_zeros += padding; padding = 0; ------------------------------------------------------------ revno: 104505 committer: Andreas Schwab branch nick: emacs timestamp: Mon 2011-06-06 00:20:42 +0200 message: * src/gtkutil.c (xg_get_default_scrollbar_width): Avoid warning. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-06-05 22:20:42 +0000 +++ src/ChangeLog 2011-06-05 22:20:42 +0000 @@ -1,5 +1,7 @@ 2011-06-05 Andreas Schwab + * gtkutil.c (xg_get_default_scrollbar_width): Avoid warning. + * xfns.c (x_set_scroll_bar_default_width): Move declarations before statements. === modified file 'src/gtkutil.c' --- src/gtkutil.c 2011-06-05 19:04:51 +0000 +++ src/gtkutil.c 2011-06-05 22:20:42 +0000 @@ -3329,11 +3329,15 @@ int xg_get_default_scrollbar_width (FRAME_PTR f) { - GtkWidget *wscroll = gtk_vscrollbar_new (gtk_adjustment_new (XG_SB_MIN, - XG_SB_MIN, - XG_SB_MAX, - 0.1, 0.1, 0.1)); +#ifdef HAVE_GTK3 + GtkAdjustment *vadj; +#else + GtkObject *vadj; +#endif + GtkWidget *wscroll; int w = 0, b = 0; + vadj = gtk_adjustment_new (XG_SB_MIN, XG_SB_MIN, XG_SB_MAX, 0.1, 0.1, 0.1); + wscroll = gtk_vscrollbar_new (GTK_ADJUSTMENT (vadj)); gtk_widget_style_get (wscroll, "slider-width", &w, "trough-border", &b, NULL); gtk_widget_destroy (wscroll); w += 2*b; ------------------------------------------------------------ revno: 104504 committer: Andreas Schwab branch nick: emacs timestamp: Mon 2011-06-06 00:20:42 +0200 message: * src/xfns.c (x_set_scroll_bar_default_width): Move declarations before statements. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-06-05 19:04:51 +0000 +++ src/ChangeLog 2011-06-05 22:20:42 +0000 @@ -1,3 +1,8 @@ +2011-06-05 Andreas Schwab + + * xfns.c (x_set_scroll_bar_default_width): Move declarations + before statements. + 2011-06-05 Jan Djärv * gtkutil.c (xg_get_default_scrollbar_width): New function. === modified file 'src/xfns.c' --- src/xfns.c 2011-06-05 19:04:51 +0000 +++ src/xfns.c 2011-06-05 22:20:42 +0000 @@ -1696,12 +1696,13 @@ { int wid = FRAME_COLUMN_WIDTH (f); int minw = 16; + int width; #ifdef USE_TOOLKIT_SCROLL_BARS #ifdef USE_GTK minw = xg_get_default_scrollbar_width (f); #endif /* A minimum width of 14 doesn't look good for toolkit scroll bars. */ - int width = minw + 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM; + width = minw + 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM; FRAME_CONFIG_SCROLL_BAR_COLS (f) = (width + wid - 1) / wid; FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = width; #else ------------------------------------------------------------ revno: 104503 committer: Deniz Dogan branch nick: emacs-trunk timestamp: Sun 2011-06-05 21:39:17 +0200 message: * lisp/net/rcirc.el (rcirc-prompt-for-encryption): Fix bug introduced in last change. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-05 19:03:28 +0000 +++ lisp/ChangeLog 2011-06-05 19:39:17 +0000 @@ -1,5 +1,10 @@ 2011-06-05 Deniz Dogan + * net/rcirc.el (rcirc-prompt-for-encryption): Fix bug introduced + in last change. + +2011-06-05 Deniz Dogan + * net/rcirc.el (rcirc-prompt-for-encryption): New function. (rcirc): Use it to prompt for encryption. === modified file 'lisp/net/rcirc.el' --- lisp/net/rcirc.el 2011-06-05 19:03:28 +0000 +++ lisp/net/rcirc.el 2011-06-05 19:39:17 +0000 @@ -594,10 +594,10 @@ (let ((msg "Encryption (default %s): ") (choices '("plain" "tls")) (default (or (plist-get server-plist :encryption) - "plain"))) + 'plain))) (intern (completing-read (format msg default) - choices nil t "" nil default)))) + choices nil t nil nil (symbol-name default))))) (defun rcirc-keepalive () "Send keep alive pings to active rcirc processes. ------------------------------------------------------------ revno: 104502 fixes bug(s): http://debbugs.gnu.org/8505 committer: Jan D. branch nick: trunk timestamp: Sun 2011-06-05 21:04:51 +0200 message: Handle scroll bar width larger than 16 for GTK3. * gtkutil.c (xg_get_default_scrollbar_width): New function. * gtkutil.h: Declare xg_get_default_scrollbar_width. * xfns.c (x_set_scroll_bar_default_width): If USE_GTK, get min width by calling x_set_scroll_bar_default_width. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-06-05 00:14:08 +0000 +++ src/ChangeLog 2011-06-05 19:04:51 +0000 @@ -1,3 +1,12 @@ +2011-06-05 Jan Djärv + + * gtkutil.c (xg_get_default_scrollbar_width): New function. + + * gtkutil.h: Declare xg_get_default_scrollbar_width. + + * xfns.c (x_set_scroll_bar_default_width): If USE_GTK, get + min width by calling x_set_scroll_bar_default_width (Bug#8505). + 2011-06-05 Juanma Barranquero * xdisp.c (single_display_spec_intangible_p): Remove declaration. === modified file 'src/gtkutil.c' --- src/gtkutil.c 2011-04-29 17:56:27 +0000 +++ src/gtkutil.c 2011-06-05 19:04:51 +0000 @@ -3326,6 +3326,21 @@ return 0; } +int +xg_get_default_scrollbar_width (FRAME_PTR f) +{ + GtkWidget *wscroll = gtk_vscrollbar_new (gtk_adjustment_new (XG_SB_MIN, + XG_SB_MIN, + XG_SB_MAX, + 0.1, 0.1, 0.1)); + int w = 0, b = 0; + gtk_widget_style_get (wscroll, "slider-width", &w, "trough-border", &b, NULL); + gtk_widget_destroy (wscroll); + w += 2*b; + if (w < 16) w = 16; + return w; +} + /* Return the scrollbar id for X Window WID on display DPY. Return -1 if WID not in id_to_widget. */ === modified file 'src/gtkutil.h' --- src/gtkutil.h 2011-01-26 08:36:39 +0000 +++ src/gtkutil.h 2011-06-05 19:04:51 +0000 @@ -135,6 +135,7 @@ int position, int whole); extern int xg_event_is_for_scrollbar (FRAME_PTR f, XEvent *event); +extern int xg_get_default_scrollbar_width (FRAME_PTR f); extern void update_frame_tool_bar (FRAME_PTR f); extern void free_frame_tool_bar (FRAME_PTR f); === modified file 'src/xfns.c' --- src/xfns.c 2011-04-19 06:34:43 +0000 +++ src/xfns.c 2011-06-05 19:04:51 +0000 @@ -1695,10 +1695,13 @@ x_set_scroll_bar_default_width (struct frame *f) { int wid = FRAME_COLUMN_WIDTH (f); - + int minw = 16; #ifdef USE_TOOLKIT_SCROLL_BARS +#ifdef USE_GTK + minw = xg_get_default_scrollbar_width (f); +#endif /* A minimum width of 14 doesn't look good for toolkit scroll bars. */ - int width = 16 + 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM; + int width = minw + 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM; FRAME_CONFIG_SCROLL_BAR_COLS (f) = (width + wid - 1) / wid; FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = width; #else ------------------------------------------------------------ revno: 104501 committer: Deniz Dogan branch nick: emacs-trunk timestamp: Sun 2011-06-05 21:03:28 +0200 message: * lisp/net/rcirc.el (rcirc-prompt-for-encryption): New function. (rcirc): Use it to prompt for encryption. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-05 05:46:43 +0000 +++ lisp/ChangeLog 2011-06-05 19:03:28 +0000 @@ -1,3 +1,8 @@ +2011-06-05 Deniz Dogan + + * net/rcirc.el (rcirc-prompt-for-encryption): New function. + (rcirc): Use it to prompt for encryption. + 2011-06-05 Roland Winkler * textmodes/bibtex.el (bibtex-search-buffer): New variable. === modified file 'lisp/net/rcirc.el' --- lisp/net/rcirc.el 2011-06-01 08:10:42 +0000 +++ lisp/net/rcirc.el 2011-06-05 19:03:28 +0000 @@ -455,15 +455,7 @@ :channels) " ")) "[, ]+" t)) - (encryption - (intern (completing-read "Encryption (default plain): " - '("plain" "tls") - nil t - (let ((choice (plist-get server-plist - :encryption))) - (when choice - (symbol-name choice))) - nil "plain")))) + (encryption (rcirc-prompt-for-encryption server-plist))) (rcirc-connect server port nick user-name rcirc-default-full-name channels password encryption)) @@ -596,6 +588,17 @@ (time-to-seconds (current-time)) (float-time))) +(defun rcirc-prompt-for-encryption (server-plist) + "Prompt the user for the encryption method to use. +SERVER-PLIST is the property list for the server." + (let ((msg "Encryption (default %s): ") + (choices '("plain" "tls")) + (default (or (plist-get server-plist :encryption) + "plain"))) + (intern + (completing-read (format msg default) + choices nil t "" nil default)))) + (defun rcirc-keepalive () "Send keep alive pings to active rcirc processes. Kill processes that have not received a server message since the ------------------------------------------------------------ revno: 104500 committer: Roland Winkler branch nick: trunk timestamp: Sun 2011-06-05 00:46:43 -0500 message: lisp/textmodes/bibtex.el: new command bibtex-search-entries diff: === modified file 'etc/NEWS' --- etc/NEWS 2011-06-05 04:47:45 +0000 +++ etc/NEWS 2011-06-05 05:46:43 +0000 @@ -438,6 +438,8 @@ ** BibTeX mode +*** New command `bibtex-search-entries' bound to C-c C-a. + *** New `bibtex-entry-format' option `sort-fields', disabled by default. *** New variable `bibtex-search-entry-globally'. === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-05 04:58:39 +0000 +++ lisp/ChangeLog 2011-06-05 05:46:43 +0000 @@ -1,5 +1,11 @@ 2011-06-05 Roland Winkler + * textmodes/bibtex.el (bibtex-search-buffer): New variable. + (bibtex-search-entries): New command bound to C-c C-a. + (bibtex-display-entries): New function. + +2011-06-05 Roland Winkler + * textmodes/bibtex.el (bibtex-generate-url-list): Fix docstring. (bibtex-insert-kill): After yanking insert newline if necessary. (bibtex-initialize): Call bibtex-string-files-init only once. === modified file 'lisp/textmodes/bibtex.el' --- lisp/textmodes/bibtex.el 2011-06-05 04:58:39 +0000 +++ lisp/textmodes/bibtex.el 2011-06-05 05:46:43 +0000 @@ -968,6 +968,11 @@ :group 'bibtex :type 'boolean) +(defcustom bibtex-search-buffer "*BibTeX Search*" + "Buffer for BibTeX search results." + :group 'bibtex + :type 'string) + ;; `bibtex-font-lock-keywords' is a user option, too. But since the ;; patterns used to define this variable are defined in a later ;; section of this file, it is defined later. @@ -1025,6 +1030,7 @@ (define-key km "\C-c\C-rn" 'bibtex-narrow-to-entry) (define-key km "\C-c\C-rw" 'widen) (define-key km "\C-c\C-l" 'bibtex-url) + (define-key km "\C-c\C-a" 'bibtex-search-entries) (define-key km "\C-c\C-o" 'bibtex-remove-OPT-or-ALT) (define-key km "\C-c\C-e\C-i" 'bibtex-InProceedings) (define-key km "\C-c\C-ei" 'bibtex-InCollection) @@ -1102,6 +1108,8 @@ ["View Cite Locations (RefTeX)" reftex-view-crossref-from-bibtex (fboundp 'reftex-view-crossref-from-bibtex)]) ("Operating on Buffer or Region" + ["Search Entries" bibtex-search-entries t] + "--" ["Validate Entries" bibtex-validate t] ["Sort Entries" bibtex-sort-buffer t] ["Reformat Entries" bibtex-reformat t] @@ -4789,6 +4797,118 @@ (message "No URL known.")) url))) +;; We could combine multiple seach results with set operations +;; AND, OR, MINUS, and NOT. Would this be useful? +;; How complicated are searches in real life? +;; We could also have other searches such as "publication year newer than...". +(defun bibtex-search-entries (field regexp &optional global display) + "Search BibTeX entries for FIELD matching REGEXP. +REGEXP may be a regexp to search for. +If REGEXP is a function, it is called for each entry with two args, +the buffer positions of beginning and end of entry. Then an entry +is accepted if this function returns non-nil. +If FIELD is an empty string perform search for REGEXP in whole entry. +With GLOBAL non-nil, search in `bibtex-files'. Otherwise the search +is limited to the current buffer. +If DISPLAY is non-nil, display search results in `bibtex-search-buffer'. +When called interactively, DISPLAY is t. +Also, GLOBAL is t if `bibtex-search-entry-globally' is non-nil. +A prefix arg negates the value of `bibtex-search-entry-globally'. +Return alist with elements (KEY FILE ENTRY), +where FILE is the BibTeX file of ENTRY." + (interactive + (list (completing-read + "Field: " + (delete-dups + (apply 'append + bibtex-user-optional-fields + (mapcar (lambda (x) + (append (mapcar 'car (nth 0 (nth 1 x))) + (mapcar 'car (nth 1 (nth 1 x))))) + bibtex-entry-field-alist))) nil t) + (read-string "Regexp: ") + (if bibtex-search-entry-globally + (not current-prefix-arg) + current-prefix-arg) + t)) + (let ((funp (functionp regexp)) + entries text file) + ;; If REGEXP is a function, the value of FIELD is ignored anyway. + ;; Yet to ensure the code below does not fail, we make FIELD + ;; a non-empty string. + (if (and funp (string= "" field)) (setq field "unrestricted")) + (dolist (buffer (if (and global bibtex-files) + (bibtex-initialize t) + (list (current-buffer)))) + (with-current-buffer buffer + (setq file (if buffer-file-name + (file-name-nondirectory buffer-file-name) + (buffer-name buffer))) + (save-excursion + (goto-char (point-min)) + (if (string= "" field) + ;; Unrestricted search. + (while (re-search-forward regexp nil t) + (let ((beg (bibtex-beginning-of-entry)) + (end (bibtex-end-of-entry)) + key) + (if (and (<= beg (match-beginning 0)) + (<= (match-end 0) end) + (save-excursion + (goto-char beg) + (and (looking-at bibtex-entry-head) + (setq key (bibtex-key-in-head))))) + (add-to-list 'entries + (list key file + (buffer-substring-no-properties + beg end)))))) + ;; The following is slow. But it works reliably even in more + ;; complicated cases with BibTeX string constants and crossrefed + ;; entries. If you prefer speed over reliability, perform an + ;; unrestricted search. + (bibtex-map-entries + (lambda (key beg end) + (if (cond (funp (funcall regexp beg end)) + ((and (setq text (bibtex-text-in-field field t)) + (string-match regexp text)))) + (add-to-list 'entries + (list key file + (buffer-substring-no-properties + beg end)))))))))) + (if display + (if entries + (bibtex-display-entries entries) + (message "No BibTeX entries %smatching `%s'" + (if (string= "" field) "" + (format "with field `%s' " field)) + regexp))) + entries)) + +(defun bibtex-display-entries (entries &optional append) + "Display BibTeX ENTRIES in `bibtex-search-buffer'. +ENTRIES is an alist with elements (KEY FILE ENTRY), +where FILE is the BibTeX file of ENTRY. +If APPEND is non-nil, append ENTRIES to those already displayed." + (pop-to-buffer (get-buffer-create bibtex-search-buffer)) + ;; It would be nice if this buffer was editable, though editing + ;; can be meaningful only for individual existing entries + ;; (unlike reordering or creating new entries). + ;; Fancy workaround: Editing commands in the virtual buffer could + ;; jump to the real entry in the real buffer. + (let (buffer-read-only) + (if append (goto-char (point-max)) (erase-buffer)) + (dolist (entry (sort entries (lambda (x y) (string< (car x) (car y))))) + (insert "% " (nth 1 entry) "\n" (nth 2 entry) "\n\n"))) + ;; `bibtex-sort-buffer' fails with the file names associated with + ;; each entry. Prior to sorting we could make the file name + ;; a BibTeX field of each entry (using `bibtex-make-field'). + ;; Or we could make it a text property that we unfold afterwards. + ;; (bibtex-sort-buffer) + (bibtex-mode) + (set-buffer-modified-p nil) + (setq buffer-read-only t) + (goto-char (point-min))) + ;; Make BibTeX a Feature