all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to feed a command prompting for user input non-interactively with args?
@ 2013-09-29 11:59 Thorsten Jolitz
  2013-09-29 17:04 ` Michael Heerdegen
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Jolitz @ 2013-09-29 11:59 UTC (permalink / raw)
  To: help-gnu-emacs


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





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to feed a command prompting for user input non-interactively with args?
  2013-09-29 11:59 How to feed a command prompting for user input non-interactively with args? Thorsten Jolitz
@ 2013-09-29 17:04 ` Michael Heerdegen
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Heerdegen @ 2013-09-29 17:04 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Thorsten,

> I tried to set buffer-local variables first too:
>
> ,-----------------------------------------------
> | (set (make-local-variable 'comment-start) "#")
> `-----------------------------------------------
>
> but was still prompted for the comment-syntax.

Works for me, I'm not prompted.  Are you sure you evaluated it in the
right buffer?


Regards,

Michael.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-09-29 17:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-29 11:59 How to feed a command prompting for user input non-interactively with args? Thorsten Jolitz
2013-09-29 17:04 ` Michael Heerdegen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.