* Icicles for filename insertion in buffer
@ 2016-01-28 19:10 B.V. Raghav
2016-01-28 19:28 ` Drew Adams
0 siblings, 1 reply; 5+ messages in thread
From: B.V. Raghav @ 2016-01-28 19:10 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
Many a times I feel the need to insert the filename into the buffer.
Example:
1. `(insert (file-name-nondirectory (buffer-file-name)))' when inserting
doxygen file comment in a file.
Though this need is fulfilled by substituting this code snippet for
evaluation in yasnippet. I have a few other uses
2. `(insert-file-name-relative-include-directories)' --- when
completing a `# include' directive in a c/c++ programming.
3. Taking notes, and referencing in org-mode.
This requirement is more than fulfilled by C-C C-l (org-insert-link)
Is there a way to use the value selected by icicle (variable name?) and
then trim down prefix using the first match within the sequence of
include directories and appended with values returned by split-string of
$CPATH environment variable.
This should boost the confidence of a novice programmer like me.
Thanks,
r
--
(B.V. Raghav)
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Icicles for filename insertion in buffer
2016-01-28 19:10 Icicles for filename insertion in buffer B.V. Raghav
@ 2016-01-28 19:28 ` Drew Adams
2016-01-28 19:49 ` B.V. Raghav
0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2016-01-28 19:28 UTC (permalink / raw)
To: B.V. Raghav, help-gnu-emacs
> Many a times I feel the need to insert the filename into the buffer.
> Example:
> 1. `(insert (file-name-nondirectory (buffer-file-name)))' when inserting
> doxygen file comment in a file.
> Though this need is fulfilled by substituting this code snippet for
> evaluation in yasnippet. I have a few other uses
> 2. `(insert-file-name-relative-include-directories)' --- when
> completing a `# include' directive in a c/c++ programming.
> 3. Taking notes, and referencing in org-mode.
> This requirement is more than fulfilled by C-C C-l (org-insert-link)
>
> Is there a way to use the value selected by icicle (variable name?) and
> then trim down prefix using the first match within the sequence of
> include directories and appended with values returned by split-string of
> $CPATH environment variable.
Sorry, but I don't understand your question.
Your #1, #2, and #3 do not seem to be about Icicles. And I don't
know what function `insert-file-name-relative-include-directories' is.
Wrt the last paragraph, just what do you mean by the "value selected
by icicle"? I also don't understand the rest of that paragraph (at all).
[I take it that you are not talking about insertion, into the minibuffer,
of a file name at point. But if you are, just use `M-.' in the minibuffer.
See http://www.emacswiki.org/emacs/Icicles_-_Inserting_Text_from_Cursor.]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Icicles for filename insertion in buffer
2016-01-28 19:28 ` Drew Adams
@ 2016-01-28 19:49 ` B.V. Raghav
2016-01-28 21:52 ` Drew Adams
0 siblings, 1 reply; 5+ messages in thread
From: B.V. Raghav @ 2016-01-28 19:49 UTC (permalink / raw)
To: Drew Adams; +Cc: help-gnu-emacs
Drew Adams <drew.adams@oracle.com> writes:
>
> Your #1, #2, and #3 do not seem to be about Icicles. And I don't
Sorry that I assumed a bit too much. I meant how can I make use of
Icicles to create a function like this:
> know what function `insert-file-name-relative-include-directories' is.
That inserts at point the part of file-name selected by icicles(? is that the
correct grammar?) relative to the given include path.
Again apologies for being unclear.
> [I take it that you are not talking about insertion, into the minibuffer,
You are correct here. I am not talking about M-. (and ThingAtPoint+)
I tried my hand at elisp, and discovered the function `read-file-name'
that does invoke icicles. And voila, the following snippet covers most
of my use-cases.
(let ((hpp-file-name (read-file-name "Header File: " "/usr/include/")))
(let ((pos (string-match "/usr/include/" hpp-file-name)))
(if (not (eq nil pos))
(substring hpp-file-name (+ pos (length "/usr/include/")))
(let ((pos (string-match "/inc/" hpp-file-name)))
(if (not (eq nil pos))
(substring hpp-file-name (+ pos (length "/inc/"))))
))))
I use this with yasnippet, and I am good to go.
That said, I am clueless about how to insert relative filenames, like:
# include "impl/SomeHeaderImpl.hpp"
or,
# include "../RelativeHeader.hpp"
Thanks,
r
--
(B.V. Raghav)
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Icicles for filename insertion in buffer
2016-01-28 19:49 ` B.V. Raghav
@ 2016-01-28 21:52 ` Drew Adams
2016-01-29 7:37 ` B.V. Raghav
0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2016-01-28 21:52 UTC (permalink / raw)
To: B.V. Raghav; +Cc: help-gnu-emacs
> > Your #1, #2, and #3 do not seem to be about Icicles. And I don't
> Sorry that I assumed a bit too much. I meant how can I make use of
> Icicles to create a function like this:
>
> > know what function `insert-file-name-relative-include-directories' is.
> That inserts at point the part of file-name selected by icicles(? is that
> the correct grammar?) relative to the given include path.
I don't know what you mean by "the part of file-name selected by icicles".
I don't know what it means for something to be selected by Icicles.
I suggest that you follow up off list. You can always summarize
anything to the list later, if you think it might help someone else.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Icicles for filename insertion in buffer
2016-01-28 21:52 ` Drew Adams
@ 2016-01-29 7:37 ` B.V. Raghav
0 siblings, 0 replies; 5+ messages in thread
From: B.V. Raghav @ 2016-01-29 7:37 UTC (permalink / raw)
To: Drew Adams; +Cc: help-gnu-emacs
Drew Adams <drew.adams@oracle.com> writes:
>
> I suggest that you follow up off list. You can always summarize
> anything to the list later, if you think it might help someone else.
It seems fair to me too to open a new thread. The subject, the matter,
and the discussion, all seem to be falling apart.
Thanks,
r
--
(B.V. Raghav)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-01-29 7:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-28 19:10 Icicles for filename insertion in buffer B.V. Raghav
2016-01-28 19:28 ` Drew Adams
2016-01-28 19:49 ` B.V. Raghav
2016-01-28 21:52 ` Drew Adams
2016-01-29 7:37 ` B.V. Raghav
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).