* complete file at point in buffer - solution and questions
@ 2010-05-18 19:37 Dirk80
2010-05-19 4:48 ` Kevin Rodgers
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Dirk80 @ 2010-05-18 19:37 UTC (permalink / raw)
To: Help-gnu-emacs
Hello,
in minibuffer it is easy to complete a file at point. Just press tab if you
don't know how to continue. But when I was looking in internet if this
feature is also available for a normal buffer I did not find a solution. So
I decided to write one on my own.
Because I am an emacs lisp newbie I am happy that the implementation is
working.
You need these 2 files:
http://www.dirkundsari.de/emacs/my/my-cfap.el
http://www.dirkundsari.de/emacs/my/my-cfap.el
http://www.dirkundsari.de/emacs/my/my-utils.el
http://www.dirkundsari.de/emacs/my/my-utils.el
Bind the function my-cfap-complete to a key (e.g. f3) and then you can use
it in a normal buffer to complete files.
But now I also have some questions:
1.) Please give me feedback to my code. So I can learn.
2.) File completion in minibuffer shows the completion-buffer with bold
letters at the first difference. How could I integrate that feature in my
code when calling display-completion-list? I've looked a bit into the code
of minibuffer.el. It seems that "defface completions-first-difference" is
what I need. But I do not understand how to use it. The function
display-completion-list has an optional parameter common-substring. But this
is described obsolete.
3.) In unix the file system is case sensitive. In windows OS the file system
is not case sensitive. But my function is always case sensitive. How can I
say that when emacs is running in windows that case does not matter. I think
that I have to say to the C-Source functions "file-name-completion" and
"file-name-all-completions" that they should be not case sensitive when
emacs is running in windows. But I do not know how to do it.
4.) I would like to change the behaviour of the self-insert-command if a
completion window is available. So I tried to use defadvice with
self-insert-command. But it was not working. And I have also read that
defadvice is more a debugging feature and should not be used in productive
code. So what would be an alternative? I'd like to have the following
behaviour for self-insert-command:
If completion-window available then insert character and update
completion-window.
Thank you very much for your help
Dirk
--
View this message in context: http://old.nabble.com/complete-file-at-point-in-buffer---solution-and-questions-tp28599706p28599706.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: complete file at point in buffer - solution and questions
2010-05-18 19:37 complete file at point in buffer - solution and questions Dirk80
@ 2010-05-19 4:48 ` Kevin Rodgers
2010-05-19 11:30 ` Dirk80
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Kevin Rodgers @ 2010-05-19 4:48 UTC (permalink / raw)
To: help-gnu-emacs
Dirk80 wrote:
> Hello,
>
> in minibuffer it is easy to complete a file at point. Just press tab if you
> don't know how to continue. But when I was looking in internet if this
> feature is also available for a normal buffer I did not find a solution. So
> I decided to write one on my own.
Take a look at http://www.emacswiki.org/emacs/CategoryCompletion#toc2 for
other contributions.
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: complete file at point in buffer - solution and questions
2010-05-18 19:37 complete file at point in buffer - solution and questions Dirk80
2010-05-19 4:48 ` Kevin Rodgers
@ 2010-05-19 11:30 ` Dirk80
2010-05-19 12:53 ` Gary .
2010-05-19 11:46 ` Dirk80
[not found] ` <mailman.2.1274268970.19035.help-gnu-emacs@gnu.org>
3 siblings, 1 reply; 6+ messages in thread
From: Dirk80 @ 2010-05-19 11:30 UTC (permalink / raw)
To: Help-gnu-emacs
> 3.) In unix the file system is case sensitive. In windows OS the file
> system is not case sensitive. But my function is always case sensitive.
> How can I say that when emacs is running in windows that case does not
> matter. I think that I have to say to the C-Source functions
> "file-name-completion" and "file-name-all-completions" that they should be
> not case sensitive when emacs is running in windows. But I do not know how
> to do it.
>
For this problem I found the solution:
(let ((completion-ignore-case (memq system-type '(ms-dos windows-nt
cygwin))))
...)
--
View this message in context: http://old.nabble.com/complete-file-at-point-in-buffer---solution-and-questions-tp28599706p28606928.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: complete file at point in buffer - solution and questions
2010-05-18 19:37 complete file at point in buffer - solution and questions Dirk80
2010-05-19 4:48 ` Kevin Rodgers
2010-05-19 11:30 ` Dirk80
@ 2010-05-19 11:46 ` Dirk80
[not found] ` <mailman.2.1274268970.19035.help-gnu-emacs@gnu.org>
3 siblings, 0 replies; 6+ messages in thread
From: Dirk80 @ 2010-05-19 11:46 UTC (permalink / raw)
To: Help-gnu-emacs
Dirk80 wrote:
>
> 2.) File completion in minibuffer shows the completion-buffer with bold
> letters at the first difference. How could I integrate that feature in my
> code when calling display-completion-list? I've looked a bit into the code
> of minibuffer.el. It seems that "defface completions-first-difference" is
> what I need. But I do not understand how to use it. The function
> display-completion-list has an optional parameter common-substring. But
> this is described obsolete.
>
Ok, here I also found a solution. The common-substring is stored in the
variable "file" in my code. I give this as parameter to
display-completion-list and now the first different letter is bold.
But the description says that the parameter common-substring is obsolete.
Why? What is the correct way?
--
View this message in context: http://old.nabble.com/complete-file-at-point-in-buffer---solution-and-questions-tp28599706p28607045.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: complete file at point in buffer - solution and questions
2010-05-19 11:30 ` Dirk80
@ 2010-05-19 12:53 ` Gary .
0 siblings, 0 replies; 6+ messages in thread
From: Gary . @ 2010-05-19 12:53 UTC (permalink / raw)
To: Help-gnu-emacs
On Wed, May 19, 2010 at 1:30 PM, Dirk80 wrote:
>> 3.) In unix the file system is case sensitive. In windows OS the file
>> system is not case sensitive. But my function is always case sensitive.
...
> For this problem I found the solution:
>
> (let ((completion-ignore-case (memq system-type '(ms-dos windows-nt
> cygwin))))
> ...)
Please see the Cygwin FAQ:
"4.30. Is Cygwin case-sensitive?? Several Unix programs expect
to be able to use to filenames spelled the same way, but with
different case. A prime example of this is perl's configuration
script, which wants Makefile and makefile. Windows can't tell the
difference between files with just different case, so the
configuration fails.
To help with this problem, Cygwin supports casesensitivity
starting with Cygwin 1.7.0. For a detailed description how to use
that feature see the Cygwin User's Guilde at
http://cygwin.com/cygwin-ug-net/using-specialnames.html."
(http://cygwin.com/faq/faq-nochunks.html#faq.using.case-sensitive)
So basically, it looks like you shouldn't assume that in Cygwin
the files ABC and abc are the same file (nor assume that they are
different files...). Even without Cygwin, the filesystem being
accessed might still support case sensitivity (some kind of
network share, perhaps, or other remote system via tramp, are two
examples that spring to mind) - the OS that emacs is running on
isn't the best guide (and don't as me what is, as I don't know :-P )
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: complete file at point in buffer - solution and questions
[not found] ` <mailman.2.1274268970.19035.help-gnu-emacs@gnu.org>
@ 2010-05-19 19:07 ` Ilya Zakharevich
0 siblings, 0 replies; 6+ messages in thread
From: Ilya Zakharevich @ 2010-05-19 19:07 UTC (permalink / raw)
To: help-gnu-emacs
On 2010-05-19, Dirk80 <dirk@dirkundsari.de> wrote:
> (let ((completion-ignore-case (memq system-type '(ms-dos windows-nt
> cygwin))))
> ...)
In 'emx it is also should be ignoring case.
Hope this helps,
Ilya
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-05-19 19:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-18 19:37 complete file at point in buffer - solution and questions Dirk80
2010-05-19 4:48 ` Kevin Rodgers
2010-05-19 11:30 ` Dirk80
2010-05-19 12:53 ` Gary .
2010-05-19 11:46 ` Dirk80
[not found] ` <mailman.2.1274268970.19035.help-gnu-emacs@gnu.org>
2010-05-19 19:07 ` Ilya Zakharevich
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.