Jerry James <james(a)xemacs.org> writes:
(when (eq (function-max-args #'pos-visible-in-window-p) 2)
(defconst internal-pos-visible-in-window-p
(symbol-function 'pos-visible-in-window-p)
"The builtin function originally named `pos-visible-in-window-p'.")
(fset 'pos-visible-in-window-p
#'(lambda (&optional pos window partially)
"Returns t if position POS is currently on the frame in WINDOW.
Returns nil if that position is scrolled vertically out of view.
If a character is only partially visible, nil is returned, unless the
optional argument PARTIALLY is non-nil.
POS defaults to point in WINDOW's buffer; WINDOW, to the selected window."
(funcall internal-pos-visible-in-window-p pos window))))
Should I use defadvice instead? (FWIW, I first used lexical-let instead
of the defconst above, but that mangled the docstring of
pos-visible-in-window-p. This is essentially what lexical-let expands
to, anyway.)
I'm not sure how the future package is supposed to work, but I like
the Lisp code that is universally loaded not to load the "advice"
package. I don't use "advice" myself, and it has the nasty habit of
loading the byte-compiler, which well-behaved code shouldn't do.
To preserve the docstring, you can put the `defun' inside
`lexical-let', but then the arglist becomes "&rest --cl-rest--", which
sucks. I'd use this:
(fset 'pos-visible-in-window-p
`(lambda (&optional pos window partially)
"...docstring goes here..."
(funcall ,(symbol-function 'pos-visible-in-window-p)
pos window)))
The only problem with this is that this lambda remains uncompiled.
But since no macro expansions are involved, that's probably OK anyway.
I'll look into fixing `lexical-let' to generate more pleasant function
arguments.