all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Some help with icomplete
@ 2024-04-15 17:30 Rahul Martim Juliato
  2024-04-16  7:46 ` Zhengyi Fu
  0 siblings, 1 reply; 5+ messages in thread
From: Rahul Martim Juliato @ 2024-04-15 17:30 UTC (permalink / raw)
  To: help-gnu-emacs

Hello there!


I've been strugling with something I can see as possible but am sure it
is not obvious (at least not for me).


On plain emacs if I use `icomplete-vertical-mode' with
`icomplete-in-buffer' set to t, I get a "company/corfu like" completion
"in buffer" feature.


Thing is, the list always starts on the next line (that is ok) but on
the first column. So it is very strange to M-TAB with the cursor on
column 50 and get a list on column 0. If I were using plain
`icomplete-mode' (no vertical), it would complete horizontally from the
place my cursor is at the moment.

Can anyone elucidate me on how to make it work the way I'd like to?


Some screenshots to illustrate it:

With vertical mode on the beginning of the line

https://0x0.st/X-Ue.png

With vertical mode on some advanced column

http://0x0.st/X-U2.png

Without vertical mode on the beginning of the line

http://0x0.st/X-U_.png

Without vertical mode on some advanced column

http://0x0.st/X-UL.png


Thanks!

Rahul M. Juliato



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

* Re: Some help with icomplete
  2024-04-15 17:30 Some help with icomplete Rahul Martim Juliato
@ 2024-04-16  7:46 ` Zhengyi Fu
  2024-04-16 12:40   ` Eli Zaretskii
  2024-04-16 14:18   ` Rahul Martim Juliato
  0 siblings, 2 replies; 5+ messages in thread
From: Zhengyi Fu @ 2024-04-16  7:46 UTC (permalink / raw)
  To: Rahul Martim Juliato; +Cc: help-gnu-emacs

Rahul Martim Juliato <rahuljuliato@gmail.com> writes:

> Thing is, the list always starts on the next line (that is ok) but on
> the first column. So it is very strange to M-TAB with the cursor on
> column 50 and get a list on column 0. If I were using plain
> `icomplete-mode' (no vertical), it would complete horizontally from the
> place my cursor is at the moment.
>
> Can anyone elucidate me on how to make it work the way I'd like to?

If you compile Emacs from source, you can try this patch:

Index: emacs/lisp/icomplete.el
===================================================================
--- emacs.orig/lisp/icomplete.el
+++ emacs/lisp/icomplete.el
@@ -913,6 +913,16 @@ icomplete--render-vertical
                  ((> (length scroll-above) (length scroll-below)) nsections)
                  (t (min (ceiling nsections 2) (length scroll-above))))
            lines))
+    (when icomplete--in-region-buffer
+      (let ((column
+	     (with-current-buffer icomplete--in-region-buffer
+	       (save-excursion
+		 (goto-char (car completion-in-region--data))
+		 (current-column)))))
+	(dolist (l lines)
+	  (add-text-properties
+           0 1 `(display ,(concat (make-string column ?\s) (substring l 0 1)))
+           l))))
     ;; At long last, render final string return value.  This may still
     ;; kick out lines at the end.
     (concat " \n"

-- 
Zhengyi Fu



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

* Re: Some help with icomplete
  2024-04-16  7:46 ` Zhengyi Fu
@ 2024-04-16 12:40   ` Eli Zaretskii
  2024-04-16 14:18   ` Rahul Martim Juliato
  1 sibling, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2024-04-16 12:40 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Zhengyi Fu <i@fuzy.me>
> Cc: help-gnu-emacs@gnu.org
> Date: Tue, 16 Apr 2024 15:46:56 +0800
> 
> Rahul Martim Juliato <rahuljuliato@gmail.com> writes:
> 
> > Thing is, the list always starts on the next line (that is ok) but on
> > the first column. So it is very strange to M-TAB with the cursor on
> > column 50 and get a list on column 0. If I were using plain
> > `icomplete-mode' (no vertical), it would complete horizontally from the
> > place my cursor is at the moment.
> >
> > Can anyone elucidate me on how to make it work the way I'd like to?
> 
> If you compile Emacs from source, you can try this patch:
> 
> Index: emacs/lisp/icomplete.el
> ===================================================================
> --- emacs.orig/lisp/icomplete.el
> +++ emacs/lisp/icomplete.el

Since icomplete.el is not preloaded, applying this patch does not
require rebuilding Emacs from sources.  It only requires
byte-compiling icomplete.el after patching it, and perhaps restarting
Emacs.



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

* Re: Some help with icomplete
  2024-04-16  7:46 ` Zhengyi Fu
  2024-04-16 12:40   ` Eli Zaretskii
@ 2024-04-16 14:18   ` Rahul Martim Juliato
  2024-04-17  4:57     ` Zhengyi Fu
  1 sibling, 1 reply; 5+ messages in thread
From: Rahul Martim Juliato @ 2024-04-16 14:18 UTC (permalink / raw)
  To: Zhengyi Fu; +Cc: Rahul Martim Juliato, help-gnu-emacs

Zhengyi Fu <i@fuzy.me> writes:

> Rahul Martim Juliato <rahuljuliato@gmail.com> writes:
>
>> Thing is, the list always starts on the next line (that is ok) but on
>> the first column. So it is very strange to M-TAB with the cursor on
>> column 50 and get a list on column 0. If I were using plain
>> `icomplete-mode' (no vertical), it would complete horizontally from the
>> place my cursor is at the moment.
>>
>> Can anyone elucidate me on how to make it work the way I'd like to?
>
> If you compile Emacs from source, you can try this patch:
>
> Index: emacs/lisp/icomplete.el
> ===================================================================
> --- emacs.orig/lisp/icomplete.el
> +++ emacs/lisp/icomplete.el
> @@ -913,6 +913,16 @@ icomplete--render-vertical
>                   ((> (length scroll-above) (length scroll-below)) nsections)
>                   (t (min (ceiling nsections 2) (length scroll-above))))
>             lines))
> +    (when icomplete--in-region-buffer
> +      (let ((column
> +	     (with-current-buffer icomplete--in-region-buffer
> +	       (save-excursion
> +		 (goto-char (car completion-in-region--data))
> +		 (current-column)))))
> +	(dolist (l lines)
> +	  (add-text-properties
> +           0 1 `(display ,(concat (make-string column ?\s) (substring l 0 1)))
> +           l))))
>      ;; At long last, render final string return value.  This may still
>      ;; kick out lines at the end.
>      (concat " \n"

Thank you Zhengyi!

This worked like a charm!

Is this already suggested as a patch to Emacs core?

Even if optional, I believe Emacs would greatly benefit from it.


Rahul M. Juliato



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

* Re: Some help with icomplete
  2024-04-16 14:18   ` Rahul Martim Juliato
@ 2024-04-17  4:57     ` Zhengyi Fu
  0 siblings, 0 replies; 5+ messages in thread
From: Zhengyi Fu @ 2024-04-17  4:57 UTC (permalink / raw)
  To: Rahul Martim Juliato; +Cc: help-gnu-emacs

Rahul Martim Juliato <rahuljuliato@gmail.com> writes:
>
> Is this already suggested as a patch to Emacs core?
>
> Even if optional, I believe Emacs would greatly benefit from it.
>

No.  I didn't submit it to Emacs core.

I don't use icomplete-vertical-mode anymore.

This patch was just a quick hack and I don't think it's the best way to
implement this feature.

-- 
Zhengyi Fu



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

end of thread, other threads:[~2024-04-17  4:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-15 17:30 Some help with icomplete Rahul Martim Juliato
2024-04-16  7:46 ` Zhengyi Fu
2024-04-16 12:40   ` Eli Zaretskii
2024-04-16 14:18   ` Rahul Martim Juliato
2024-04-17  4:57     ` Zhengyi Fu

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.