(pcomplete--common-suffix): Remove.
(pcomplete--common-quoted-suffix): Use comint--common-suffix instead.
(pcomplete--table-subvert): Sync with comint--table-subvert.
(pcomplete--entries): Use comint-completion-file-name-table.
* lisp/comint.el (comint-unquote-filename): Simplify.
(comint-completion-file-name-table): New function.
(comint--complete-file-name-data): Use it.
* src/dired.c (file_name_completion): Don't expand file name.
(Ffile_name_completion, Ffile_name_all_completions): Expand file name
before checking file name handler.
Fixes: debbugs:9616
2011-10-02 Stefan Monnier <monnier@iro.umontreal.ca>
+ * pcomplete.el: Require comint.
+ (pcomplete--common-suffix): Remove.
+ (pcomplete--common-quoted-suffix): Use comint--common-suffix instead.
+ (pcomplete--table-subvert): Sync with comint--table-subvert.
+ (pcomplete--entries): Use comint-completion-file-name-table.
+ * comint.el (comint-unquote-filename): Simplify.
+ (comint-completion-file-name-table): New function (bug#9616).
+ (comint--complete-file-name-data): Use it.
+
* pcmpl-gnu.el (pcmpl-gnu-with-file-buffer): New macro (bug#9643).
(pcmpl-gnu-tar-buffer): Remove.
(pcmpl-gnu-with-file-buffer): Use it to avoid leaving the tar's buffer
(if (null comint-file-name-quote-list)
filename
(save-match-data
- (let ((i 0))
- (while (string-match "\\\\\\(.\\)" filename i)
- (setq filename (replace-match "\\1" nil nil filename))
- (setq i (+ 1 (match-beginning 0)))))
- filename)))
+ (replace-regexp-in-string "\\\\\\(.\\)" "\\1" filename t))))
(defun comint-completion-at-point ()
(run-hook-with-args-until-success 'comint-dynamic-complete-functions))
(- (match-end 1) (match-beginning 1))))
(defun comint--common-quoted-suffix (s1 s2)
+ ;; FIXME: Copied in pcomplete.el.
"Find the common suffix between S1 and S2 where S1 is the expanded S2.
S1 is expected to be the unquoted and expanded version of S1.
Returns (PS1 . PS2), i.e. the shortest prefixes of S1 and S2, such that
;; E.g. action=nil and it's the only completion.
(res)))))
+(defun comint-completion-file-name-table (string pred action)
+ (if (not (file-name-absolute-p string))
+ (completion-file-name-table string pred action)
+ (cond
+ ((memq action '(t lambda))
+ (completion-file-name-table
+ (concat comint-file-name-prefix string) pred action))
+ ((null action)
+ (let ((res (completion-file-name-table
+ (concat comint-file-name-prefix string) pred action)))
+ (if (and (stringp res)
+ (string-match
+ (concat "\\`" (regexp-quote comint-file-name-prefix))
+ res))
+ (substring res (match-end 0))
+ res)))
+ (t (completion-file-name-table string pred action)))))
+
(defun comint--complete-file-name-data ()
"Return the completion data for file name at point."
(let* ((filesuffix (cond ((not comint-completion-addsuffix) "")
unquoted filename)))
(apply-partially
#'comint--table-subvert
- #'completion-file-name-table
+ #'comint-completion-file-name-table
(cdr prefixes) (car prefixes)))))
(nconc
(list
;;; Code:
(eval-when-compile (require 'cl))
+(require 'comint)
(defgroup pcomplete nil
"Programmable completion."
(t
(replace-regexp-in-string "\\\\\\(.\\)" "\\1" s t))))
-(defun pcomplete--common-suffix (s1 s2)
- (assert (not (or (string-match "\n" s1) (string-match "\n" s2))))
- ;; Since S2 is expected to be the "unquoted/expanded" version of S1,
- ;; there shouldn't be any case difference, even if the completion is
- ;; case-insensitive.
- (let ((case-fold-search nil)) ;; pcomplete-ignore-case
- (string-match ".*?\\(.*\\)\n.*\\1\\'" (concat s1 "\n" s2))
- (- (match-end 1) (match-beginning 1))))
-
(defun pcomplete--common-quoted-suffix (s1 s2)
+ ;; FIXME: Copied in comint.el.
"Find the common suffix between S1 and S2 where S1 is the expanded S2.
S1 is expected to be the unquoted and expanded version of S1.
Returns (PS1 . PS2), i.e. the shortest prefixes of S1 and S2, such that
S1 = (concat PS1 SS1) and S2 = (concat PS2 SS2) and
SS1 = (unquote SS2)."
- (let* ((cs (pcomplete--common-suffix s1 s2))
+ (let* ((cs (comint--common-suffix s1 s2))
(ss1 (substring s1 (- (length s1) cs)))
(qss1 (pcomplete-quote-argument ss1))
qc)
(substring s2 0 (- (length s2) cs))))))
(defun pcomplete--table-subvert (table s1 s2 string pred action)
+ ;; FIXME: Copied in comint.el.
"Completion table that replaces the prefix S1 with S2 in STRING.
When TABLE, S1 and S2 are provided by `apply-partially', the result
is a completion table which completes strings of the form (concat S1 S)
(mapcar (lambda (c)
(if (string-match re c)
(substring c (match-end 0))))
- res))))))))))
+ res))))))
+ ;; E.g. action=nil and it's the only completion.
+ (res)))))
;; I don't think such commands are usable before first setting up buffer-local
;; variables to parse args, so there's no point autoloading it.
,@(cdr (completion-file-name-table s p a)))
(let ((completion-ignored-extensions nil))
(completion-table-with-predicate
- 'completion-file-name-table pred 'strict s p a))))))
+ #'comint-completion-file-name-table pred 'strict s p a))))))
(defconst pcomplete--env-regexp
"\\(?:\\`\\|[^\\]\\)\\(?:\\\\\\\\\\)*\\(\\$\\(?:{\\([^}]+\\)}\\|\\(?2:[[:alnum:]_]+\\)\\)\\)")
2011-10-02 Stefan Monnier <monnier@iro.umontreal.ca>
+ * dired.c (file_name_completion): Don't expand file name.
+ (Ffile_name_completion, Ffile_name_all_completions): Expand file name
+ before checking file name handler.
+
* minibuf.c (Finternal_complete_buffer): Only show internal buffers if
they've been requested explicitly (bug#9591).
* xdisp.c (handle_invisible_prop): If invisible text ends on a
newline, reseat the iterator instead of bidi-iterating there one
character at a time. (Bug#9610)
- (BUFFER_POS_REACHED_P, move_it_in_display_line_to): Bail out when
- past TO_CHARPOS if the bidi iterator is at base embedding level.
+ (BUFFER_POS_REACHED_P, move_it_in_display_line_to): Bail when past
+ TO_CHARPOS if the bidi iterator is at base embedding level.
2011-09-27 Andreas Schwab <schwab@linux-m68k.org>
value is now t. Doc fix.
* indent.c (Fvertical_motion): Compute and apply the overshoot
- logic also when moving up, not only when moving down. Fix the
+ logic when moving up, not only when moving down. Fix the
confusing name and values of the it_overshoot_expected variable;
- logic changed accordingly. (Bug#9254) (Bug#9549)
+ logic changes accordingly. (Bug#9254) (Bug#9549)
* xdisp.c (pos_visible_p): Produce correct pixel coordinates when
CHARPOS is covered by a display string which includes newlines.
2011-09-24 Jim Meyering <meyering@redhat.com>
- Do not ignore write error for any output size.
+ do not ignore write error for any output size
The previous change was incomplete.
While it makes emacs --batch detect the vast majority of stdout
write failures, errors were still ignored whenever the output size is
(Lisp_Object file, Lisp_Object directory, Lisp_Object predicate)
{
Lisp_Object handler;
+ directory = Fexpand_file_name (directory, Qnil);
/* If the directory name has special constructs in it,
call the corresponding file handler. */
(Lisp_Object file, Lisp_Object directory)
{
Lisp_Object handler;
+ directory = Fexpand_file_name (directory, Qnil);
/* If the directory name has special constructs in it,
call the corresponding file handler. */
bestmatch = Qnil;
encoded_file = encoded_dir = Qnil;
GCPRO5 (file, dirname, bestmatch, encoded_file, encoded_dir);
- dirname = Fexpand_file_name (dirname, Qnil);
specbind (Qdefault_directory, dirname);
/* Do completion on the encoded file name