From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thorsten Jolitz Newsgroups: gmane.emacs.help Subject: How to feed a command prompting for user input non-interactively with args? Date: Sun, 29 Sep 2013 13:59:41 +0200 Message-ID: <87k3hzdej6.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1380456027 20025 80.91.229.3 (29 Sep 2013 12:00:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 29 Sep 2013 12:00:27 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Sep 29 14:00:30 2013 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 1VQFfn-0003EP-Eb for geh-help-gnu-emacs@m.gmane.org; Sun, 29 Sep 2013 14:00:27 +0200 Original-Received: from localhost ([::1]:44522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQFfn-0006Zm-40 for geh-help-gnu-emacs@m.gmane.org; Sun, 29 Sep 2013 08:00:27 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQFfR-0006Ri-R1 for help-gnu-emacs@gnu.org; Sun, 29 Sep 2013 08:00:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VQFfK-0007dC-EY for help-gnu-emacs@gnu.org; Sun, 29 Sep 2013 08:00:05 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:36456) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQFfK-0007d6-7k for help-gnu-emacs@gnu.org; Sun, 29 Sep 2013 07:59:58 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VQFfH-0002la-Qc for help-gnu-emacs@gnu.org; Sun, 29 Sep 2013 13:59:55 +0200 Original-Received: from g231106068.adsl.alicedsl.de ([92.231.106.68]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 29 Sep 2013 13:59:55 +0200 Original-Received: from tjolitz by g231106068.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 29 Sep 2013 13:59:55 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 56 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: g231106068.adsl.alicedsl.de User-Agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:7Gh+iUtVG0BjJ8Ql6sTg05SLNjI= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:93746 Archived-At: Hi List, I want to (or rather have to) use `comment-normalize-vars' in a program, and sometimes in 'text-mode' buffers without defined comment syntax (start, end, add, padding). The way 'comment-normalize-vars' is written, it always quries for user input in this case: ,--------------------------------------------------------------------------- | (defun comment-normalize-vars (&optional noerror) | "Check and set up variables needed by other commenting functions. | [...]" | (unless (and (not comment-start) noerror) | (unless comment-start | (let ((cs (read-string "No comment syntax is defined. Use: ")))...) `--------------------------------------------------------------------------- I tried to avoid this by defining a convenience function: ,------------------------------------------------------ | (defun outorg-comment-normalize-vars () | "Sets comment-syntax before-hand when undefined." | (if comment-start | (comment-normalize-vars) | (let ((comment-start "#") | (comment-end (or comment-end "")) | (comment-add (or comment-add 1)) | (comment-padding (or comment-padding " "))) | (comment-normalize-vars)))) `------------------------------------------------------ but to no avail. I tried to set buffer-local variables first too: ,----------------------------------------------- | (set (make-local-variable 'comment-start) "#") `----------------------------------------------- but was still prompted for the comment-syntax. How can I use this function programmatically in a non-interactive fashion? And why isn't it written like this ,------------------------------------------------------------------- | (defun comment-normalize-vars (&optional noerror comment-start)... `------------------------------------------------------------------- to make it more convenient for use in programs? -- cheers, Thorsten