rnkn / fountain-mode

Emacs major mode for screenwriting in Fountain plain-text markup
https://fountain-mode.org
GNU General Public License v3.0
391 stars 16 forks source link

Character name completion dupplicates #116

Closed alienbogart closed 4 years ago

alienbogart commented 4 years ago

My Environment

Issue

Whenever a character has more than one line in a script, using fountain-dwim (via TAB) to complete it (after typing one or two letters) will render a bunch of identical completions.

So with this text:

DRIVER
You.

The unmoved face of Death.

DRIVER
Some people hate doing this. They think it's a sacrifice, and that I'm poor. Not me. I always wanted to be a bus driver, like the old man.

The unmoved face of Death.

DRIVER
I traveled with him sometimes. He let me drive, sat on his lap. The truck life is simple: just you and the road.

I get this: fountain_shot

Since they're identical, the completion should only display a single option.

rnkn commented 4 years ago

Please attempt to reproduce this with emacs -Q and M-x load-file RET [PATH TO FILE]

alienbogart commented 4 years ago

That works! I have no idea what might be cause this, though. The issue persists even if I remove all my fountain configurations.

rnkn commented 4 years ago

Looks like you're using company? How'd you get this to work with fountain-mode?

Apply this patch and let me know if it works:

diff --git a/fountain-mode.el b/fountain-mode.el
index 51192d3..53641eb 100644
--- a/fountain-mode.el
+++ b/fountain-mode.el
@@ -1165,17 +1165,13 @@ important."
           contd-character (car scene-characters)
           rest-characters (cddr scene-characters)
           scene-characters nil)
-    (when rest-characters
-      (setq scene-characters rest-characters))
-    (when contd-character
-      (setq scene-characters
-            (cons contd-character scene-characters)))
-    (when alt-character
-      (setq scene-characters
-            (cons alt-character scene-characters)))
-    (append scene-characters
-            fountain-completion-additional-characters
-            fountain--completion-characters)))
+    (when rest-characters (setq scene-characters rest-characters))
+    (when contd-character (push contd-character scene-characters))
+    (when alt-character (push alt-character scene-characters))
+    (delete-dups
+     (append scene-characters
+             fountain-completion-additional-characters
+             (mapcar 'car fountain--completion-characters)))))

 (defun fountain-completion-at-point ()
   "\\<fountain-mode-map>Return completion table for entity at point.
alienbogart commented 4 years ago

Looks like you're using company? How'd you get this to work with fountain-mode?

Apply this patch and let me know if it works:

diff --git a/fountain-mode.el b/fountain-mode.el
index 51192d3..53641eb 100644
--- a/fountain-mode.el
+++ b/fountain-mode.el
@@ -1165,17 +1165,13 @@ important."
           contd-character (car scene-characters)
           rest-characters (cddr scene-characters)
           scene-characters nil)
-    (when rest-characters
-      (setq scene-characters rest-characters))
-    (when contd-character
-      (setq scene-characters
-            (cons contd-character scene-characters)))
-    (when alt-character
-      (setq scene-characters
-            (cons alt-character scene-characters)))
-    (append scene-characters
-            fountain-completion-additional-characters
-            fountain--completion-characters)))
+    (when rest-characters (setq scene-characters rest-characters))
+    (when contd-character (push contd-character scene-characters))
+    (when alt-character (push alt-character scene-characters))
+    (delete-dups
+     (append scene-characters
+             fountain-completion-additional-characters
+             (mapcar 'car fountain--completion-characters)))))

 (defun fountain-completion-at-point ()
   "\\<fountain-mode-map>Return completion table for entity at point.

Company is not enabled for Fountain Mode. But I'll try your solution and give feedback.

rnkn commented 4 years ago

What's giving you the dropdown completion candidates in your screenshot?

alienbogart commented 4 years ago

What's giving you the dropdown completion candidates in your screenshot?

  1. Type first letter(s) of character name
  2. Hit Tab