help-gnu-emacs
[Top][All Lists]
Advanced

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

How to feed a command prompting for user input non-interactively with ar


From: Thorsten Jolitz
Subject: How to feed a command prompting for user input non-interactively with args?
Date: Sun, 29 Sep 2013 13:59:41 +0200
User-agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux)

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





reply via email to

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