#include "config.h"
#include <stdio.h>
-#undef NULL
#include "lisp.h"
#include "commands.h"
#include "buffer.h"
int last_abbrev_point;
+/* Hook to run before expanding any abbrev. */
+
+Lisp_Object Vpre_abbrev_expand_hook, Qpre_abbrev_expand_hook;
\f
DEFUN ("make-abbrev-table", Fmake_abbrev_table, Smake_abbrev_table, 0, 0, 0,
"Create a new, empty abbrev table object.")
Lisp_Object sym, oexp, ohook, tem;
CHECK_VECTOR (table, 0);
CHECK_STRING (name, 1);
- if (!NULL (expansion))
+ if (!NILP (expansion))
CHECK_STRING (expansion, 2);
- if (NULL (count))
+ if (NILP (count))
count = make_number (0);
else
CHECK_NUMBER (count, 0);
ohook = XSYMBOL (sym)->function;
if (!((EQ (oexp, expansion)
|| (XTYPE (oexp) == Lisp_String && XTYPE (expansion) == Lisp_String
- && (tem = Fstring_equal (oexp, expansion), !NULL (tem))))
+ && (tem = Fstring_equal (oexp, expansion), !NILP (tem))))
&&
(EQ (ohook, hook)
- || (tem = Fequal (ohook, hook), !NULL (tem)))))
+ || (tem = Fequal (ohook, hook), !NILP (tem)))))
abbrevs_changed = 1;
Fset (sym, expansion);
(name, expansion)
Lisp_Object name, expansion;
{
- if (NULL (current_buffer->abbrev_table))
+ if (NILP (current_buffer->abbrev_table))
error ("Major mode has no abbrev table");
Fdefine_abbrev (current_buffer->abbrev_table, Fdowncase (name),
{
Lisp_Object sym;
CHECK_STRING (abbrev, 0);
- if (!NULL (table))
+ if (!NILP (table))
sym = Fintern_soft (abbrev, table);
else
{
sym = Qnil;
- if (!NULL (current_buffer->abbrev_table))
+ if (!NILP (current_buffer->abbrev_table))
sym = Fintern_soft (abbrev, current_buffer->abbrev_table);
- if (NULL (XSYMBOL (sym)->value))
+ if (NILP (XSYMBOL (sym)->value))
sym = Qnil;
- if (NULL (sym))
+ if (NILP (sym))
sym = Fintern_soft (abbrev, Vglobal_abbrev_table);
}
- if (NULL (XSYMBOL (sym)->value)) return Qnil;
+ if (NILP (XSYMBOL (sym)->value)) return Qnil;
return sym;
}
{
Lisp_Object sym;
sym = Fabbrev_symbol (abbrev, table);
- if (NULL (sym)) return sym;
+ if (NILP (sym)) return sym;
return Fsymbol_value (sym);
}
\f
register Lisp_Object sym;
Lisp_Object expansion, hook, tem;
+ if (!NILP (Vrun_hooks))
+ call1 (Vrun_hooks, Qpre_abbrev_expand_hook);
+
if (XBUFFER (Vabbrev_start_location_buffer) != current_buffer)
Vabbrev_start_location = Qnil;
- if (!NULL (Vabbrev_start_location))
+ if (!NILP (Vabbrev_start_location))
{
tem = Vabbrev_start_location;
CHECK_NUMBER_COERCE_MARKER (tem, 0);
sym = oblookup (current_buffer->abbrev_table, buffer, p - buffer);
else
XFASTINT (sym) = 0;
- if (XTYPE (sym) == Lisp_Int || NULL (XSYMBOL (sym)->value))
+ if (XTYPE (sym) == Lisp_Int || NILP (XSYMBOL (sym)->value))
sym = oblookup (Vglobal_abbrev_table, buffer, p - buffer);
- if (XTYPE (sym) == Lisp_Int || NULL (XSYMBOL (sym)->value))
+ if (XTYPE (sym) == Lisp_Int || NILP (XSYMBOL (sym)->value))
return Qnil;
if (INTERACTIVE && !EQ (minibuf_window, selected_window))
else if (uccount)
{
/* Abbrev included some caps. Cap first initial of expansion */
- idx = point;
+ int old_zv = ZV;
+ int old_pt = point;
+
+ /* Don't let Fcapitalize_word operate on text after point. */
+ ZV = point;
SET_PT (wordstart);
Fcapitalize_word (make_number (1));
- SET_PT (idx);
+
+ SET_PT (old_pt);
+ ZV = old_zv;
}
hook = XSYMBOL (sym)->function;
- if (!NULL (hook))
+ if (!NILP (hook))
call0 (hook);
return Qt;
Lisp_Object sym, stream;
{
Lisp_Object name;
- if (NULL (XSYMBOL (sym)->value))
+ if (NILP (XSYMBOL (sym)->value))
return;
insert (" (", 5);
XSET (name, Lisp_String, XSYMBOL (sym)->name);
{
Lisp_Object one;
- if (NULL (XSYMBOL (sym)->value))
+ if (NILP (XSYMBOL (sym)->value))
return;
one = make_number (1);
Fprin1 (Fsymbol_name (sym), stream);
Fprin1 (XSYMBOL (sym)->plist, stream);
Findent_to (make_number (20), one);
Fprin1 (XSYMBOL (sym)->value, stream);
- if (!NULL (XSYMBOL (sym)->function))
+ if (!NILP (XSYMBOL (sym)->function))
{
Findent_to (make_number (45), one);
Fprin1 (XSYMBOL (sym)->function, stream);
XSET (stream, Lisp_Buffer, current_buffer);
- if (!NULL (readable))
+ if (!NILP (readable))
{
insert_string ("(");
Fprin1 (name, stream);
CHECK_SYMBOL (tabname, 0);
table = Fboundp (tabname);
- if (NULL (table) || (table = Fsymbol_value (tabname), NULL (table)))
+ if (NILP (table) || (table = Fsymbol_value (tabname), NILP (table)))
{
table = Fmake_abbrev_table ();
Fset (tabname, table);
}
CHECK_VECTOR (table, 0);
- for (;!NULL (defns); defns = Fcdr (defns))
+ for (;!NILP (defns); defns = Fcdr (defns))
{
elt = Fcar (defns);
name = Fcar (elt);
"*Set non-nil means expand multi-word abbrevs all caps if abbrev was so.");
abbrev_all_caps = 0;
+ DEFVAR_LISP ("pre-abbrev-expand-hook", &Vpre_abbrev_expand_hook,
+ "Function or functions to be called before abbrev expansion is done.\n\
+This is the first thing that `expand-abbrev' does, and so this may change\n\
+the current abbrev table before abbrev lookup happens.");
+ Vpre_abbrev_expand_hook = Qnil;
+ Qpre_abbrev_expand_hook = intern ("pre-abbrev-expand-hook");
+ staticpro (&Qpre_abbrev_expand_hook);
+
defsubr (&Smake_abbrev_table);
defsubr (&Sclear_abbrev_table);
defsubr (&Sdefine_abbrev);