From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: Optimizations for flymake Date: Tue, 02 Nov 2004 10:10:45 +0100 Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1099386843 7996 80.91.229.6 (2 Nov 2004 09:14:03 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 2 Nov 2004 09:14:03 +0000 (UTC) Cc: Pavel Kobiakov , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 02 10:13:52 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1COujg-0002wJ-00 for ; Tue, 02 Nov 2004 10:13:52 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1COuri-0007UJ-QF for ged-emacs-devel@m.gmane.org; Tue, 02 Nov 2004 04:22:10 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1COupR-0006uS-85 for emacs-devel@gnu.org; Tue, 02 Nov 2004 04:19:49 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1COupL-0006ts-U4 for emacs-devel@gnu.org; Tue, 02 Nov 2004 04:19:48 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1COupJ-0006t6-SD for emacs-devel@gnu.org; Tue, 02 Nov 2004 04:19:42 -0500 Original-Received: from [212.88.64.25] (helo=mail-relay.sonofon.dk) by monty-python.gnu.org with smtp (Exim 4.34) id 1COugW-0001Jf-Qu for emacs-devel@gnu.org; Tue, 02 Nov 2004 04:10:37 -0500 Original-Received: (qmail 50946 invoked from network); 2 Nov 2004 09:10:34 -0000 Original-Received: from unknown (HELO kfs-l.imdomain.dk.cua.dk) (213.83.150.2) by 0 with SMTP; 2 Nov 2004 09:10:34 -0000 Original-To: Stefan In-Reply-To: (Stefan's message of "Mon, 01 Nov 2004 19:17:13 -0500") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:29302 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:29302 Stefan 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 http://www.cua.dk