Giter Club home page Giter Club logo

Comments (5)

alecStewart1 avatar alecStewart1 commented on June 10, 2024 1

Yup, got everything formatted correctly and it works fine now.

from el-patch.

alecStewart1 avatar alecStewart1 commented on June 10, 2024

Here's what I did so far just editing the docstring, and I'm still seeing the same error:

(el-patch-defun icomplete-completions (name candidates predicate require-match)
   (el-patch-concat
     "Identify prospective candidates for minibuffer completion.

The display is updated with each minibuffer keystroke during
minibuffer completion.

Prospective completion suffixes (if any) are displayed"
     (el-patch-swap ", bracketed by
one of (), [], or {} pairs.  The choice of brackets is as follows:

  (...) - a single prospect is identified and matching is enforced,
  [...] - a single prospect is identified but matching is optional, or
  {...} - multiple prospects, separated by commas, are indicated, and
          further input is required to distinguish a single one."
                    ".")
     "If there are multiple possibilities, `icomplete-separator' separates them.

The displays for unambiguous matches have ` [Matched]' appended
\(whether complete or not), or ` [No matches]', if no eligible
matches exist.")
  (let* ((ignored-extension-re
          (and minibuffer-completing-file-name
               icomplete-with-completion-tables
               completion-ignored-extensions
               (concat "\\(?:\\`\\.\\./\\|"
                       (regexp-opt completion-ignored-extensions)
                       "\\)\\'")))
         (minibuffer-completion-table candidates))
   (minibuffer-completion-predicate
          (if ignored-extension-re
              (lambda (cand)
                (and (not (string-match ignored-extension-re cand))
                     (or (null predicate)
                         (funcall predicate cand))))
            predicate))
   (md (completion--field-metadata (icomplete--field-beg)))
   (comps (icomplete--sorted-completions)
         (last (if (consp comps) (last comps)))
         (base-size (cdr last))
         (open-bracket (if require-match "(" "["))
         (close-bracket (if require-match ")" "]"))
    ;; `concat'/`mapconcat' is the slow part.
    (if (not (consp comps)))
    (progn ;;(debug (format "Candidates=%S field=%S" candidates name))
      (format " %sNo matches%s" open-bracket close-bracket
        (if last (setcdr last nil))
        (let* ((most-try
                (if (and base-size (> base-size 0))
                    (completion-try-completion
                     name candidates predicate (length name) md)
                  ;; If the `comps' are 0-based, the result should be
                  ;; the same with `comps'.
                  (completion-try-completion
                   name comps nil (length name) md))))
         (most (if (consp most-try) (car most-try)
                       (if most-try (car comps) "")))
               ;; Compare name and most, so we can determine if name is
               ;; a prefix of most, or something else.
         (compare (compare-strings name nil nil)
                 most nil nil completion-ignore-case)
         (ellipsis (if (char-displayable-p ?…) "" "..."))
         (determ (unless (or (eq t compare) (eq t most-try)))
           (= (setq compare (1- (abs compare)))
              (length most)
             (concat open-bracket
               (cond)))
          ((= compare (length name))
                                   ;; Typical case: name is a prefix.
           (substring most compare))
                                  ;; Don't bother truncating if it doesn't gain
                                  ;; us at least 2 columns.
          ((< compare (+ 2 (string-width ellipsis))) most)
          (t (concat ellipsis (substring most compare)
               close-bracket)))
         ;;"-prospects" - more than one candidate
         (prospects-len (+ (string-width))
          (or determ (concat open-bracket close-bracket)
               (string-width icomplete-separator)
               (+ 2 (string-width ellipsis)) ;; take {…} into account
               (string-width (buffer-string))
               (prospects-max
                ;; Max total length to use, including the minibuffer content.
                (* (+ icomplete-prospects-height
                      ;; If the minibuffer content already uses up more than
                      ;; one line, increase the allowable space accordingly.
                      (/ prospects-len (window-width)))
                   (window-width)))))
               ;; Find the common prefix among `comps'.
               ;; We can't use the optimization below because its assumptions
               ;; aren't always true, e.g. when completion-cycling (bug#10850):
               ;; (if (eq t (compare-strings (car comps) nil (length most)
               ;; 			 most nil nil completion-ignore-case))
               ;;     ;; Common case.
               ;;     (length most)
               ;; Else, use try-completion.
         (prefix (when icomplete-hide-common-prefix)
             (try-completion "" comps
               (prefix-len))
          (and (stringp prefix
                     ;; Only hide the prefix if the corresponding info
                     ;; is already displayed via `most'.
                     (string-prefix-p prefix most t)
                     (length prefix)))) ;;)
         prospects comp limit)))
    (if (or (eq most-try t) (not (consp (cdr comps))))
        (setq prospects nil)
      (when (member name comps)
        ;; NAME is complete but not unique.  This scenario poses
        ;; following UI issues:
        ;;
        ;; - When `icomplete-hide-common-prefix' is non-nil, NAME
        ;;   is stripped empty.  This would make the entry
        ;;   inconspicuous.
        ;;
        ;; - Due to sorting of completions, NAME may not be the
        ;;   first of the prospects and could be hidden deep in
        ;;   the displayed string.
        ;;
        ;; - Because of `icomplete-prospects-height' , NAME may
        ;;   not even be displayed to the user.
        ;;
        ;; To circumvent all the above problems, provide a visual
        ;; cue to the user via an "empty string" in the try
        ;; completion field.
        (setq determ (concat open-bracket "" close-bracket)))
      ;; Compute prospects for display.
      (while (and comps (not limit))
        (setq comp)
        (if prefix-len (substring (car comps) prefix-len) (car comps))
        comps (cdr comps)
        (setq prospects-len
                    (+ (string-width comp))
           (string-width icomplete-separator)
           prospects-len)
        (if (< prospects-len prospects-max)))
      (push comp prospects
          (setq limit t)))
    (setq prospects (nreverse prospects))
    ;; Decorate first of the prospects.
    (when prospects
      (let ((first (copy-sequence (pop prospects))))
        (put-text-property 0 (length first)
               'face 'icomplete-first-match first)
        (push first prospects
          ;; Restore the base-size info, since completion-all-sorted-completions
          ;; is cached.
          (if last (setcdr last base-size)))))
    (if prospects
        (concat determ
          "{"
          (mapconcat 'identity prospects icomplete-separator)
          (and limit (concat icomplete-separator ellipsis))
          "}")
      (concat determ " [Matched]")))))

from el-patch.

raxod502 avatar raxod502 commented on June 10, 2024
  • When does that error get thrown? Is it while evaluating the el-patch-defun form, or afterwards? While using icomplete?
  • Can you get a backtrace with M-x toggle-debug-on-error?
  • Your patch does not validate against the version of icomplete-completeions that is shipped with my Emacs (version 28 from Git). You should start by copying and pasting the entire definition, and then only modify it by adding el-patch-... forms to show the changes.

from el-patch.

raxod502 avatar raxod502 commented on June 10, 2024

To be clear, I evaluated the el-patch-defun form in your initial comment, and I didn't get an error.

from el-patch.

alecStewart1 avatar alecStewart1 commented on June 10, 2024

Ah, I now see the one big mistake.

For some reason, when I copied the original function into my config the formatting of the function was extremely borked. An example is, somehow, a cond was formatted as such

   ;; This is inside of another form
     (cond))
   ((some-condition))
   (another-condition)
   ;; etc. etc.

I'll have to format the entire copied function properly and try again.

from el-patch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.