From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: bvraghav@iitk.ac.in (B.V. Raghav) Newsgroups: gmane.emacs.help Subject: Re: C Headers completion candidates Date: Mon, 18 Jul 2016 16:51:50 +0530 Organization: Indian Institute of Technology, Kanpur Message-ID: <87vb03i435.fsf@ram.bvr.dp.lan> References: <87k2gozusa.fsf@ram.bvr.dp.lan> <87twfohd2e.fsf@ram.bvr.dp.lan> <9d12723a-07a8-47e4-9f8a-451da7bccb63@default> <871t2rzlsl.fsf@ram.bvr.dp.lan> <6cd1402c-d034-4d6f-a7e7-ef09677a680e@default> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1468840967 7001 80.91.229.3 (18 Jul 2016 11:22:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 18 Jul 2016 11:22:47 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Drew Adams Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jul 18 13:22:42 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bP6dE-0002q6-BO for geh-help-gnu-emacs@m.gmane.org; Mon, 18 Jul 2016 13:22:40 +0200 Original-Received: from localhost ([::1]:45924 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP6dD-0004DH-Ji for geh-help-gnu-emacs@m.gmane.org; Mon, 18 Jul 2016 07:22:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP6cm-0004DA-M1 for help-gnu-emacs@gnu.org; Mon, 18 Jul 2016 07:22:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bP6cg-0004fj-SE for help-gnu-emacs@gnu.org; Mon, 18 Jul 2016 07:22:11 -0400 Original-Received: from mail2.iitk.ac.in ([202.3.77.186]:37419) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP6cg-0004fF-FL for help-gnu-emacs@gnu.org; Mon, 18 Jul 2016 07:22:06 -0400 Original-Received: from smtp.cc.iitk.ac.in (smtp.cc.iitk.ac.in [172.31.1.22]) by mail2.iitk.ac.in (Postfix) with ESMTP id 7A6BA10001AC; Mon, 18 Jul 2016 16:51:50 +0530 (IST) Original-Received: from ram.bvr.dp.lan.iitk.ac.in (unknown [172.20.240.119]) (Authenticated sender: bvraghav) by smtp.cc.iitk.ac.in (Postfix) with ESMTPA id 722B148; Mon, 18 Jul 2016 16:51:50 +0530 (IST) In-Reply-To: <6cd1402c-d034-4d6f-a7e7-ef09677a680e@default> (Drew Adams's message of "Sun, 17 Jul 2016 22:17:32 -0700 (PDT)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 202.3.77.186 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:110882 Archived-At: Drew Adams 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. Example: (_ 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! Thanks, -- (B.V. Raghav) Ph.D. Student, Design Programme, IIT Kanpur