unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* execute a command with euc-jp
@ 2011-05-05  0:29 masashi ito
  2011-05-05  8:31 ` Thien-Thi Nguyen
  0 siblings, 1 reply; 8+ messages in thread
From: masashi ito @ 2011-05-05  0:29 UTC (permalink / raw)
  To: help-gnu-emacs

Hello to everyone!

I have just joined the list, but been using emacs for about 10 years. Today, I
would like to ask you for help with lisp functions.

I have tried to define a function (my first experience) to execute another
function (howm-menu) with a specified encoding (euc-jp).

What I have ever tried is:
(defun myhowm-menu-eucjp ()
       "to show howm menu with eucjp"
   (interactive)
   (universal-coding-system-argument 'euc-jp)
   (howm-menu)
)

But this (M-x myhowm-menu-eucjp) prompts me to enter a "command to execute
with euc-jp," but does not initiate the command, howm-menu. What should I do
to run the command, howm-menu, with the euc-jp encoding automatically without
prompting me to enter "howm-menu."

Thank you in advance,

Masashi Ito



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

* Re: execute a command with euc-jp
  2011-05-05  0:29 execute a command with euc-jp masashi ito
@ 2011-05-05  8:31 ` Thien-Thi Nguyen
  2011-05-05  8:44   ` Bastian Ballmann
                     ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Thien-Thi Nguyen @ 2011-05-05  8:31 UTC (permalink / raw)
  To: masashi ito; +Cc: help-gnu-emacs

() masashi ito <ma345to@gmx.com>
() Wed, 4 May 2011 20:29:34 -0400

   (defun myhowm-menu-eucjp ()
          "to show howm menu with eucjp"
      (interactive)
      (universal-coding-system-argument 'euc-jp)
      (howm-menu)
   )

   What should I do to run the command, howm-menu, with the euc-jp
   encoding automatically without prompting me to enter "howm-menu."

The long (but more satisfying IMHO) way:

 Move the cursor to ‘universal-coding-system-argument’ and type
 ‘C-h f RET’.  Emacs will show a buffer *Help* at the top of
 which appears:
 
   universal-coding-system-argument is an interactive compiled
   Lisp function in `mule-cmds.el'.
 
 If your Emacs is properly installed, the words mule-cmds.el will be
 presented as a hyperlink.  You can move the cursor there (by typing
 TAB repeatedly) and type RET to follow it, or click with the mouse.
 Doing so will open a buffer viewing that file, with cursor at function
 ‘universal-coding-system-argument’.
 
 Type ‘C-M-e’ to go to the end of the defun.  Note the form:
 
     (let ((coding-system-for-read coding-system)
 	  (coding-system-for-write coding-system)
 	  (coding-system-require-warning t)
 	  (current-prefix-arg prefix))
       (message "")
       (call-interactively cmd))
 
 or something like that.  This shows the basic approach of how to
 invoke a command using a specific coding system: ‘let’-bind some
 variables to the desired value around a call to ‘call-interactively’.
 Transfer this form into ‘myhowm-menu-eucjp’, hard-coding the constant
 bits as you see fit, and pruning the parts that don't seem relevant.
 You might end up with:

The short (but untested, only derived) way:

 (defun myhowm-menu-eucjp ()
   "to show howm menu with eucjp"
   (interactive)
   (let ((coding-system-for-read 'euc-jp)
         (coding-system-for-write 'euc-jp)
         (coding-system-require-warning t))
     (call-interactively 'howm-menu)))

In any case, if your Emacs is not properly installed, fix that first.



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

* Re: execute a command with euc-jp
  2011-05-05  8:31 ` Thien-Thi Nguyen
@ 2011-05-05  8:44   ` Bastian Ballmann
  2011-05-05  8:45   ` Bastian Ballmann
  2011-05-05 22:01   ` masashi ito
  2 siblings, 0 replies; 8+ messages in thread
From: Bastian Ballmann @ 2011-05-05  8:44 UTC (permalink / raw)
  To: help-gnu-emacs

Am Thu, 05 May 2011 10:31:52 +0200
schrieb Thien-Thi Nguyen <ttn@gnuvola.org>:

> () masashi ito <ma345to@gmx.com>
> () Wed, 4 May 2011 20:29:34 -0400
> 
>    (defun myhowm-menu-eucjp ()
>           "to show howm menu with eucjp"
>       (interactive)
>       (universal-coding-system-argument 'euc-jp)
>       (howm-menu)
>    )
> 
>    What should I do to run the command, howm-menu, with the euc-jp
>    encoding automatically without prompting me to enter "howm-menu."
> 
> The long (but more satisfying IMHO) way:
> 
>  Move the cursor to ‘universal-coding-system-argument’ and type
>  ‘C-h f RET’.  Emacs will show a buffer *Help* at the top of
>  which appears:
>  
>    universal-coding-system-argument is an interactive compiled
>    Lisp function in `mule-cmds.el'.
>  
>  If your Emacs is properly installed, the words mule-cmds.el will be
>  presented as a hyperlink.  You can move the cursor there (by typing
>  TAB repeatedly) and type RET to follow it, or click with the mouse.
>  Doing so will open a buffer viewing that file, with cursor at
> function ‘universal-coding-system-argument’.
>  
>  Type ‘C-M-e’ to go to the end of the defun.  Note the form:
>  
>      (let ((coding-system-for-read coding-system)
>  	  (coding-system-for-write coding-system)
>  	  (coding-system-require-warning t)
>  	  (current-prefix-arg prefix))
>        (message "")
>        (call-interactively cmd))
>  
>  or something like that.  This shows the basic approach of how to
>  invoke a command using a specific coding system: ‘let’-bind some
>  variables to the desired value around a call to ‘call-interactively’.
>  Transfer this form into ‘myhowm-menu-eucjp’, hard-coding the constant
>  bits as you see fit, and pruning the parts that don't seem relevant.
>  You might end up with:
> 
> The short (but untested, only derived) way:
> 
>  (defun myhowm-menu-eucjp ()
>    "to show howm menu with eucjp"
>    (interactive)
>    (let ((coding-system-for-read 'euc-jp)
>          (coding-system-for-write 'euc-jp)
>          (coding-system-require-warning t))
>      (call-interactively 'howm-menu)))
> 
> In any case, if your Emacs is not properly installed, fix that first.
> 




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

* Re: execute a command with euc-jp
  2011-05-05  8:31 ` Thien-Thi Nguyen
  2011-05-05  8:44   ` Bastian Ballmann
@ 2011-05-05  8:45   ` Bastian Ballmann
  2011-05-05 22:01   ` masashi ito
  2 siblings, 0 replies; 8+ messages in thread
From: Bastian Ballmann @ 2011-05-05  8:45 UTC (permalink / raw)
  To: help-gnu-emacs

Am Thu, 05 May 2011 10:31:52 +0200
schrieb Thien-Thi Nguyen <ttn@gnuvola.org>:

> () masashi ito <ma345to@gmx.com>
> () Wed, 4 May 2011 20:29:34 -0400
> 
>    (defun myhowm-menu-eucjp ()
>           "to show howm menu with eucjp"
>       (interactive)
>       (universal-coding-system-argument 'euc-jp)
>       (howm-menu)
>    )
> 
>    What should I do to run the command, howm-menu, with the euc-jp
>    encoding automatically without prompting me to enter "howm-menu."
> 
> The long (but more satisfying IMHO) way:
> 
>  Move the cursor to ‘universal-coding-system-argument’ and type
>  ‘C-h f RET’.  Emacs will show a buffer *Help* at the top of
>  which appears:
>  
>    universal-coding-system-argument is an interactive compiled
>    Lisp function in `mule-cmds.el'.
>  
>  If your Emacs is properly installed, the words mule-cmds.el will be
>  presented as a hyperlink.  You can move the cursor there (by typing
>  TAB repeatedly) and type RET to follow it, or click with the mouse.
>  Doing so will open a buffer viewing that file, with cursor at
> function ‘universal-coding-system-argument’.
>  
>  Type ‘C-M-e’ to go to the end of the defun.  Note the form:
>  
>      (let ((coding-system-for-read coding-system)
>  	  (coding-system-for-write coding-system)
>  	  (coding-system-require-warning t)
>  	  (current-prefix-arg prefix))
>        (message "")
>        (call-interactively cmd))
>  
>  or something like that.  This shows the basic approach of how to
>  invoke a command using a specific coding system: ‘let’-bind some
>  variables to the desired value around a call to ‘call-interactively’.
>  Transfer this form into ‘myhowm-menu-eucjp’, hard-coding the constant
>  bits as you see fit, and pruning the parts that don't seem relevant.
>  You might end up with:
> 
> The short (but untested, only derived) way:
> 
>  (defun myhowm-menu-eucjp ()
>    "to show howm menu with eucjp"
>    (interactive)
>    (let ((coding-system-for-read 'euc-jp)
>          (coding-system-for-write 'euc-jp)
>          (coding-system-require-warning t))
>      (call-interactively 'howm-menu)))
> 
> In any case, if your Emacs is not properly installed, fix that first.
> 




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

* Re: execute a command with euc-jp
  2011-05-05  8:31 ` Thien-Thi Nguyen
  2011-05-05  8:44   ` Bastian Ballmann
  2011-05-05  8:45   ` Bastian Ballmann
@ 2011-05-05 22:01   ` masashi ito
  2011-05-06  0:37     ` Thien-Thi Nguyen
  2 siblings, 1 reply; 8+ messages in thread
From: masashi ito @ 2011-05-05 22:01 UTC (permalink / raw)
  To: Thien-Thi Nguyen, help-gnu-emacs

Dear Thien-Thi Nguyen,

Thank you for your detailed instruction. You told me many things I didn't
know. These will be definitely helpful in my learning lisp programming. As for
the function definition, however, the code you suggested, unfortunately,
didn't work (M-x myhowm-menu-eucjp didn't show anything).

I have tried many variations. But I haven't got things done yet. One
thing I noticed is 

(defun myhowm-menu-eucjp ()
   "to show howm menu with eucjp"
   (interactive)
   (universal-coding-system-argument 'euc-jp)
   (call-interactively 'howm-menu))

shows the prompt "Command to execute with euc-jp" and stops waiting for further
input. If I press just "enter," howm-menu is processed with a wrong
encoding. If instead I press "ctrl-c , '" which is bound to the howm-menu
command, howm-menu is processed with the euc-jp encoding...

Any suggestion is welcomed!

Masashi

On Thu, May 05, 2011 at 10:31:52AM +0200, Thien-Thi Nguyen wrote:
> () masashi ito <ma345to@gmx.com>
> () Wed, 4 May 2011 20:29:34 -0400
> 
>    (defun myhowm-menu-eucjp ()
>           "to show howm menu with eucjp"
>       (interactive)
>       (universal-coding-system-argument 'euc-jp)
>       (howm-menu)
>    )
> 
>    What should I do to run the command, howm-menu, with the euc-jp
>    encoding automatically without prompting me to enter "howm-menu."
> 
> The long (but more satisfying IMHO) way:
> 
>  Move the cursor to ‘universal-coding-system-argument’ and type
>  ‘C-h f RET’.  Emacs will show a buffer *Help* at the top of
>  which appears:
>  
>    universal-coding-system-argument is an interactive compiled
>    Lisp function in `mule-cmds.el'.
>  
>  If your Emacs is properly installed, the words mule-cmds.el will be
>  presented as a hyperlink.  You can move the cursor there (by typing
>  TAB repeatedly) and type RET to follow it, or click with the mouse.
>  Doing so will open a buffer viewing that file, with cursor at function
>  ‘universal-coding-system-argument’.
>  
>  Type ‘C-M-e’ to go to the end of the defun.  Note the form:
>  
>      (let ((coding-system-for-read coding-system)
>  	  (coding-system-for-write coding-system)
>  	  (coding-system-require-warning t)
>  	  (current-prefix-arg prefix))
>        (message "")
>        (call-interactively cmd))
>  
>  or something like that.  This shows the basic approach of how to
>  invoke a command using a specific coding system: ‘let’-bind some
>  variables to the desired value around a call to ‘call-interactively’.
>  Transfer this form into ‘myhowm-menu-eucjp’, hard-coding the constant
>  bits as you see fit, and pruning the parts that don't seem relevant.
>  You might end up with:
> 
> The short (but untested, only derived) way:
> 
>  (defun myhowm-menu-eucjp ()
>    "to show howm menu with eucjp"
>    (interactive)
>    (let ((coding-system-for-read 'euc-jp)
>          (coding-system-for-write 'euc-jp)
>          (coding-system-require-warning t))
>      (call-interactively 'howm-menu)))
> 
> In any case, if your Emacs is not properly installed, fix that first.



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

* Re: execute a command with euc-jp
  2011-05-05 22:01   ` masashi ito
@ 2011-05-06  0:37     ` Thien-Thi Nguyen
  2011-05-06  3:50       ` masashi ito
  0 siblings, 1 reply; 8+ messages in thread
From: Thien-Thi Nguyen @ 2011-05-06  0:37 UTC (permalink / raw)
  To: masashi ito; +Cc: help-gnu-emacs

() masashi ito <ma345to@gmx.com>
() Thu, 5 May 2011 18:01:10 -0400

   As for the function definition, however, the code you suggested,
   unfortunately, didn't work (M-x myhowm-menu-eucjp didn't show anything).

Perhaps you did not evaluate the new definition?
I was able to see the menu appear with

  (defun ttn-howm-menu ()
    (interactive)
    (let ((coding-system-for-read 'euc-jp)
          (coding-system-for-write 'euc-jp)
          (coding-system-require-warning t))
      (call-interactively 'howm-menu)))

and an installation of howm from howm-1.3.9.1.tar.gz.  After copying this
definition into *scratch*, i typed ‘C-M-x’ (i.e., ‘eval-defun’) and then
‘M-x ttn-howm-menu’.

To verify that ‘eval-defun’ worked correctly, you can type into *scratch*:

  (symbol-function 'ttn-howm-menu)

then type ‘C-j’ to inspect what Emacs thinks is the current definition.



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

* Re: execute a command with euc-jp
  2011-05-06  0:37     ` Thien-Thi Nguyen
@ 2011-05-06  3:50       ` masashi ito
  2011-05-06  8:10         ` Thien-Thi Nguyen
  0 siblings, 1 reply; 8+ messages in thread
From: masashi ito @ 2011-05-06  3:50 UTC (permalink / raw)
  To: Thien-Thi Nguyen; +Cc: help-gnu-emacs

Dear Thien-Thi Nguyen,

Thank you very much again for your kind, thorough instruction. And I apologize
for my mistake. As you said, I didn't evaluate the newly defined function
properly. I did C-x, C-e, which I found somewhere on the Internet. When I did
C-M-x, everything worked like a charm! I appreciate your help very much!

Sincerely yours,

Masashi

On Fri, May 06, 2011 at 02:37:52AM +0200, Thien-Thi Nguyen wrote:
> () masashi ito <ma345to@gmx.com>
> () Thu, 5 May 2011 18:01:10 -0400
> 
>    As for the function definition, however, the code you suggested,
>    unfortunately, didn't work (M-x myhowm-menu-eucjp didn't show anything).
> 
> Perhaps you did not evaluate the new definition?
> I was able to see the menu appear with
> 
>   (defun ttn-howm-menu ()
>     (interactive)
>     (let ((coding-system-for-read 'euc-jp)
>           (coding-system-for-write 'euc-jp)
>           (coding-system-require-warning t))
>       (call-interactively 'howm-menu)))
> 
> and an installation of howm from howm-1.3.9.1.tar.gz.  After copying this
> definition into *scratch*, i typed ‘C-M-x’ (i.e., ‘eval-defun’) and then
> ‘M-x ttn-howm-menu’.
> 
> To verify that ‘eval-defun’ worked correctly, you can type into *scratch*:
> 
>   (symbol-function 'ttn-howm-menu)
> 
> then type ‘C-j’ to inspect what Emacs thinks is the current definition.



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

* Re: execute a command with euc-jp
  2011-05-06  3:50       ` masashi ito
@ 2011-05-06  8:10         ` Thien-Thi Nguyen
  0 siblings, 0 replies; 8+ messages in thread
From: Thien-Thi Nguyen @ 2011-05-06  8:10 UTC (permalink / raw)
  To: masashi ito; +Cc: help-gnu-emacs

() masashi ito <ma345to@gmx.com>
() Thu, 5 May 2011 23:50:22 -0400

   And I apologize for my mistake.

No worries; i'm glad you persisted towards this understanding.

   As you said, I didn't evaluate the newly defined function properly.
   I did C-x, C-e, which I found somewhere on the Internet.
   When I did C-M-x, everything worked like a charm!

‘C-x C-e’ works fine if you place the cursor after the form you want to
evaluate.  ‘C-M-x’ is more suitable when you are in the middle of a defun,
which is often the case when experimenting in *scratch*.

To avoid Internet-induced confusion, you can find this kind of information
directly from Emacs.  Try:

  C-h k C-h k
  C-h k C-x C-e
  C-h k C-M-x

(This way, if there is any remaining confusion, you can tell the Emacs
maintainers about it and Emacs will improve as a result.  Try THAT with the
Internet!  :-D)



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

end of thread, other threads:[~2011-05-06  8:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-05  0:29 execute a command with euc-jp masashi ito
2011-05-05  8:31 ` Thien-Thi Nguyen
2011-05-05  8:44   ` Bastian Ballmann
2011-05-05  8:45   ` Bastian Ballmann
2011-05-05 22:01   ` masashi ito
2011-05-06  0:37     ` Thien-Thi Nguyen
2011-05-06  3:50       ` masashi ito
2011-05-06  8:10         ` Thien-Thi Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).