bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23842: 24.4; Runaway background process


From: npostavs
Subject: bug#23842: 24.4; Runaway background process
Date: Sat, 13 Aug 2016 22:36:53 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

tags 23842 patch
quit

Ian Perryman <iperryman@xtreme-eda.com> writes:

> I am not the author of the verilog mode. I have alerted the maintainer
> to the issue at
> http://www.veripool.org/issues/1070-Verilog-mode-Auto-completion-results-in-runaway-emacs-process-in-emacs-24-4-on-Debian-using-2016-04-23-5f6855e-vpo
>
> Not sure what the intended behaviour is. My guess is that the list of
> possible completions was to be presented in the temporary buffer, and
> then user could select the completion they wanted with a mouse click
> and it should be inserted back in the original buffer.
>
> Did the definition of with-output-to-temp-buffer change over the
> years? I am not certain when this code was developed, but it was quite
> a while back. I am surprised that no one else has complained about it.

Probably most Emacs users don't use the mouse much.

>
> Perhaps the paradigm for completion is not being followed by this mode?
>
> Any suggestions?

I can't really figure out how that completion window code is supposed to
work, but it seems to be duplicating completion-at-point functionality.
Patch below just replaces most of it with completion-at-point and it
seems to work fine.  But I see at the top of the file

;;    This code supports Emacs 21.1 and later
;;    And XEmacs 21.1 and later
;;    Please do not make changes that break Emacs 21.  Thanks!

So it may need some adjustments for Emacs 21...

>From ed885f166108945b8e99d09feaac53ee470a3f2c Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sat, 13 Aug 2016 22:13:56 -0400
Subject: [PATCH v1] Use completion-at-point in verilog-mode

There were some functions in verilog-mode that implemented in-buffer
completion, but this needlessly duplicates completion-at-point
functionality, and the popup window management had problems
(see Bug #23842).

* lisp/progmodes/verilog-mode.el (verilog-toggle-completions): Mark
obsolete, it does the same job as `completion-cycle-threshold'.
(verilog-completion-at-point): New function.
(verilog-show-completions): Remove, replace calls with
`completion-help-at-point'.
(verilog-complete-word): Remove, replace calls with `completion-at-point'.
---
 lisp/progmodes/verilog-mode.el | 109 +++++++++--------------------------------
 1 file changed, 23 insertions(+), 86 deletions(-)

diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el
index fd2e96a..e5b9ee8 100644
--- a/lisp/progmodes/verilog-mode.el
+++ b/lisp/progmodes/verilog-mode.el
@@ -1374,8 +1374,8 @@ verilog-mode-map
     (define-key map "\M-\C-b"  'electric-verilog-backward-sexp)
     (define-key map "\M-\C-f"  'electric-verilog-forward-sexp)
     (define-key map "\M-\r"    `electric-verilog-terminate-and-indent)
-    (define-key map "\M-\t"    'verilog-complete-word)
-    (define-key map "\M-?"     'verilog-show-completions)
+    (define-key map "\M-\t"    'completion-at-point)
+    (define-key map "\M-?"     'completion-help-at-point)
     ;; Note \C-c and letter are reserved for users
     (define-key map "\C-c`"    'verilog-lint-off)
     (define-key map "\C-c*"    'verilog-delete-auto-star-implicit)
@@ -1498,7 +1498,7 @@ verilog-mode-map
       :help            "Take a signal vector on the current line and expand it 
to multiple lines"]
      ["Insert begin-end block"         verilog-insert-block
       :help            "Insert begin ... end"]
-     ["Complete word"                  verilog-complete-word
+     ["Complete word"                  completion-at-point
       :help            "Complete word at point"]
      "----"
      ["Recompute AUTOs"                        verilog-auto
@@ -3762,7 +3762,7 @@ verilog-mode
 
 Some other functions are:
 
-    \\[verilog-complete-word]    Complete word with appropriate possibilities.
+    \\[completion-at-point]    Complete word with appropriate possibilities.
     \\[verilog-mark-defun]  Mark function.
     \\[verilog-beg-of-defun]  Move to beginning of current function.
     \\[verilog-end-of-defun]  Move to end of current function.
@@ -3876,6 +3876,9 @@ verilog-mode
                                       verilog-forward-sexp-function)
                  hs-special-modes-alist))))
 
+  (add-hook 'completion-at-point-functions
+            #'verilog-completion-at-point nil 'local)
+
   ;; Stuff for autos
   (add-hook 'write-contents-hooks 'verilog-auto-save-check nil 'local)
   ;; verilog-mode-hook call added by define-derived-mode
@@ -7143,10 +7146,9 @@ verilog-pred
 (defvar verilog-buffer-to-use nil)
 (defvar verilog-flag nil)
 (defvar verilog-toggle-completions nil
-  "True means \\<verilog-mode-map>\\[verilog-complete-word] should try all 
possible completions one by one.
-Repeated use of \\[verilog-complete-word] will show you all of them.
-Normally, when there is more than one possible completion,
-it displays a list of all possible completions.")
+  "Obsolete, use `completion-cycle-threshold' instead.")
+(make-obsolete-variable
+ 'verilog-toggle-completions 'completion-cycle-threshold "25.2")
 
 
 (defvar verilog-type-keywords
@@ -7429,85 +7431,20 @@ verilog-last-word-numb
 (defvar verilog-last-word-shown nil)
 (defvar verilog-last-completions nil)
 
-(defun verilog-complete-word ()
-  "Complete word at current point.
-\(See also `verilog-toggle-completions', `verilog-type-keywords',
-and `verilog-separator-keywords'.)"
-  ;; FIXME: Provide completion-at-point-function.
-  (interactive)
-  (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point)))
-        (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point)))
-        (verilog-str (buffer-substring b e))
-        ;; The following variable is used in verilog-completion
-        (verilog-buffer-to-use (current-buffer))
-        (allcomp (if (and verilog-toggle-completions
-                          (string= verilog-last-word-shown verilog-str))
-                     verilog-last-completions
-                   (all-completions verilog-str 'verilog-completion)))
-        (match (if verilog-toggle-completions
-                   "" (try-completion
-                       verilog-str (mapcar (lambda (elm)
-                                             (cons elm 0)) allcomp)))))
-    ;; Delete old string
-    (delete-region b e)
-
-    ;; Toggle-completions inserts whole labels
-    (if verilog-toggle-completions
-       (progn
-         ;; Update entry number in list
-         (setq verilog-last-completions allcomp
-               verilog-last-word-numb
-               (if (>= verilog-last-word-numb (1- (length allcomp)))
-                   0
-                 (1+ verilog-last-word-numb)))
-         (setq verilog-last-word-shown (elt allcomp verilog-last-word-numb))
-         ;; Display next match or same string if no match was found
-         (if (not (null allcomp))
-             (insert "" verilog-last-word-shown)
-           (insert "" verilog-str)
-           (message "(No match)")))
-      ;; The other form of completion does not necessarily do that.
-
-      ;; Insert match if found, or the original string if no match
-      (if (or (null match) (equal match 't))
-         (progn (insert "" verilog-str)
-                (message "(No match)"))
-       (insert "" match))
-      ;; Give message about current status of completion
-      (cond ((equal match 't)
-            (if (not (null (cdr allcomp)))
-                (message "(Complete but not unique)")
-              (message "(Sole completion)")))
-           ;; Display buffer if the current completion didn't help
-           ;; on completing the label.
-           ((and (not (null (cdr allcomp))) (= (length verilog-str)
-                                               (length match)))
-            (with-output-to-temp-buffer "*Completions*"
-              (display-completion-list allcomp))
-            ;; Wait for a key press. Then delete *Completion*  window
-            (momentary-string-display "" (point))
-            (delete-window (get-buffer-window (get-buffer "*Completions*")))
-            )))))
-
-(defun verilog-show-completions ()
-  "Show all possible completions at current point."
-  (interactive)
+(defun verilog-completion-at-point ()
+  "Used as an element of `completion-at-point-functions'.
+\(See also `verilog-type-keywords' and
+`verilog-separator-keywords'.)"
   (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point)))
-        (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point)))
-        (verilog-str (buffer-substring b e))
-        ;; The following variable is used in verilog-completion
-        (verilog-buffer-to-use (current-buffer))
-        (allcomp (if (and verilog-toggle-completions
-                          (string= verilog-last-word-shown verilog-str))
-                     verilog-last-completions
-                   (all-completions verilog-str 'verilog-completion))))
-    ;; Show possible completions in a temporary buffer.
-    (with-output-to-temp-buffer "*Completions*"
-      (display-completion-list allcomp))
-    ;; Wait for a key press. Then delete *Completion*  window
-    (momentary-string-display "" (point))
-    (delete-window (get-buffer-window (get-buffer "*Completions*")))))
-
+         (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point)))
+         (verilog-str (buffer-substring b e))
+         ;; The following variable is used in verilog-completion
+         (verilog-buffer-to-use (current-buffer))
+         (allcomp (if (and verilog-toggle-completions
+                           (string= verilog-last-word-shown verilog-str))
+                      verilog-last-completions
+                    (all-completions verilog-str 'verilog-completion))))
+    (list b e allcomp)))
 
 (defun verilog-get-default-symbol ()
   "Return symbol around current point as a string."
-- 
2.9.2


reply via email to

[Prev in Thread] Current Thread [Next in Thread]