unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#29007: 25.3; [PATCH] Make filecache use extended completion
@ 2017-10-26  6:56 Andreas Politz
  2017-11-03  9:56 ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Andreas Politz @ 2017-10-26  6:56 UTC (permalink / raw)
  To: 29007

[-- Attachment #1: Type: text/plain, Size: 193 bytes --]


As it is, file-cache-minibuffer-complete uses prefix completion via
{try,all}-completion only, which makes it less convenient.  The patch
below adds calls to completion-{try,all}-completion.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: file-cache-minibuffer-complete --]
[-- Type: text/x-diff, Size: 6202 bytes --]

diff --git a/lisp/filecache.el b/lisp/filecache.el
index 38a434b11b..aac4f488cd 100644
--- a/lisp/filecache.el
+++ b/lisp/filecache.el
@@ -566,68 +566,67 @@ file-cache-minibuffer-complete
 the name is considered already unique; only the second substitution
 \(directories) is done."
   (interactive "P")
-  (let*
-      (
-       (completion-ignore-case file-cache-completion-ignore-case)
-       (case-fold-search       file-cache-case-fold-search)
-       (string                 (file-name-nondirectory (minibuffer-contents)))
-       (completion-string      (try-completion string file-cache-alist))
-       (completion-list)
-       (len)
-       (file-cache-string))
+  (let* ((completion-ignore-case file-cache-completion-ignore-case)
+         (case-fold-search       file-cache-case-fold-search)
+         (string                 (file-name-nondirectory (minibuffer-contents)))
+         (completion             (completion-try-completion
+                                  string file-cache-alist nil 0)))
     (cond
      ;; If it's the only match, replace the original contents
-     ((or arg (eq completion-string t))
-      (setq file-cache-string (file-cache-file-name string))
-      (if (string= file-cache-string (minibuffer-contents))
-	  (minibuffer-message file-cache-sole-match-message)
-	(delete-minibuffer-contents)
-	(insert file-cache-string)
-	(if file-cache-multiple-directory-message
-	    (minibuffer-message file-cache-multiple-directory-message))))
+     ((or arg (eq completion t))
+      (let ((file-name (file-cache-file-name string)))
+        (if (string= file-name (minibuffer-contents))
+            (minibuffer-message file-cache-sole-match-message)
+          (delete-minibuffer-contents)
+          (insert file-name)
+          (if file-cache-multiple-directory-message
+              (minibuffer-message file-cache-multiple-directory-message)))))
 
      ;; If it's the longest match, insert it
-     ((stringp completion-string)
-      ;; If we've already inserted a unique string, see if the user
-      ;; wants to use that one
-      (if (and (string= string completion-string)
-	       (assoc-string string file-cache-alist
-			     file-cache-ignore-case))
-	  (if (and (eq last-command this-command)
-		   (string= file-cache-last-completion completion-string))
-	      (progn
-		(delete-minibuffer-contents)
-		(insert (file-cache-file-name completion-string))
-		(setq file-cache-last-completion nil))
-	    (minibuffer-message file-cache-non-unique-message)
-	    (setq file-cache-last-completion string))
-	(setq file-cache-last-completion string)
-	(setq completion-list (all-completions string file-cache-alist)
-	      len             (length completion-list))
-	(if (> len 1)
-	    (progn
-	      (goto-char (point-max))
-	      (insert
-	       (substring completion-string (length string)))
-	      ;; Add our own setup function to the Completions Buffer
-	      (let ((completion-setup-hook
-                     (append completion-setup-hook
-                             (list 'file-cache-completion-setup-function))))
-		(with-output-to-temp-buffer file-cache-completions-buffer
-		  (display-completion-list
-                   (completion-hilit-commonality completion-list
-                                                 (length string))))))
-	  (setq file-cache-string (file-cache-file-name completion-string))
-	  (if (string= file-cache-string (minibuffer-contents))
-	      (minibuffer-message file-cache-sole-match-message)
-	    (delete-minibuffer-contents)
-	    (insert file-cache-string)
-	    (if file-cache-multiple-directory-message
-		(minibuffer-message file-cache-multiple-directory-message)))
-	  )))
+     ((consp completion)
+      (let ((newstring (car completion))
+            (newpoint  (cdr completion)))
+        ;; If we've already inserted a unique string, see if the user
+        ;; wants to use that one
+        (if (and (string= string newstring)
+                 (assoc-string string file-cache-alist
+                               file-cache-ignore-case))
+            (if (and (eq last-command this-command)
+                     (string= file-cache-last-completion newstring))
+                (progn
+                  (delete-minibuffer-contents)
+                  (insert (file-cache-file-name newstring))
+                  (setq file-cache-last-completion nil))
+              (minibuffer-message file-cache-non-unique-message)
+              (setq file-cache-last-completion string))
+          (setq file-cache-last-completion string)
+          (let* ((completion-list (completion-all-completions
+                                   newstring file-cache-alist nil newpoint))
+                 (base-size       (cdr (last completion-list))))
+            (when base-size
+              (setcdr (last completion-list) nil))
+            (if (> (length completion-list) 1)
+                (progn
+                  (delete-region (- (point-max) (length string)) (point-max))
+                  (save-excursion (insert newstring))
+                  (forward-char newpoint)
+                  ;; Add our own setup function to the Completions Buffer
+                  (let ((completion-setup-hook
+                         (append completion-setup-hook
+                                 (list 'file-cache-completion-setup-function))))
+                    (with-output-to-temp-buffer file-cache-completions-buffer
+                      (display-completion-list
+                       (completion-hilit-commonality completion-list newpoint)))))
+              (let ((file-name (file-cache-file-name newstring)))
+                (if (string= file-name (minibuffer-contents))
+                    (minibuffer-message file-cache-sole-match-message)
+                  (delete-minibuffer-contents)
+                  (insert file-name)
+                  (if file-cache-multiple-directory-message
+                      (minibuffer-message file-cache-multiple-directory-message)))))))))
 
      ;; No match
-     ((eq completion-string nil)
+     ((eq completion nil)
       (minibuffer-message file-cache-no-match-message)))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

[-- Attachment #3: Type: text/plain, Size: 16633 bytes --]


-ap



In GNU Emacs 25.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.19)
 of 2017-09-16 built on juergen
Windowing system distributor 'The X.Org Foundation', version 11.0.11905000
System Description:	Arch Linux

Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --with-x-toolkit=gtk3 --with-xft --with-modules
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
 -fno-plt' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Org

Minor modes in effect:
  shell-dirtrack-mode: t
  TeX-PDF-mode: t
  pdf-occur-global-minor-mode: t
  sane/sync-mail-mode: t
  override-global-mode: t
  savehist-mode: t
  diff-auto-refine-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  auto-fill-function: org-auto-fill-function
  transient-mark-mode: t

Recent messages:
Wrote /home/politza/.emacs.d/etc/init.org
Mark set
Press C-c C-c when you are done editing.
Enter a change comment.  Type C-c C-c when done
Checking in /home/politza/.emacs.d/etc/init.org...done
Mark set
Saved text until "message file-cache-no-match-message)))))"
Finding changes in /home/politza/.emacs.d/etc/init.org...
No changes between working revision and workfile
Making completion list...

Load-path shadows:
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-latex hides /usr/share/emacs/25.3/lisp/org/ob-latex
/home/politza/.emacs.d/usr/elpa/org-20170814/org-mobile hides /usr/share/emacs/25.3/lisp/org/org-mobile
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-screen hides /usr/share/emacs/25.3/lisp/org/ob-screen
/home/politza/.emacs.d/usr/elpa/org-20170814/org-plot hides /usr/share/emacs/25.3/lisp/org/org-plot
/home/politza/.emacs.d/usr/elpa/org-20170814/org-capture hides /usr/share/emacs/25.3/lisp/org/org-capture
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-org hides /usr/share/emacs/25.3/lisp/org/ob-org
/home/politza/.emacs.d/usr/elpa/org-20170814/ox-ascii hides /usr/share/emacs/25.3/lisp/org/ox-ascii
/home/politza/.emacs.d/usr/elpa/org-20170814/org-agenda hides /usr/share/emacs/25.3/lisp/org/org-agenda
/home/politza/.emacs.d/usr/elpa/org-20170814/org-protocol hides /usr/share/emacs/25.3/lisp/org/org-protocol
/home/politza/.emacs.d/usr/elpa/org-20170814/ox-icalendar hides /usr/share/emacs/25.3/lisp/org/ox-icalendar
/home/politza/.emacs.d/usr/elpa/org-20170814/org-gnus hides /usr/share/emacs/25.3/lisp/org/org-gnus
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-io hides /usr/share/emacs/25.3/lisp/org/ob-io
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-comint hides /usr/share/emacs/25.3/lisp/org/ob-comint
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-matlab hides /usr/share/emacs/25.3/lisp/org/ob-matlab
/home/politza/.emacs.d/usr/elpa/org-20170814/org-compat hides /usr/share/emacs/25.3/lisp/org/org-compat
/home/politza/.emacs.d/usr/elpa/org-20170814/org-src hides /usr/share/emacs/25.3/lisp/org/org-src
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-ditaa hides /usr/share/emacs/25.3/lisp/org/ob-ditaa
/home/politza/.emacs.d/usr/elpa/org-20170814/org-bibtex hides /usr/share/emacs/25.3/lisp/org/org-bibtex
/home/politza/.emacs.d/usr/elpa/org-20170814/org-feed hides /usr/share/emacs/25.3/lisp/org/org-feed
/home/politza/.emacs.d/usr/elpa/org-20170814/org-bbdb hides /usr/share/emacs/25.3/lisp/org/org-bbdb
/home/politza/.emacs.d/usr/elpa/org-20170814/ox-texinfo hides /usr/share/emacs/25.3/lisp/org/ox-texinfo
/home/politza/.emacs.d/usr/elpa/org-20170814/org-entities hides /usr/share/emacs/25.3/lisp/org/org-entities
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-css hides /usr/share/emacs/25.3/lisp/org/ob-css
/home/politza/.emacs.d/usr/elpa/org-20170814/org-macro hides /usr/share/emacs/25.3/lisp/org/org-macro
/home/politza/.emacs.d/usr/elpa/org-20170814/org-crypt hides /usr/share/emacs/25.3/lisp/org/org-crypt
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-core hides /usr/share/emacs/25.3/lisp/org/ob-core
/home/politza/.emacs.d/usr/elpa/org-20170814/ox-latex hides /usr/share/emacs/25.3/lisp/org/ox-latex
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-sass hides /usr/share/emacs/25.3/lisp/org/ob-sass
/home/politza/.emacs.d/usr/elpa/org-20170814/org-mouse hides /usr/share/emacs/25.3/lisp/org/org-mouse
/home/politza/.emacs.d/usr/elpa/org-20170814/org-info hides /usr/share/emacs/25.3/lisp/org/org-info
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-shen hides /usr/share/emacs/25.3/lisp/org/ob-shen
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-sql hides /usr/share/emacs/25.3/lisp/org/ob-sql
/home/politza/.emacs.d/usr/elpa/org-20170814/ox-html hides /usr/share/emacs/25.3/lisp/org/ox-html
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-makefile hides /usr/share/emacs/25.3/lisp/org/ob-makefile
/home/politza/.emacs.d/usr/elpa/org-20170814/org-colview hides /usr/share/emacs/25.3/lisp/org/org-colview
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-plantuml hides /usr/share/emacs/25.3/lisp/org/ob-plantuml
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-scheme hides /usr/share/emacs/25.3/lisp/org/ob-scheme
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-ref hides /usr/share/emacs/25.3/lisp/org/ob-ref
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-picolisp hides /usr/share/emacs/25.3/lisp/org/ob-picolisp
/home/politza/.emacs.d/usr/elpa/org-20170814/ob hides /usr/share/emacs/25.3/lisp/org/ob
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-js hides /usr/share/emacs/25.3/lisp/org/ob-js
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-octave hides /usr/share/emacs/25.3/lisp/org/ob-octave
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-calc hides /usr/share/emacs/25.3/lisp/org/ob-calc
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-eval hides /usr/share/emacs/25.3/lisp/org/ob-eval
/home/politza/.emacs.d/usr/elpa/org-20170814/org-indent hides /usr/share/emacs/25.3/lisp/org/org-indent
/home/politza/.emacs.d/usr/elpa/org-20170814/org-eshell hides /usr/share/emacs/25.3/lisp/org/org-eshell
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-mscgen hides /usr/share/emacs/25.3/lisp/org/ob-mscgen
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-C hides /usr/share/emacs/25.3/lisp/org/ob-C
/home/politza/.emacs.d/usr/elpa/org-20170814/org-list hides /usr/share/emacs/25.3/lisp/org/org-list
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-lisp hides /usr/share/emacs/25.3/lisp/org/ob-lisp
/home/politza/.emacs.d/usr/elpa/org-20170814/ox-publish hides /usr/share/emacs/25.3/lisp/org/ox-publish
/home/politza/.emacs.d/usr/elpa/org-20170814/org-docview hides /usr/share/emacs/25.3/lisp/org/org-docview
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-keys hides /usr/share/emacs/25.3/lisp/org/ob-keys
/home/politza/.emacs.d/usr/elpa/org-20170814/ox-org hides /usr/share/emacs/25.3/lisp/org/ox-org
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-asymptote hides /usr/share/emacs/25.3/lisp/org/ob-asymptote
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-ocaml hides /usr/share/emacs/25.3/lisp/org/ob-ocaml
/home/politza/.emacs.d/usr/elpa/org-20170814/org-loaddefs hides /usr/share/emacs/25.3/lisp/org/org-loaddefs
/home/politza/.emacs.d/usr/elpa/org-20170814/org-habit hides /usr/share/emacs/25.3/lisp/org/org-habit
/home/politza/.emacs.d/usr/elpa/org-20170814/org-clock hides /usr/share/emacs/25.3/lisp/org/org-clock
/home/politza/.emacs.d/usr/elpa/org-20170814/org-pcomplete hides /usr/share/emacs/25.3/lisp/org/org-pcomplete
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-lilypond hides /usr/share/emacs/25.3/lisp/org/ob-lilypond
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-tangle hides /usr/share/emacs/25.3/lisp/org/ob-tangle
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-dot hides /usr/share/emacs/25.3/lisp/org/ob-dot
/home/politza/.emacs.d/usr/elpa/org-20170814/ox hides /usr/share/emacs/25.3/lisp/org/ox
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-python hides /usr/share/emacs/25.3/lisp/org/ob-python
/home/politza/.emacs.d/usr/elpa/org-20170814/org-macs hides /usr/share/emacs/25.3/lisp/org/org-macs
/home/politza/.emacs.d/usr/elpa/org-20170814/org-id hides /usr/share/emacs/25.3/lisp/org/org-id
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-clojure hides /usr/share/emacs/25.3/lisp/org/ob-clojure
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-perl hides /usr/share/emacs/25.3/lisp/org/ob-perl
/home/politza/.emacs.d/usr/elpa/org-20170814/org-w3m hides /usr/share/emacs/25.3/lisp/org/org-w3m
/home/politza/.emacs.d/usr/elpa/org-20170814/ox-md hides /usr/share/emacs/25.3/lisp/org/ox-md
/home/politza/.emacs.d/usr/elpa/org-20170814/org-mhe hides /usr/share/emacs/25.3/lisp/org/org-mhe
/home/politza/.emacs.d/usr/elpa/org-20170814/org-attach hides /usr/share/emacs/25.3/lisp/org/org-attach
/home/politza/.emacs.d/usr/elpa/org-20170814/org-datetree hides /usr/share/emacs/25.3/lisp/org/org-datetree
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-ledger hides /usr/share/emacs/25.3/lisp/org/ob-ledger
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-lob hides /usr/share/emacs/25.3/lisp/org/ob-lob
/home/politza/.emacs.d/usr/elpa/org-20170814/org-table hides /usr/share/emacs/25.3/lisp/org/org-table
/home/politza/.emacs.d/usr/elpa/org-20170814/org-archive hides /usr/share/emacs/25.3/lisp/org/org-archive
/home/politza/.emacs.d/usr/elpa/org-20170814/org-version hides /usr/share/emacs/25.3/lisp/org/org-version
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-awk hides /usr/share/emacs/25.3/lisp/org/ob-awk
/home/politza/.emacs.d/usr/elpa/org-20170814/ox-odt hides /usr/share/emacs/25.3/lisp/org/ox-odt
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-maxima hides /usr/share/emacs/25.3/lisp/org/ob-maxima
/home/politza/.emacs.d/usr/elpa/org-20170814/org-footnote hides /usr/share/emacs/25.3/lisp/org/org-footnote
/home/politza/.emacs.d/usr/elpa/org-20170814/org-irc hides /usr/share/emacs/25.3/lisp/org/org-irc
/home/politza/.emacs.d/usr/elpa/org-20170814/org-ctags hides /usr/share/emacs/25.3/lisp/org/org-ctags
/home/politza/.emacs.d/usr/elpa/org-20170814/org-install hides /usr/share/emacs/25.3/lisp/org/org-install
/home/politza/.emacs.d/usr/elpa/org-20170814/org hides /usr/share/emacs/25.3/lisp/org/org
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-java hides /usr/share/emacs/25.3/lisp/org/ob-java
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-emacs-lisp hides /usr/share/emacs/25.3/lisp/org/ob-emacs-lisp
/home/politza/.emacs.d/usr/elpa/org-20170814/ox-man hides /usr/share/emacs/25.3/lisp/org/ox-man
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-scala hides /usr/share/emacs/25.3/lisp/org/ob-scala
/home/politza/.emacs.d/usr/elpa/org-20170814/ox-beamer hides /usr/share/emacs/25.3/lisp/org/ox-beamer
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-sqlite hides /usr/share/emacs/25.3/lisp/org/ob-sqlite
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-exp hides /usr/share/emacs/25.3/lisp/org/ob-exp
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-haskell hides /usr/share/emacs/25.3/lisp/org/ob-haskell
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-gnuplot hides /usr/share/emacs/25.3/lisp/org/ob-gnuplot
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-ruby hides /usr/share/emacs/25.3/lisp/org/ob-ruby
/home/politza/.emacs.d/usr/elpa/org-20170814/org-inlinetask hides /usr/share/emacs/25.3/lisp/org/org-inlinetask
/home/politza/.emacs.d/usr/elpa/org-20170814/org-timer hides /usr/share/emacs/25.3/lisp/org/org-timer
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-R hides /usr/share/emacs/25.3/lisp/org/ob-R
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-table hides /usr/share/emacs/25.3/lisp/org/ob-table
/home/politza/.emacs.d/usr/elpa/org-20170814/org-rmail hides /usr/share/emacs/25.3/lisp/org/org-rmail
/home/politza/.emacs.d/usr/elpa/org-20170814/org-element hides /usr/share/emacs/25.3/lisp/org/org-element
/home/politza/.emacs.d/usr/elpa/org-20170814/ob-fortran hides /usr/share/emacs/25.3/lisp/org/ob-fortran
/home/politza/.emacs.d/usr/elpa/org-20170814/org-faces hides /usr/share/emacs/25.3/lisp/org/org-faces

Features:
(shadow emacsbug sendmail ispell log-edit pcvs-util add-log edebug debug
dabbrev apropos nnir url-util url-parse url-vars shr-color color shr dom
browse-url preview prv-emacs tex-buf font-latex latex tex-ispell
tex-style tex-mode latexenc ox-odt rng-loc rng-uri rng-parse rng-match
rng-dt rng-util rng-pttrn nxml-parse nxml-ns nxml-enc xmltok nxml-util
ox-latex ox-icalendar ox-html table ox-ascii ox-publish ox flow-fill
sort smiley gnus-cite mm-archive mail-extr gnus-async gnus-bcklg qp
gnus-ml disp-table nndraft nnmh utf-7 network-stream nsm starttls
nnfolder nnnil gnus-agent gnus-srvr gnus-score score-mode nnvirtual
gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime dig mailcap nntp
gnus-cache gnus-sum gnus-group gnus-undo gnus-start gnus-cloud nnimap
nnmail mail-source tls gnutls utf7 netrc nnoo parse-time gnus-spec
gnus-int gnus-range message idna rfc822 mml mml-sec epg mm-decode
mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums
mailabbrev gmm-utils mailheader gnus-win gnus gnus-ems nnheader
mail-utils org-table pdf-sync pdf-annot pdf-outline pdf-links
pdf-history tabify eieio-opt speedbar sb-image ezimage dframe pulse
dired-aux smerge-mode whitespace vc vc-dispatcher misearch multi-isearch
company-oddmuse company-keywords company-etags company-gtags
company-dabbrev-code company-dabbrev company-files company-capf
company-cmake company-xcode company-clang company-semantic company-eclim
company-template company-css company-nxml company-bbdb racer thingatpt f
s etags xref project dash view tramp-cmds tramp-cache tramp-sh tramp
tramp-compat auth-source mm-util help-fns mail-prsvr tramp-loaddefs
trampver ucs-normalize shell filecache company rust-mode json map gud
ediff-merg ediff-wind ediff-diff ediff-mult ediff-help ediff-init
ediff-util ediff tex dbus xml crm pdf-occur ibuf-ext ibuffer tablist
tablist-filter semantic/wisent/comp semantic/wisent
semantic/wisent/wisent semantic/util-modes semantic/util semantic
semantic/tag semantic/lex semantic/fw eieio eieio-core cl-macs
mode-local cedet pdf-isearch let-alist pdf-misc imenu pdf-tools cus-edit
cus-start cus-load wid-edit pdf-view password-cache bookmark pp
pdf-cache pdf-info tq pdf-util restart-emacs desktop frameset
tsdh-dark-theme completion-dyninit edmacro kmacro man use-package
diminish bind-key rx server savehist vc-git diff-mode org-rmail org-mhe
org-irc org-info org-gnus gnus-util org-docview doc-view subr-x
jka-compr image-mode dired org-bibtex bibtex org-bbdb org-w3m
org-element cl-seq avl-tree org advice org-macro org-footnote
org-pcomplete pcomplete org-list org-faces org-entities noutline outline
easy-mmode org-version ob-emacs-lisp ob ob-tangle org-src ob-ref ob-lob
ob-table ob-keys ob-exp ob-comint ob-core ob-eval org-compat org-macs
org-loaddefs format-spec find-func cal-menu calendar cal-loaddefs
compile comint ansi-color ring finder-inf tex-site info package
epg-config seq byte-opt gv bytecomp byte-compile cl-extra help-mode
easymenu cconv cl-loaddefs pcase cl-lib time-date mule-util tooltip
eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
dbusbind inotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 644433 74788)
 (symbols 48 57971 0)
 (miscs 40 1356 1667)
 (strings 32 158027 13031)
 (string-bytes 1 5412591)
 (vectors 16 86481)
 (vector-slots 8 1967783 42765)
 (floats 8 1471 869)
 (intervals 56 8047 954)
 (buffers 976 95))

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#29007: 25.3; [PATCH] Make filecache use extended completion
  2017-10-26  6:56 bug#29007: 25.3; [PATCH] Make filecache use extended completion Andreas Politz
@ 2017-11-03  9:56 ` Eli Zaretskii
  2017-11-03 17:12   ` Andreas Politz
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2017-11-03  9:56 UTC (permalink / raw)
  To: Andreas Politz; +Cc: 29007

> From: Andreas Politz <politza@hochschule-trier.de>
> Date: Thu, 26 Oct 2017 08:56:16 +0200
> 
> As it is, file-cache-minibuffer-complete uses prefix completion via
> {try,all}-completion only, which makes it less convenient.  The patch
> below adds calls to completion-{try,all}-completion.

Can you please elaborate how this change makes the feature more
convenient?

Thanks.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#29007: 25.3; [PATCH] Make filecache use extended completion
  2017-11-03  9:56 ` Eli Zaretskii
@ 2017-11-03 17:12   ` Andreas Politz
  2017-11-03 19:19     ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Andreas Politz @ 2017-11-03 17:12 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 29007


Is there a reason why that function should keep using the ancient
completion mechanism ?

-ap





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#29007: 25.3; [PATCH] Make filecache use extended completion
  2017-11-03 17:12   ` Andreas Politz
@ 2017-11-03 19:19     ` Eli Zaretskii
  2017-11-04 17:44       ` Andreas Politz
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2017-11-03 19:19 UTC (permalink / raw)
  To: Andreas Politz; +Cc: 29007

> From: Andreas Politz <politza@hochschule-trier.de>
> Cc: 29007@debbugs.gnu.org
> Date: Fri, 03 Nov 2017 18:12:04 +0100
> 
> Is there a reason why that function should keep using the ancient
> completion mechanism ?

Sorry, I don't understand the implications of this question.

Your original report said the current code causes inconvenience, so
I'd like to understand more the nature of this inconvenience, and how
the modified code makes this feature more convenient.  I'm not saying
I'm opposed to your changes, I'm just asking for additional
information to make up my mind about it.

Thanks.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#29007: 25.3; [PATCH] Make filecache use extended completion
  2017-11-03 19:19     ` Eli Zaretskii
@ 2017-11-04 17:44       ` Andreas Politz
  2017-11-04 18:23         ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Andreas Politz @ 2017-11-04 17:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 29007


OK, I'll elaborate.

Currently, file-cache-minibuffer-complete does longest-prefix completion
via all-completions only, instead of completion-all-completions, which
completes according to the completion-styles variable.  And here are
some cases where this behavior is inconvenient or even insufficient,
when trying to open some file via `C-x C-f C-TAB'.

1. Opening some file from the file-cache, without remembering the exact
   prefix.

   Example: You only remember that the file ends in '-foo.el'.

2. Opening some file, while the file-cache contains many files having the
   same prefix.

   Example: The cache contains the following files.
   
   aaa.a
   aab.b
   aba.c
   abb.d
   baa.e
   bab.f
   bba.g
   bbb.h

   Here prefix completion is basically useless, but entering the unique
   suffix and using substring completion immediately completes to the
   unique match.

-ap





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#29007: 25.3; [PATCH] Make filecache use extended completion
  2017-11-04 17:44       ` Andreas Politz
@ 2017-11-04 18:23         ` Eli Zaretskii
  2017-11-04 19:31           ` Andreas Politz
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2017-11-04 18:23 UTC (permalink / raw)
  To: Andreas Politz; +Cc: 29007

> From: Andreas Politz <politza@hochschule-trier.de>
> Cc: 29007@debbugs.gnu.org
> Date: Sat, 04 Nov 2017 18:44:43 +0100
> 
> Currently, file-cache-minibuffer-complete does longest-prefix completion
> via all-completions only, instead of completion-all-completions, which
> completes according to the completion-styles variable.  And here are
> some cases where this behavior is inconvenient or even insufficient,
> when trying to open some file via `C-x C-f C-TAB'.
> 
> 1. Opening some file from the file-cache, without remembering the exact
>    prefix.
> 
>    Example: You only remember that the file ends in '-foo.el'.
> 
> 2. Opening some file, while the file-cache contains many files having the
>    same prefix.
> 
>    Example: The cache contains the following files.
>    
>    aaa.a
>    aab.b
>    aba.c
>    abb.d
>    baa.e
>    bab.f
>    bba.g
>    bbb.h
> 
>    Here prefix completion is basically useless, but entering the unique
>    suffix and using substring completion immediately completes to the
>    unique match.

Thanks.  I think your patch is good for the master branch, but I think
it should include a NEWS entry about the change.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#29007: 25.3; [PATCH] Make filecache use extended completion
  2017-11-04 18:23         ` Eli Zaretskii
@ 2017-11-04 19:31           ` Andreas Politz
  2017-11-04 19:48             ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Andreas Politz @ 2017-11-04 19:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 29007

[-- Attachment #1: Type: text/plain, Size: 196 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

> Thanks.  I think your patch is good for the master branch, but I think
> it should include a NEWS entry about the change.

Take a look and see if it's OK.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-diff, Size: 6694 bytes --]

diff --git a/etc/NEWS b/etc/NEWS
index 0dd6e36c70..c47ca42d27 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -103,6 +103,12 @@ less verbose by removing non-essential information.
 dimensions, instead of always using 16 pixels. As a result, Tetris,
 Snake and Pong are more playable on HiDPI displays.
 
+** Filecache
+
+---
+*** Completing filenames in the minibuffer via 'C-TAB' now uses the
+styles as configured by the variable 'completion-styles'.
+
 \f
 * New Modes and Packages in Emacs 27.1
 
diff --git a/lisp/filecache.el b/lisp/filecache.el
index 38a434b11b..aac4f488cd 100644
--- a/lisp/filecache.el
+++ b/lisp/filecache.el
@@ -566,68 +566,67 @@ file-cache-minibuffer-complete
 the name is considered already unique; only the second substitution
 \(directories) is done."
   (interactive "P")
-  (let*
-      (
-       (completion-ignore-case file-cache-completion-ignore-case)
-       (case-fold-search       file-cache-case-fold-search)
-       (string                 (file-name-nondirectory (minibuffer-contents)))
-       (completion-string      (try-completion string file-cache-alist))
-       (completion-list)
-       (len)
-       (file-cache-string))
+  (let* ((completion-ignore-case file-cache-completion-ignore-case)
+         (case-fold-search       file-cache-case-fold-search)
+         (string                 (file-name-nondirectory (minibuffer-contents)))
+         (completion             (completion-try-completion
+                                  string file-cache-alist nil 0)))
     (cond
      ;; If it's the only match, replace the original contents
-     ((or arg (eq completion-string t))
-      (setq file-cache-string (file-cache-file-name string))
-      (if (string= file-cache-string (minibuffer-contents))
-	  (minibuffer-message file-cache-sole-match-message)
-	(delete-minibuffer-contents)
-	(insert file-cache-string)
-	(if file-cache-multiple-directory-message
-	    (minibuffer-message file-cache-multiple-directory-message))))
+     ((or arg (eq completion t))
+      (let ((file-name (file-cache-file-name string)))
+        (if (string= file-name (minibuffer-contents))
+            (minibuffer-message file-cache-sole-match-message)
+          (delete-minibuffer-contents)
+          (insert file-name)
+          (if file-cache-multiple-directory-message
+              (minibuffer-message file-cache-multiple-directory-message)))))
 
      ;; If it's the longest match, insert it
-     ((stringp completion-string)
-      ;; If we've already inserted a unique string, see if the user
-      ;; wants to use that one
-      (if (and (string= string completion-string)
-	       (assoc-string string file-cache-alist
-			     file-cache-ignore-case))
-	  (if (and (eq last-command this-command)
-		   (string= file-cache-last-completion completion-string))
-	      (progn
-		(delete-minibuffer-contents)
-		(insert (file-cache-file-name completion-string))
-		(setq file-cache-last-completion nil))
-	    (minibuffer-message file-cache-non-unique-message)
-	    (setq file-cache-last-completion string))
-	(setq file-cache-last-completion string)
-	(setq completion-list (all-completions string file-cache-alist)
-	      len             (length completion-list))
-	(if (> len 1)
-	    (progn
-	      (goto-char (point-max))
-	      (insert
-	       (substring completion-string (length string)))
-	      ;; Add our own setup function to the Completions Buffer
-	      (let ((completion-setup-hook
-                     (append completion-setup-hook
-                             (list 'file-cache-completion-setup-function))))
-		(with-output-to-temp-buffer file-cache-completions-buffer
-		  (display-completion-list
-                   (completion-hilit-commonality completion-list
-                                                 (length string))))))
-	  (setq file-cache-string (file-cache-file-name completion-string))
-	  (if (string= file-cache-string (minibuffer-contents))
-	      (minibuffer-message file-cache-sole-match-message)
-	    (delete-minibuffer-contents)
-	    (insert file-cache-string)
-	    (if file-cache-multiple-directory-message
-		(minibuffer-message file-cache-multiple-directory-message)))
-	  )))
+     ((consp completion)
+      (let ((newstring (car completion))
+            (newpoint  (cdr completion)))
+        ;; If we've already inserted a unique string, see if the user
+        ;; wants to use that one
+        (if (and (string= string newstring)
+                 (assoc-string string file-cache-alist
+                               file-cache-ignore-case))
+            (if (and (eq last-command this-command)
+                     (string= file-cache-last-completion newstring))
+                (progn
+                  (delete-minibuffer-contents)
+                  (insert (file-cache-file-name newstring))
+                  (setq file-cache-last-completion nil))
+              (minibuffer-message file-cache-non-unique-message)
+              (setq file-cache-last-completion string))
+          (setq file-cache-last-completion string)
+          (let* ((completion-list (completion-all-completions
+                                   newstring file-cache-alist nil newpoint))
+                 (base-size       (cdr (last completion-list))))
+            (when base-size
+              (setcdr (last completion-list) nil))
+            (if (> (length completion-list) 1)
+                (progn
+                  (delete-region (- (point-max) (length string)) (point-max))
+                  (save-excursion (insert newstring))
+                  (forward-char newpoint)
+                  ;; Add our own setup function to the Completions Buffer
+                  (let ((completion-setup-hook
+                         (append completion-setup-hook
+                                 (list 'file-cache-completion-setup-function))))
+                    (with-output-to-temp-buffer file-cache-completions-buffer
+                      (display-completion-list
+                       (completion-hilit-commonality completion-list newpoint)))))
+              (let ((file-name (file-cache-file-name newstring)))
+                (if (string= file-name (minibuffer-contents))
+                    (minibuffer-message file-cache-sole-match-message)
+                  (delete-minibuffer-contents)
+                  (insert file-name)
+                  (if file-cache-multiple-directory-message
+                      (minibuffer-message file-cache-multiple-directory-message)))))))))
 
      ;; No match
-     ((eq completion-string nil)
+     ((eq completion nil)
       (minibuffer-message file-cache-no-match-message)))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

[-- Attachment #3: Type: text/plain, Size: 5 bytes --]


-ap

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#29007: 25.3; [PATCH] Make filecache use extended completion
  2017-11-04 19:31           ` Andreas Politz
@ 2017-11-04 19:48             ` Eli Zaretskii
  2017-11-04 20:53               ` Andreas Politz
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2017-11-04 19:48 UTC (permalink / raw)
  To: Andreas Politz; +Cc: 29007

> From: Andreas Politz <politza@hochschule-trier.de>
> Cc: 29007@debbugs.gnu.org
> Date: Sat, 04 Nov 2017 20:31:40 +0100
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > Thanks.  I think your patch is good for the master branch, but I think
> > it should include a NEWS entry about the change.
> 
> Take a look and see if it's OK.

LGTM, thanks.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#29007: 25.3; [PATCH] Make filecache use extended completion
  2017-11-04 19:48             ` Eli Zaretskii
@ 2017-11-04 20:53               ` Andreas Politz
  0 siblings, 0 replies; 9+ messages in thread
From: Andreas Politz @ 2017-11-04 20:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 29007


OK, I pushed it.

commit d3233b437eb8757e3c5abc1b50f100ea53ca9e15
Author: Andreas Politz <politza@hochschule-trier.de>
Date:   Thu Oct 26 08:59:05 2017 +0200

    Make filecache use extended completion
    
    * lisp/filecache.el (file-cache-minibuffer-complete): Use
    completion-try-completion and completion-all-completions.
    
    * etc/NEWS: Add news entry.


-ap





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-11-04 20:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-26  6:56 bug#29007: 25.3; [PATCH] Make filecache use extended completion Andreas Politz
2017-11-03  9:56 ` Eli Zaretskii
2017-11-03 17:12   ` Andreas Politz
2017-11-03 19:19     ` Eli Zaretskii
2017-11-04 17:44       ` Andreas Politz
2017-11-04 18:23         ` Eli Zaretskii
2017-11-04 19:31           ` Andreas Politz
2017-11-04 19:48             ` Eli Zaretskii
2017-11-04 20:53               ` Andreas Politz

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).