GNU bug report logs - #17284
24.3.90; Host name completion in shell mode take 45 seconds

Previous Next

Package: emacs;

Reported by: Svend Sorensen <svend <at> ciffer.net>

Date: Thu, 17 Apr 2014 17:49:02 UTC

Severity: normal

Found in version 24.3.90

Done: Nicolas Richard <theonewiththeevillook <at> yahoo.fr>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Drew Adams <drew.adams <at> oracle.com>
To: Svend Sorensen <svend <at> ciffer.net>, Nicolas Richard <theonewiththeevillook <at> yahoo.fr>
Cc: 17284 <at> debbugs.gnu.org
Subject: bug#17284: Host name completion in shell mode take 45 seconds
Date: Fri, 3 Apr 2015 09:25:04 -0700 (PDT)
> > > Does it help to replace (looking-back ",") by (eq ?, (char-before)) ?
> > 
> > The function runs quickly with that change.
>
> Couldn't the byte-compiler warn when `looking-back' is used without
> specifying LIMIT?  Making LIMIT non-optional seems too harsh.

1. Is it really about LIMIT?  Or is it instead about looking back
   at a literal string of chars?  And typically a short string.
   I'm guessing that that is the use case to pursue here.

2. Instead of (or in addition to) a byte-compiler warning for
   `looking-back', how about adding a function `chars-before'?

Since I use multiple Emacs versions, some quite old, I use this.
But I'm sure that a much better (including prettier) definition
can be had for recent Emacs.  Or (better) define it in C.

(defun chars-before (chars)
  "Return non-nil if the literal string CHARS is right before point."
  (let* ((len  (length chars))
         (idx  (1- len))
         (pt   (point)))
    (catch 'chars-before
      (dolist (char  (append chars ()))
        (unless (condition-case nil
                    (eq char (char-before (- pt idx)))
                  (error nil))
          (throw 'chars-before nil))
        (setq idx  (1- idx)))
      t)))

Likewise (but may be no better than `looking-at' + `regexp-quote'):

(defun chars-after (chars)
  "Return non-nil if the literal string CHARS is right after point."
  (let* ((len  (length chars))
         (idx  (1- len))
         (pt   (point)))
    (catch 'chars-after
      (dolist (char  (nreverse (append chars ())))
        (unless (condition-case nil
                    (eq char (char-after (+ pt idx)))
                  (error nil))          ; e.g. `eobp'
          (throw 'chars-after nil))
        (setq idx  (1- idx)))
      t)))




This bug report was last modified 9 years and 144 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.