From: storm@cua.dk (Kim F. Storm)
Cc: Pavel Kobiakov <pk_at_work@yahoo.com>, emacs-devel@gnu.org
Subject: Re: Optimizations for flymake
Date: Tue, 02 Nov 2004 10:10:45 +0100 [thread overview]
Message-ID: <m3ekjcwr8q.fsf@kfs-l.imdomain.dk> (raw)
In-Reply-To: <m1zn21glv7.fsf-monnier+emacs@gnu.org> (Stefan's message of "Mon, 01 Nov 2004 19:17:13 -0500")
Stefan <monnier@iro.umontreal.ca> writes:
>> ! (defsubst flymake-makehash(&optional test)
>> ! (if (featurep 'xemacs)
>> ! (if test (make-hash-table :test test) (make-hash-table))
>> ! (makehash test)))
>
> Why not (if (fboundp 'make-hash-table) ...) ?
Right, that's better.
>
>> (defun flymake-float-time()
>> ! (if (featurep 'xemacs)
>> ! (let ((tm (current-time)))
>> ! (multiple-value-bind (s0 s1 s2) (current-time)
>> ! (+ (* (float (ash 1 16)) s0) (float s1) (* 0.0000001 s2))))
>> ! (float-time)))
>
> Why not (if (fboundp 'float-time) ...) ?
>
Because Emacs doesn't have multiple-value-bind.
>> ! (defsubst flymake-replace-regexp-in-string(regexp rep str)
>> ! (if (featurep 'xemacs)
>> ! (replace-in-string str regexp rep)
>> ! (replace-regexp-in-string regexp rep str)))
>
> Why not (if (fboundp 'replace-regexp-in-string) ...) ?
> I'd actually make it even more efficient than `defsubst':
Like this?
(defalias 'flymake-replace-regexp-in-string
(if (fboundp 'replace-regexp-in-string))
'replace-regexp-in-string
'replace-in-string))
>
>> ! (defsubst flymake-split-string(str pattern)
>> ! (if (featurep 'xemacs)
>> ! (flymake-split-string-remove-empty-edges str pattern)
>> ! (flymake-split-string-remove-empty-edges str pattern)))
>
> Hmmm... isn't this just
> (defalias 'flymake-split-string 'flymake-split-string-remove-empty-edges) ?
Yes -- looks odd.
>
>> ! (defsubst flymake-get-temp-dir()
>> ! (if (featurep 'xemacs)
>> ! (temp-directory)
>> ! temporary-file-directory))
>
> Why not (if (fboundp 'temp-directory) ...) ?
Would work as well -- but it would hide why we make the check...
>
>> (defun flymake-popup-menu(pos menu-data)
>> ! (if (featurep 'xemacs)
>> ! (let* ((x-pos (nth 0 (nth 0 pos)))
>> ! (y-pos (nth 1 (nth 0 pos)))
>> ! (fake-event-props '(button 1 x 1 y 1)))
>> ! (setq fake-event-props (plist-put fake-event-props 'x x-pos))
>> ! (setq fake-event-props (plist-put fake-event-props 'y y-pos))
>> ! (popup-menu (flymake-make-xemacs-menu menu-data) (make-event 'button-press fake-event-props))
>> ! )
>> ! (x-popup-menu pos (flymake-make-emacs-menu menu-data))))
>
> Since Emacs-21 has popup-menu, we should be able to throw away
> flymake-make-emacs-menu and rename flymake-make-xemacs-menu to
> flymake-make-menu:
>
> (defun flymake-popup-menu(pos menu-data)
> (popup-menu (flymake-make-menu menu-data)
> (if (not (featurep 'xemacs))
> pos
> (let* ((x-pos (nth 0 (nth 0 pos)))
> (y-pos (nth 1 (nth 0 pos)))
> (fake-event-props '(button 1 x 1 y 1)))
> (setq fake-event-props (plist-put fake-event-props 'x x-pos))
> (setq fake-event-props (plist-put fake-event-props 'y y-pos))
> (make-event 'button-press fake-event-props)))))
I take your word for it :-)
>
>> (defun flymake-current-row()
>> "return current row in current frame"
>> ! (if (featurep 'xemacs)
>> ! (count-lines (window-start) (point))
>> ! (+ (car (cdr (window-edges))) (count-lines (window-start) (point)))))
>
> I suspect this should be:
>
> (defun flymake-current-row()
> "return current row in current frame"
> (+ (count-lines (window-start) (point))
> (if (fboundp 'window-edges)
> (car (cdr (window-edges)))
> ;; On XEmacs we should probably use something else, but what??
> 0)))
Ok.
>
>> ! (defsubst flymake-selected-frame()
>> ! (if (featurep 'xemacs)
>> ! (selected-window)
>> ! (selected-frame)))
>
> XEmacs has `selected-frame' as well, so the above code looks odd.
> I must be missing something.
Me too.
It also occurred to me that rather than all the autoloads for the
various overlay things, it should simply do:
(require 'overlay)
Emacs has (featurep 'overlay) => t, so there's no need to
condition it with (featurep 'xemacs) either.
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
next prev parent reply other threads:[~2004-11-02 9:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-01 22:37 Optimizations for flymake Kim F. Storm
2004-11-02 0:17 ` Stefan
2004-11-02 9:10 ` Kim F. Storm [this message]
2004-11-02 10:57 ` David Kastrup
2004-11-02 12:21 ` Pavel Kobiakov
2004-11-02 12:34 ` David Kastrup
2004-11-02 15:48 ` Drew Adams
2004-11-03 12:45 ` Richard Stallman
2004-11-02 12:20 ` Stefan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3ekjcwr8q.fsf@kfs-l.imdomain.dk \
--to=storm@cua.dk \
--cc=emacs-devel@gnu.org \
--cc=pk_at_work@yahoo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.