diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4c7306174d6..61ef1a21065 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,22 @@ +2011-08-23 Stefan Monnier + + * shell.el (shell-completion-vars): Set pcomplete-arg-quote-list. + * pcomplete.el (pcomplete-quote-argument): Fix thinko (bug#9161). + + * pcomplete.el (pcomplete-parse-comint-arguments): Fix inf-loop. + Mark obsolete. + * shell.el (shell-parse-pcomplete-arguments): New function. + (shell-completion-vars): Use it instead (bug#9160). + +2011-08-22 Stefan Monnier + + * progmodes/sh-script.el (sh-maybe-here-document): Disable magic in + strings and comments (bug#9333). + + * emacs-lisp/debug.el (debug-arglist): New function. + (debug-convert-byte-code): Use it. Handle lexical byte-codes. + (debug-on-entry-1): Handle interpreted closures (bug#9120). + 2011-08-22 Juri Linkov * progmodes/compile.el (compilation-mode-font-lock-keywords): @@ -45,8 +64,8 @@ (font-lock-default-fontify-region) (font-lock-default-unfontify-region): Add docstrings (Bug#8624). - * progmodes/compile.el (compilation-error-properties): Fix - confusion between file struct and message struct (Bug#9319). + * progmodes/compile.el (compilation-error-properties): + Fix confusion between file struct and message struct (Bug#9319). (compilation-error-regexp-alist-alist): Fix 2011-05-09 change to `ant' regexp. @@ -140,8 +159,8 @@ binding variables (bug#9298). Also clean up some unused autoloads. - * net/network-stream.el (network-stream-open-starttls): Support - using starttls.el without using gnutls-cli. + * net/network-stream.el (network-stream-open-starttls): + Support using starttls.el without using gnutls-cli. 2011-08-17 Juri Linkov diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el index 157749500e7..8276030ccf8 100644 --- a/lisp/emacs-lisp/debug.el +++ b/lisp/emacs-lisp/debug.el @@ -778,6 +778,7 @@ Redefining FUNCTION also cancels it." (not (debugger-special-form-p symbol)))) t nil nil (symbol-name fn))) (list (if (equal val "") fn (intern val))))) + ;; FIXME: Use advice.el. (when (debugger-special-form-p function) (error "Function %s is a special form" function)) (if (or (symbolp (symbol-function function)) @@ -835,24 +836,30 @@ To specify a nil argument interactively, exit with an empty minibuffer." (message "Cancelling debug-on-entry for all functions") (mapcar 'cancel-debug-on-entry debug-function-list))) +(defun debug-arglist (definition) + ;; FIXME: copied from ad-arglist. + "Return the argument list of DEFINITION." + (require 'help-fns) + (help-function-arglist definition 'preserve-names)) + (defun debug-convert-byte-code (function) (let* ((defn (symbol-function function)) (macro (eq (car-safe defn) 'macro))) (when macro (setq defn (cdr defn))) - (unless (consp defn) - ;; Assume a compiled code object. - (let* ((contents (append defn nil)) + (when (byte-code-function-p defn) + (let* ((args (debug-arglist defn)) (body - (list (list 'byte-code (nth 1 contents) - (nth 2 contents) (nth 3 contents))))) - (if (nthcdr 5 contents) - (setq body (cons (list 'interactive (nth 5 contents)) body))) - (if (nth 4 contents) + `((,(if (memq '&rest args) #'apply #'funcall) + ,defn + ,@(remq '&rest (remq '&optional args)))))) + (if (> (length defn) 5) + (push `(interactive ,(aref defn 5)) body)) + (if (aref defn 4) ;; Use `documentation' here, to get the actual string, ;; in case the compiled function has a reference ;; to the .elc file. (setq body (cons (documentation function) body))) - (setq defn (cons 'lambda (cons (car contents) body)))) + (setq defn `(closure (t) ,args ,@body))) (when macro (setq defn (cons 'macro defn))) (fset function defn)))) @@ -861,11 +868,12 @@ To specify a nil argument interactively, exit with an empty minibuffer." (tail defn)) (when (eq (car-safe tail) 'macro) (setq tail (cdr tail))) - (if (not (eq (car-safe tail) 'lambda)) + (if (not (memq (car-safe tail) '(closure lambda))) ;; Only signal an error when we try to set debug-on-entry. ;; When we try to clear debug-on-entry, we are now done. (when flag (error "%s is not a user-defined Lisp function" function)) + (if (eq (car tail) 'closure) (setq tail (cdr tail))) (setq tail (cdr tail)) ;; Skip the docstring. (when (and (stringp (cadr tail)) (cddr tail)) @@ -875,9 +883,9 @@ To specify a nil argument interactively, exit with an empty minibuffer." (setq tail (cdr tail))) (unless (eq flag (equal (cadr tail) '(implement-debug-on-entry))) ;; Add/remove debug statement as needed. - (if flag - (setcdr tail (cons '(implement-debug-on-entry) (cdr tail))) - (setcdr tail (cddr tail))))) + (setcdr tail (if flag + (cons '(implement-debug-on-entry) (cdr tail)) + (cddr tail))))) defn)) (defun debugger-list-functions () diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el index 46a82e3720d..bdf2dadd16c 100644 --- a/lisp/pcomplete.el +++ b/lisp/pcomplete.el @@ -811,15 +811,19 @@ this is `comint-dynamic-complete-functions'." (while (< (point) end) (skip-chars-forward " \t\n") (push (point) begins) - (let ((skip t)) - (while skip - (skip-chars-forward "^ \t\n") - (if (eq (char-before) ?\\) - (skip-chars-forward " \t\n") - (setq skip nil)))) + (while + (progn + (skip-chars-forward "^ \t\n\\") + (when (eq (char-after) ?\\) + (forward-char 1) + (unless (eolp) + (forward-char 1) + t)))) (push (buffer-substring-no-properties (car begins) (point)) args)) (cons (nreverse args) (nreverse begins))))) +(make-obsolete 'pcomplete-parse-comint-arguments + 'comint-parse-pcomplete-arguments "24.1") (defun pcomplete-parse-arguments (&optional expand-p) "Parse the command line arguments. Most completions need this info." @@ -879,7 +883,7 @@ Magic characters are those in `pcomplete-arg-quote-list'." (or (run-hook-with-args-until-success 'pcomplete-quote-arg-hook filename index) (when (memq c pcomplete-arg-quote-list) - (string "\\" c)) + (string ?\\ c)) (char-to-string c)) (setq index (1+ index)))) filename diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 31a4fbaef4d..7b949134c6c 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -460,6 +460,7 @@ This is buffer-local in every such buffer.") (define-key map "\C-c+" 'sh-add) (define-key map "\C-\M-x" 'sh-execute-region) (define-key map "\C-c\C-x" 'executable-interpret) + ;; FIXME: Use post-self-insert-hook. (define-key map "<" 'sh-maybe-here-document) (define-key map "(" 'skeleton-pair-insert-maybe) (define-key map "{" 'skeleton-pair-insert-maybe) @@ -3659,6 +3660,7 @@ The document is bounded by `sh-here-document-word'." (save-excursion (backward-char 2) (sh-quoted-p)) + (nth 8 (syntax-ppss)) (let ((tabs (if (string-match "\\`-" sh-here-document-word) (make-string (/ (current-indentation) tab-width) ?\t) "")) diff --git a/lisp/shell.el b/lisp/shell.el index de811543ba0..01d1a688f0e 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -383,6 +383,21 @@ to `dirtrack-mode'." :group 'shell :type '(choice (const nil) regexp)) +(defun shell-parse-pcomplete-arguments () + "Parse whitespace separated arguments in the current region." + (let ((begin (save-excursion (shell-backward-command 1) (point))) + (end (point)) + begins args) + (save-excursion + (goto-char begin) + (while (< (point) end) + (skip-chars-forward " \t\n") + (push (point) begins) + (looking-at "\\(?:[^\s\t\n\\]\\|'[^']*'\\|\"\\(?:[^\"\\]\\|\\\\.\\)*\"\\|\\\\.\\)*\\(?:\\\\\\|'[^']*\\|\"\\(?:[^\"\\]\\|\\\\.\\)*\\)?") + (goto-char (match-end 0)) + (push (buffer-substring-no-properties (car begins) (point)) + args)) + (cons (nreverse args) (nreverse begins))))) (defun shell-completion-vars () "Setup completion vars for `shell-mode' and `read-shell-command'." @@ -396,8 +411,9 @@ to `dirtrack-mode'." (set (make-local-variable 'comint-dynamic-complete-functions) shell-dynamic-complete-functions) (set (make-local-variable 'pcomplete-parse-arguments-function) - ;; FIXME: This function should be moved to shell.el. - #'pcomplete-parse-comint-arguments) + #'shell-parse-pcomplete-arguments) + (set (make-local-variable 'pcomplete-arg-quote-list) + (append "\\ \t\n\r\"'`$|&;(){}[]<>#" nil)) (set (make-local-variable 'pcomplete-termination-string) (cond ((not comint-completion-addsuffix) "") ((stringp comint-completion-addsuffix) diff --git a/src/ChangeLog b/src/ChangeLog index e3cf7546962..d4f654a1028 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2011-08-23 Eli Zaretskii + + * dispnew.c (buffer_posn_from_coords): Use buf_charpos_to_bytepos + instead of CHAR_TO_BYTE. Fixes a crash when a completion + candidate is selected by the mouse, and that candidate has a + composed character under the mouse. + + * xdisp.c (x_produce_glyphs): Set it->nglyphs to 1. Fixes pixel + coordinates reported by pos-visible-in-window-p for a composed + character in column zero. + +2011-08-23 Stefan Monnier + + * cmds.c (Fself_insert_command): Mention post-self-insert-hook. + 2011-08-22 Eli Zaretskii * xdisp.c (BUFFER_POS_REACHED_P): If this is a composition, @@ -45,8 +60,8 @@ 2011-08-17 Chong Yidong * eval.c (internal_condition_case, internal_condition_case_1) - (internal_condition_case_2, internal_condition_case_n): Remove - unnecessary aborts (Bug#9081). + (internal_condition_case_2, internal_condition_case_n): + Remove unnecessary aborts (Bug#9081). 2011-08-17 Eli Zaretskii @@ -69,8 +84,8 @@ * unexcw.c ( __malloc_initialized): Declare external variable. (fixup_executable): Force the dumped emacs to reinitialize malloc. - * gmalloc.c [CYGWIN] (bss_sbrk_heapbase, bss_sbrk_heapinfo): New - variables. + * gmalloc.c [CYGWIN] (bss_sbrk_heapbase, bss_sbrk_heapinfo): + New variables. (malloc_initialize_1) [CYGWIN]: Prepare for reinitializing the dumped emacs. (_free_internal_nolock) [CYGWIN]: Ignore requests to free storage @@ -172,8 +187,8 @@ * xdisp.c (iterate_out_of_display_property): xassert that IT->position is set to within IT->object's boundaries. Break from the loop as soon as EOB is reached; avoids infloops in redisplay - when IT->position is set up wrongly due to some bug. Set - IT->current to match the bidi iterator unconditionally. + when IT->position is set up wrongly due to some bug. + Set IT->current to match the bidi iterator unconditionally. (push_display_prop): Allow GET_FROM_STRING as IT->method on entry. Force push_it to save on the stack the current buffer/string position, to be restored by pop_it. Fix flags in @@ -196,8 +211,8 @@ 2011-08-08 Eli Zaretskii * xdisp.c (forward_to_next_line_start): Allow to use the - no-display-properties-and-no-overlays under bidi display. Set - disp_pos in the bidi iterator to avoid searches for display + no-display-properties-and-no-overlays under bidi display. + Set disp_pos in the bidi iterator to avoid searches for display properties and overlays. 2011-08-08 Chong Yidong @@ -235,7 +250,7 @@ * bidi.c : Now static. (bidi_initialize): Initialize bidi_cache_total_alloc. - *xdisp.c (display_line): Release buffer allocated for shelved bidi + * xdisp.c (display_line): Release buffer allocated for shelved bidi cache. (Bug#9221) * bidi.c (bidi_shelve_cache, bidi_unshelve_cache): Track total diff --git a/src/cmds.c b/src/cmds.c index f49cfc221be..c079ad7168f 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -271,7 +271,8 @@ Whichever character you type to run this command is inserted. Before insertion, `expand-abbrev' is executed if the inserted character does not have word syntax and the previous character in the buffer does. After insertion, the value of `auto-fill-function' is called if the -`auto-fill-chars' table has a non-nil value for the inserted character. */) +`auto-fill-chars' table has a non-nil value for the inserted character. +At the end, it runs `post-self-insert-hook'. */) (Lisp_Object n) { int remove_boundary = 1; diff --git a/src/dispnew.c b/src/dispnew.c index 4cffc32b0d7..a09421a9f15 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -5314,7 +5314,8 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p if (STRINGP (it.string)) BYTEPOS (pos->pos) = string_char_to_byte (string, CHARPOS (pos->pos)); else - BYTEPOS (pos->pos) = CHAR_TO_BYTE (CHARPOS (pos->pos)); + BYTEPOS (pos->pos) = buf_charpos_to_bytepos (XBUFFER (w->buffer), + CHARPOS (pos->pos)); } #ifdef HAVE_WINDOW_SYSTEM diff --git a/src/xdisp.c b/src/xdisp.c index 5ce8cbf8d9b..6fbbc69a7ca 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -24292,6 +24292,8 @@ x_produce_glyphs (struct it *it) Lisp_Object gstring; struct font_metrics metrics; + it->nglyphs = 1; + gstring = composition_gstring_from_id (it->cmp_it.id); it->pixel_width = composition_gstring_width (gstring, it->cmp_it.from, it->cmp_it.to,