I returned the " Def" string to modeline. Also, I played with
defining keyboard macros, and noticed that the menu code treats
something like (lambda () (interactive) ...) as form to evaluate
instead of command, and tries to eval it, which is a no-op.
After fixing that, I noticed that when `end-kbd-macro' is invoked
through a menu event, that menu event gets recorded. Bummer. I
"fixed" it by adding a REMOVE-LAST argument to `end-kbd-macro', but it
is not a long-term good fix. I don't have an idea how to fix it
without kludges, though.
C ChangeLog:
1998-04-30 Hrvoje Niksic <hniksic(a)srce.hr>
* macros.c (Fend_kbd_macro): New arg REMOVE-LAST.
* gui-x.c (popup_selection_callback): Treat anonymous interactive
and compiled-function interactive callbacks as commands.
1998-04-28 Hrvoje Niksic <hniksic(a)srce.hr>
* abbrev.c (obarray_has_blank_p): Simplify.
1998-04-27 Hrvoje Niksic <hniksic(a)srce.hr>
* getloadavg.c (getloadavg): Removed some code repetition.
Lisp ChangeLog:
1998-04-30 Hrvoje Niksic <hniksic(a)srce.hr>
* modeline.el (defining-kbd-macro): Restore modeline indication of
kbd-macro being recorded.
(add-minor-mode): Simplify docstring.
(modeline-minor-mode-menu): Remove stuff.
--- src/gui-x.c.orig Thu Apr 30 03:05:56 1998
+++ src/gui-x.c Thu Apr 30 03:19:55 1998
@@ -36,6 +36,7 @@
#include "frame.h"
#include "gui.h"
#include "opaque.h"
+#include "bytecode.h" /* for struct Lisp_Compiled_Function */
#ifdef HAVE_POPUPS
Lisp_Object Qmenu_no_selection_hook;
@@ -258,7 +259,12 @@
fn = Qrun_hooks;
arg = Qmenu_no_selection_hook;
}
- else if (SYMBOLP (data))
+ else if (SYMBOLP (data)
+ /* poor man's commandp */
+ || (COMPILED_FUNCTIONP (data)
+ && XCOMPILED_FUNCTION (data)->flags.interactivep)
+ || (EQ (XCAR (data), Qlambda)
+ && !NILP (Fassq (Qinteractive, Fcdr (Fcdr (data))))))
{
fn = Qcall_interactively;
arg = data;
--- src/macros.c.orig Thu Apr 30 03:29:01 1998
+++ src/macros.c Thu Apr 30 03:31:54 1998
@@ -87,7 +87,7 @@
return Qnil;
}
-DEFUN ("end-kbd-macro", Fend_kbd_macro, 0, 1, "P", /*
+DEFUN ("end-kbd-macro", Fend_kbd_macro, 0, 2, "P", /*
Finish defining a keyboard macro.
The definition was started by \\[start-kbd-macro].
The macro is now available for use via \\[call-last-kbd-macro],
@@ -97,16 +97,29 @@
With numeric arg, repeat macro now that many times,
counting the definition just completed as the first repetition.
An argument of zero means repeat until error.
+
+If REMOVE-LAST is an integer, it means to not record the last number
+of events. This is used internally and will likely be removed.
*/
- (arg))
+ (arg, remove_last))
{
/* This function can GC */
struct console *con = XCONSOLE (Vselected_console);
- int repeat;
+ int repeat, kill;
if (NILP (con->defining_kbd_macro))
error ("Not defining kbd macro.");
+ /* #### Read the comment in modeline.el to see why this ugliness is
+ needed. #### Try to avoid it, somehow! */
+ if (!NILP (remove_last))
+ {
+ CHECK_NATNUM (remove_last);
+ kill = XINT (remove_last);
+ }
+ else
+ kill = 0;
+
if (NILP (arg))
repeat = -1;
else
@@ -115,9 +128,12 @@
if (!NILP (con->defining_kbd_macro))
{
int i;
- int size = con->kbd_macro_end;
+ int size = con->kbd_macro_end - kill;
+
+ if (size < 0)
+ size = 0;
con->last_kbd_macro = make_vector (size, Qnil);
- for (i = 0; i < con->kbd_macro_end; i++)
+ for (i = 0; i < size; i++)
XVECTOR_DATA (con->last_kbd_macro) [i] =
XVECTOR_DATA (con->kbd_macro_builder) [i];
con->defining_kbd_macro = Qnil;
--- src/abbrev.c.orig Tue Apr 28 04:29:48 1998
+++ src/abbrev.c Tue Apr 28 04:33:27 1998
@@ -190,10 +190,10 @@
wordstart = get_buffer_pos_char (buf, Vabbrev_start_location,
GB_COERCE_RANGE);
Vabbrev_start_location = Qnil;
+#if 0
/* Previously, abbrev-prefix-mark crockishly inserted a dash to
indicate the abbrev start point. It now uses an extent with
a begin glyph so there's no dash to remove. */
-#if 0
if (wordstart != BUF_ZV (buf)
&& BUF_FETCH_CHAR (buf, wordstart) == '-')
{
@@ -245,10 +245,7 @@
static int
obarray_has_blank_p (Lisp_Object obarray)
{
- Lisp_Object lookup;
-
- lookup = oblookup (obarray, (Bufbyte *)" ", 1);
- return SYMBOLP (lookup);
+ return !ZEROP (oblookup (obarray, (Bufbyte *)" ", 1));
}
/* Analyze case in the buffer substring, and report it. */
@@ -256,12 +253,10 @@
abbrev_count_case (struct buffer *buf, Bufpos pos, Charcount length,
int *lccount, int *uccount)
{
- Emchar c;
-
*lccount = *uccount = 0;
while (length--)
{
- c = BUF_FETCH_CHAR (buf, pos);
+ Emchar c = BUF_FETCH_CHAR (buf, pos);
if (UPPERCASEP (buf, c))
++*uccount;
else if (LOWERCASEP (buf, c))
--- src/getloadavg.c.orig Mon Apr 27 19:47:32 1998
+++ src/getloadavg.c Mon Apr 27 19:49:54 1998
@@ -525,7 +525,7 @@
this function just can't work at all on this system. */
errno = 0;
elem = -2;
-#endif
+#endif /* NO_GET_LOAD_AVG */
#if ! defined (LDAV_DONE) && defined (HAVE_KSTAT_H) && defined
(HAVE_LIBKSTAT)
#define LDAV_DONE
@@ -546,7 +546,7 @@
if (nelem > countof (avestrings))
nelem = countof (avestrings);
- kc = kstat_open();
+ kc = kstat_open ();
if (!kc)
return -1;
ksp = kstat_lookup (kc, "unix", 0, "system_misc");
@@ -568,7 +568,7 @@
kstat_close (kc);
return -1;
}
- loadavg[elem] = (double)kn->value.ul/FSCALE;
+ loadavg[elem] = (double)kn->value.ul / FSCALE;
}
kstat_close (kc);
#endif /* HAVE_KSTAT_H && HAVE_LIBKSTAT */
@@ -943,14 +943,7 @@
#define LDAV_DONE
#endif /* !LDAV_DONE && LOAD_AVE_TYPE */
-#ifdef LDAV_DONE
return elem;
-#else
- /* Set errno to zero to indicate that there was no particular error;
- this function just can't work at all on this system. */
- errno = 0;
- return -2;
-#endif
}
#endif /* ! HAVE_GETLOADAVG */
--- lisp/modeline.el.orig Thu Apr 30 00:46:17 1998
+++ lisp/modeline.el Thu Apr 30 03:38:45 1998
@@ -74,7 +74,7 @@
(start-event-frame (event-frame event))
(start-event-window (event-window event))
(start-nwindows (count-windows t))
- (hscroll-delta (face-width 'modeline))
+;; (hscroll-delta (face-width 'modeline))
;; (start-hscroll (modeline-hscroll (event-window event)))
(start-x-pixel (event-x-pixel event))
(last-timestamp 0)
@@ -313,26 +313,12 @@
;; (append minor-mode-alist
;; '((isearch-mode isearch-mode))))))
-(defvar place)
(defun add-minor-mode (toggle name &optional keymap after toggle-fun)
"Add a minor mode to `minor-mode-alist' and `minor-mode-map-alist'.
TOGGLE is a symbol whose value as a variable specifies whether the
minor mode is active.
- If TOGGLE has the `:menu-tag' property set to a string, that string
- will be used as the label on the `modeline-minor-mode-menu' instead
- of TOGGLE's symbol-name.
-
- TOGGLE may have an `:included' property, which determines whether a
- menu button will be shown for this minor mode in the
- `modeline-minor-mode-menu'. This should be either a boolean
- variable, or an expression evaluating to t or nil. \(See the
- documentation of `current-menubar' for more information.)
-
- It may have an `:active' property also, as documented in
- `current-menubar'.
-
NAME is the name that should appear in the modeline. It should either
be a string beginning with a space, or a symbol with a similar string
as its value.
@@ -349,70 +335,61 @@
modes. If TOGGLE-FUN is nil and TOGGLE names an interactive function,
TOGGLE is used as the toggle function.
-Example: (put 'view-minor-mode :menu-tag \"View (minor)\")
- (put 'view-minor-mode :included '(buffer-file-name))
- (add-minor-mode 'view-minor-mode \" View\" view-mode-map)"
- (let (el place
- (add-elt #'(lambda (elt sym)
- (cond ((null after) ; add to front
- (set sym (cons elt (symbol-value sym))))
- ((and (not (eq after t))
- (setq place (memq (assq after
- (symbol-value sym))
- (symbol-value sym))))
- (setq elt (cons elt (cdr place)))
- (setcdr place elt))
- (t
- (set sym (append (symbol-value sym) (list elt))))
- )
- (symbol-value sym)))
- toggle-keymap)
+Example: (add-minor-mode 'view-minor-mode \" View\" view-mode-map)"
+ (let* ((add-elt #'(lambda (elt sym)
+ (let (place)
+ (cond ((null after) ; add to front
+ (push elt (symbol-value sym)))
+ ((and (not (eq after t))
+ (setq place (memq (assq after
+ (symbol-value sym))
+ (symbol-value sym))))
+ (push elt (cdr place)))
+ (t
+ (set sym (append (symbol-value sym)
+ (list elt))))))
+ (symbol-value sym)))
+ el toggle-keymap)
(if toggle-fun
- (if (not (commandp toggle-fun))
- (error "not an interactive function: %S" toggle-fun))
- (if (commandp toggle)
- (setq toggle-fun toggle)))
- (if (and toggle-fun name)
- (progn
- (setq toggle-keymap (make-sparse-keymap
- (intern (concat "modeline-minor-"
- (symbol-name toggle)
- "-map"))))
- (define-key toggle-keymap 'button2
- ;; defeat the DUMB-ASS byte-compiler, which tries to
- ;; expand the macro at compile time and fucks up.
- (eval '(make-modeline-command-wrapper toggle-fun)))
- (put toggle 'modeline-toggle-function toggle-fun)))
- (and name
- (let ((hacked-name
- (if toggle-keymap
- (cons (let ((extent (make-extent nil nil)))
- (set-extent-keymap extent toggle-keymap)
- (set-extent-property
- extent 'help-echo
- (concat "button2 turns off "
- (if (symbolp toggle-fun)
- (symbol-name toggle-fun)
- (symbol-name toggle))))
- extent)
- (cons
- modeline-mousable-minor-mode-extent
- name))
- name)))
- (if (setq el (assq toggle minor-mode-alist))
- (setcdr el (list hacked-name))
- (funcall add-elt
- (list toggle hacked-name)
- 'minor-mode-alist))))
- (and keymap
- (if (setq el (assq toggle minor-mode-map-alist))
- (setcdr el keymap)
- (funcall add-elt
- (cons toggle keymap)
- 'minor-mode-map-alist)))
- ))
+ (check-argument-type 'commandp toggle-fun)
+ (when (commandp toggle)
+ (setq toggle-fun toggle)))
+ (when (and toggle-fun name)
+ (setq toggle-keymap (make-sparse-keymap
+ (intern (concat "modeline-minor-"
+ (symbol-name toggle)
+ "-map"))))
+ (define-key toggle-keymap 'button2
+ ;; defeat the DUMB-ASS byte-compiler, which tries to
+ ;; expand the macro at compile time and fucks up.
+ (eval '(make-modeline-command-wrapper toggle-fun)))
+ (put toggle 'modeline-toggle-function toggle-fun))
+ (when name
+ (let ((hacked-name
+ (if toggle-keymap
+ (cons (let ((extent (make-extent nil nil)))
+ (set-extent-keymap extent toggle-keymap)
+ (set-extent-property
+ extent 'help-echo
+ (concat "button2 turns off "
+ (if (symbolp toggle-fun)
+ (symbol-name toggle-fun)
+ (symbol-name toggle))))
+ extent)
+ (cons modeline-mousable-minor-mode-extent name))
+ name)))
+ (if (setq el (assq toggle minor-mode-alist))
+ (setcdr el (list hacked-name))
+ (funcall add-elt
+ (list toggle hacked-name)
+ 'minor-mode-alist))))
+ (when keymap
+ (if (setq el (assq toggle minor-mode-map-alist))
+ (setcdr el keymap)
+ (funcall add-elt
+ (cons toggle keymap)
+ 'minor-mode-map-alist)))))
-;; gettext anyone?
(put 'abbrev-mode :menu-tag "Abbreviation Expansion")
(add-minor-mode 'abbrev-mode " Abbrev")
;; only when visiting a file...
@@ -420,10 +397,18 @@
(put 'auto-fill-function :menu-tag "Auto Fill")
(add-minor-mode 'auto-fill-function " Fill" nil nil 'auto-fill-mode)
-;; what's the meaning of `####' vs `FIXME' or ...?
-;; not really a minor mode... and it doesn't work right anyway.
-;;(put 'defining-kbd-macro :menu-tag "Defining kbd macro")
-;;(add-minor-mode 'defining-kbd-macro " Def") FIXME
+(put 'defining-kbd-macro :menu-tag "Keyboard Macro")
+(add-minor-mode 'defining-kbd-macro " Def" nil nil
+ (lambda ()
+ (interactive)
+ (if defining-kbd-macro
+ ;; #### 1 means to disregard the last event.
+ ;; This is needed because the last recorded
+ ;; event is usually the mouse event that invoked
+ ;; the menu item (and this function), and having
+ ;; it in the macro causes problems.
+ (end-kbd-macro nil 1)
+ (start-kbd-macro nil))))
(defun modeline-minor-mode-menu (event)
"The menu that pops up when you press `button3' inside the
@@ -432,38 +417,36 @@
(save-excursion
(set-buffer (event-buffer event))
(popup-menu-and-execute-in-window
- (cons "Minor Mode Toggles"
- (apply 'nconc
- (mapcar
- #'(lambda (x)
- (let* ((toggle-sym (car x))
- (menu-tag (get toggle-sym :menu-tag nil))
- (toggle-fun
- (or (get toggle-sym
- 'modeline-toggle-function)
- (and (fboundp toggle-sym)
- (commandp toggle-sym)
- toggle-sym))))
- (if (not toggle-fun) nil
- (list (vector
- (or (and (stringp menu-tag)
- menu-tag)
- (setq menu-tag (capitalize
- (replace-in-string
- (replace-in-string
- (replace-in-string (if (symbolp toggle-fun)
- (symbol-name toggle-fun)
- (symbol-name toggle-sym))
- "-" " ")
- "minor" " (minor)")
- " mode" ""))))
- toggle-fun
- :active (get toggle-sym :active t)
- :included (get toggle-sym :included t)
- :style 'toggle
- :selected (and (boundp toggle-sym)
- toggle-sym))))))
- minor-mode-alist)))
+ (cons
+ "Minor Mode Toggles"
+ (delq nil (mapcar
+ #'(lambda (x)
+ (let* ((toggle-sym (car x))
+ (toggle-fun (or (get toggle-sym
+ 'modeline-toggle-function)
+ (and (commandp toggle-sym)
+ toggle-sym)))
+ (menu-tag (or (get toggle-sym :menu-tag nil)
+ (symbol-name (if (symbolp toggle-fun)
+ toggle-fun
+ toggle-sym))
+ ;; Here a function should
+ ;; maybe be invoked to
+ ;; beautify the symbol's
+ ;; menu appearance.
+ )))
+ (and toggle-fun
+ (vector menu-tag
+ toggle-fun
+ ;; The following two are wrong
+ ;; because of possible name
+ ;; clashes.
+ ;:active (get toggle-sym :active t)
+ ;:included (get toggle-sym :included t)
+ :style 'toggle
+ :selected (and (boundp toggle-sym)
+ toggle-sym)))))
+ minor-mode-alist)))
event)))
(defvar modeline-minor-mode-map (make-sparse-keymap 'modeline-minor-mode-map)
--
Hrvoje Niksic <hniksic(a)srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
Unspeakable horrors from outer space paralyze the living and
resurrect the dead!