m-x.c (672dff93) | m-x.c (3aa90977) |
---|---|
1/* m-x.c -- Meta-x minibuffer reader. | 1/* m-x.c -- Meta-x minibuffer reader. |
2 $Id: m-x.c,v 1.3 2000/02/09 02:18:40 espie Exp $ | 2 $Id: m-x.c,v 1.4 2002/06/10 13:51:03 espie Exp $ |
3 | 3 |
4 Copyright (C) 1993, 97, 98 Free Software Foundation, Inc. | 4 Copyright (C) 1993, 97, 98, 2001 Free Software Foundation, Inc. |
5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 20 Written by Brian Fox (bfox@ai.mit.edu). */ 21 22#include "info.h" | 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 20 Written by Brian Fox (bfox@ai.mit.edu). */ 21 22#include "info.h" |
23#include "funs.h" |
|
23 24/* **************************************************************** */ 25/* */ 26/* Reading Named Commands */ 27/* */ 28/* **************************************************************** */ 29 30/* Read the name of an Info function in the echo area and return the --- 45 unchanged lines hidden (view full) --- 76 { 77 info_abort_key (active_window, count, key); 78 return; 79 } 80 81 /* Describe the function named in "LINE". */ 82 if (*line) 83 { | 24 25/* **************************************************************** */ 26/* */ 27/* Reading Named Commands */ 28/* */ 29/* **************************************************************** */ 30 31/* Read the name of an Info function in the echo area and return the --- 45 unchanged lines hidden (view full) --- 77 { 78 info_abort_key (active_window, count, key); 79 return; 80 } 81 82 /* Describe the function named in "LINE". */ 83 if (*line) 84 { |
84 VFunction *fun = named_function (line); | 85 InfoCommand *cmd = named_function (line); |
85 | 86 |
86 if (!fun) | 87 if (!cmd) |
87 return; 88 89 window_message_in_echo_area ("%s: %s.", | 88 return; 89 90 window_message_in_echo_area ("%s: %s.", |
90 line, function_documentation (fun)); | 91 line, function_documentation (cmd)); |
91 } 92 free (line); 93} 94 95DECLARE_INFO_COMMAND (info_execute_command, 96 _("Read a command name in the echo area and execute it")) 97{ 98 char *line; | 92 } 93 free (line); 94} 95 96DECLARE_INFO_COMMAND (info_execute_command, 97 _("Read a command name in the echo area and execute it")) 98{ 99 char *line; |
100 char *keys; 101 char *prompt; |
|
99 | 102 |
100 /* Ask the completer to read a reference for us. */ 101 if (info_explicit_arg || count != 1) 102 { 103 char *prompt; | 103 prompt = (char *)xmalloc (20); |
104 | 104 |
105 prompt = (char *)xmalloc (20); 106 sprintf (prompt, "%d M-x ", count); 107 line = read_function_name (prompt, window); 108 } | 105 keys = where_is (info_keymap, InfoCmd(info_execute_command)); 106 /* If the where_is () function thinks that this command doesn't exist, 107 there's something very wrong! */ 108 if (!keys) 109 abort(); 110 111 if (info_explicit_arg || count != 1) 112 sprintf (prompt, "%d %s ", count, keys); |
109 else | 113 else |
110 line = read_function_name ("M-x ", window); | 114 sprintf (prompt, "%s ", keys); |
111 | 115 |
116 /* Ask the completer to read a reference for us. */ 117 line = read_function_name (prompt, window); 118 |
|
112 /* User aborted? */ 113 if (!line) 114 { 115 info_abort_key (active_window, count, key); 116 return; 117 } 118 119 /* User accepted "default"? (There is none.) */ 120 if (!*line) 121 { 122 free (line); 123 return; 124 } 125 126 /* User wants to execute a named command. Do it. */ 127 { | 119 /* User aborted? */ 120 if (!line) 121 { 122 info_abort_key (active_window, count, key); 123 return; 124 } 125 126 /* User accepted "default"? (There is none.) */ 127 if (!*line) 128 { 129 free (line); 130 return; 131 } 132 133 /* User wants to execute a named command. Do it. */ 134 { |
128 VFunction *function; | 135 InfoCommand *command; |
129 130 if ((active_window != the_echo_area) && 131 (strncmp (line, "echo-area-", 10) == 0)) 132 { 133 free (line); 134 info_error (_("Cannot execute an `echo-area' command here.")); 135 return; 136 } 137 | 136 137 if ((active_window != the_echo_area) && 138 (strncmp (line, "echo-area-", 10) == 0)) 139 { 140 free (line); 141 info_error (_("Cannot execute an `echo-area' command here.")); 142 return; 143 } 144 |
138 function = named_function (line); | 145 command = named_function (line); |
139 free (line); 140 | 146 free (line); 147 |
141 if (!function) | 148 if (!command) |
142 return; 143 | 149 return; 150 |
144 (*function) (active_window, count, 0); | 151 (*InfoFunction(command)) (active_window, count, 0); |
145 } 146} 147 148/* Okay, now that we have M-x, let the user set the screen height. */ 149DECLARE_INFO_COMMAND (set_screen_height, 150 _("Set the height of the displayed window")) 151{ 152 int new_height, old_height = screenheight; --- 52 unchanged lines hidden --- | 152 } 153} 154 155/* Okay, now that we have M-x, let the user set the screen height. */ 156DECLARE_INFO_COMMAND (set_screen_height, 157 _("Set the height of the displayed window")) 158{ 159 int new_height, old_height = screenheight; --- 52 unchanged lines hidden --- |