[Top][All Lists]

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

Re: C Headers completion candidates

From: B.V. Raghav
Subject: Re: C Headers completion candidates
Date: Mon, 18 Jul 2016 16:51:50 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Drew Adams <address@hidden> writes:

> Vanilla Emacs considers parameter INITIAL-INPUT to be deprecated.
> Icicles does not.  But even vanilla Emacs still respects it.  IMO,
> it is up to _you_ to decide whether, for your context, it is more
> useful to use INITIAL-INPUT or DEF (or both).
> (`C-h f completing-read' in Icicle mode mentions this.)
> In Icicle mode you can also choose to insert the default value
> (DEF) if INITIAL-INPUT is nil.  You use var `icicle-default-value'
> to control such behavior.  This is a user option, but you can also
> bind it in code if you want.

I refactored `c-header' to accept an optional `initial' argument,

(defun c-header(&optional initial)
  ;; code.. code.. code..
  (completing-read var1 var2 nil nil initial)
  ;; code.. code.. code..)

Then combined it with yasnippets, the following way:

# -*- mode: snippet -*-
# name : #include <...>
# key  : inc
# binding: C-c C-c C-i
# --
#include <`(c-header yas/selected-text)`>

The key binding makes it simpler for me to fulfill the use-case.

(_ represents point and [] represents region)

| Description                        | On Display   |
| write vec                          | vec_         |
| mark (may be C-S-a)                | [vec]_       |
| Invoke yasnippets with C-c C-c C-i | #include <_> |

On the minibuffer I can see the selected text following the prompt

Header: vec_

All I require is a TAB (or S-TAB) with Icicles and I am good to go!


(B.V. Raghav)
Ph.D. Student,
Design Programme, IIT Kanpur

reply via email to

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