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: Optimizations for flymake Date: Mon, 01 Nov 2004 23:37:59 +0100 Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1099348752 1305 80.91.229.6 (1 Nov 2004 22:39:12 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 1 Nov 2004 22:39:12 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 01 23:38:57 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 1COkpE-0008Ab-00 for ; Mon, 01 Nov 2004 23:38:56 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1COkxF-0002Vw-Oy for ged-emacs-devel@m.gmane.org; Mon, 01 Nov 2004 17:47:13 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1COkwl-0002Id-61 for emacs-devel@gnu.org; Mon, 01 Nov 2004 17:46:43 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1COkwj-0002HR-3Z for emacs-devel@gnu.org; Mon, 01 Nov 2004 17:46:42 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1COkwi-0002H3-QL for emacs-devel@gnu.org; Mon, 01 Nov 2004 17:46:40 -0500 Original-Received: from [195.41.46.237] (helo=pfepc.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.34) id 1COko8-0006jM-UF for emacs-devel@gnu.org; Mon, 01 Nov 2004 17:37:49 -0500 Original-Received: from kfs-l.imdomain.dk.cua.dk (0x503e2644.bynxx3.adsl-dhcp.tele.dk [80.62.38.68]) by pfepc.post.tele.dk (Postfix) with SMTP id 2B112262843; Mon, 1 Nov 2004 23:37:47 +0100 (CET) Original-To: Pavel Kobiakov 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:29281 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:29281 Hi Pavel, The byte-compiler explicitly knows how to handle (i.e. eliminate) code conditioned by (if (featurep 'xemacs) ...) and it is also faster to use defsubst for trivial functions. Here is a patch to flymake.el which uses these optimizations, and also passes the byte-compiler without warnings (except for makehash which is obsolete in 21.4): *** flymake.el 01 Nov 2004 23:10:05 +0100 1.4 --- flymake.el 01 Nov 2004 23:32:52 +0100 *************** *** 36,83 **** (provide 'flymake) ;;;; [[ Overlay compatibility (autoload 'make-overlay "overlay" "Overlay compatibility kit." t) (autoload 'overlayp "overlay" "Overlay compatibility kit." t) (autoload 'overlays-in "overlay" "Overlay compatibility kit." t) (autoload 'delete-overlay "overlay" "Overlay compatibility kit." t) (autoload 'overlay-put "overlay" "Overlay compatibility kit." t) (autoload 'overlay-get "overlay" "Overlay compatibility kit." t) ;;;; ]] ;;;; [[ cross-emacs compatibility routines ! (defvar flymake-emacs ! (cond ! ((string-match "XEmacs" emacs-version) 'xemacs) ! (t 'emacs) ! ) ! "Currently used emacs flavor" ! ) ! ! (defun flymake-makehash(&optional test) ! (cond ! ((equal flymake-emacs 'xemacs) (if test (make-hash-table :test test) (make-hash-table))) ! (t (makehash test)) ! ) ! ) - (defun flymake-time-to-float(&optional tm) - "Convert `current-time` to a float number of seconds." - (multiple-value-bind (s0 s1 s2) (or tm (current-time)) - (+ (* (float (ash 1 16)) s0) (float s1) (* 0.0000001 s2))) - ) (defun flymake-float-time() ! (cond ! ((equal flymake-emacs 'xemacs) (flymake-time-to-float (current-time))) ! (t (float-time)) ! ) ! ) ! ! (defun flymake-replace-regexp-in-string(regexp rep str) ! (cond ! ((equal flymake-emacs 'xemacs) (replace-in-string str regexp rep)) ! (t (replace-regexp-in-string regexp rep str)) ! ) ! ) (defun flymake-split-string-remove-empty-edges(str pattern) "split, then remove first and/or last in case it's empty" --- 36,68 ---- (provide 'flymake) ;;;; [[ Overlay compatibility + (if (featurep 'xemacs) (progn (autoload 'make-overlay "overlay" "Overlay compatibility kit." t) (autoload 'overlayp "overlay" "Overlay compatibility kit." t) (autoload 'overlays-in "overlay" "Overlay compatibility kit." t) (autoload 'delete-overlay "overlay" "Overlay compatibility kit." t) (autoload 'overlay-put "overlay" "Overlay compatibility kit." t) (autoload 'overlay-get "overlay" "Overlay compatibility kit." t) + )) ;; xemacs ;;;; ]] ;;;; [[ cross-emacs compatibility routines ! (defsubst flymake-makehash(&optional test) ! (if (featurep 'xemacs) ! (if test (make-hash-table :test test) (make-hash-table)) ! (makehash test))) (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))) ! ! (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))) (defun flymake-split-string-remove-empty-edges(str pattern) "split, then remove first and/or last in case it's empty" *************** *** 91,109 **** splitted ) ) ! (defun flymake-split-string(str pattern) ! (cond ! ((equal flymake-emacs 'xemacs) (flymake-split-string-remove-empty-edges str pattern)) ! (t (flymake-split-string-remove-empty-edges str pattern)) ! ) ! ) ! ! (defun flymake-get-temp-dir() ! (cond ! ((equal flymake-emacs 'xemacs) (temp-directory)) ! (t temporary-file-directory) ! ) ! ) (defun flymake-line-beginning-position() (save-excursion --- 76,90 ---- splitted ) ) ! (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))) ! ! (defsubst flymake-get-temp-dir() ! (if (featurep 'xemacs) ! (temp-directory) ! temporary-file-directory)) (defun flymake-line-beginning-position() (save-excursion *************** *** 120,138 **** ) (defun flymake-popup-menu(pos menu-data) ! (cond ! ((equal flymake-emacs '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)) ! ) ! ) ! (t (x-popup-menu pos (flymake-make-emacs-menu menu-data))) ! ) ! ) (defun flymake-make-emacs-menu(menu-data) (let* ((menu-title (nth 0 menu-data)) --- 101,115 ---- ) (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)))) (defun flymake-make-emacs-menu(menu-data) (let* ((menu-title (nth 0 menu-data)) *************** *** 149,154 **** --- 126,133 ---- (defun flymake-nop() ) + (if (featurep 'xemacs) (progn + (defun flymake-make-xemacs-menu(menu-data) (let* ((menu-title (nth 0 menu-data)) (menu-items (nth 1 menu-data)) *************** *** 175,194 **** ) ) (defun flymake-current-row() "return current row in current frame" ! (cond ! ((equal flymake-emacs 'xemacs) (count-lines (window-start) (point))) ! (t (+ (car (cdr (window-edges))) (count-lines (window-start) (point)))) ! ) ! ) ! ! (defun flymake-selected-frame() ! (cond ! ((equal flymake-emacs 'xemacs) (selected-window)) ! (t (selected-frame)) ! ) ! ) ;;;; ]] --- 154,172 ---- ) ) + )) ;; xemacs + + (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))))) ! ! (defsubst flymake-selected-frame() ! (if (featurep 'xemacs) ! (selected-window) ! (selected-frame))) ;;;; ]] *************** *** 547,552 **** --- 525,534 ---- :type 'integer ) + (defvar flymake-included-file-name nil ; this is used to pass a parameter to a sort predicate below + "" + ) + (defun flymake-find-possible-master-files(file-name master-file-dirs masks) "find (by name and location) all posible master files, which are .cpp and .c for and .h. Files are searched for starting from the .h directory and max max-level parent dirs. *************** *** 593,602 **** ) ) - (defvar flymake-included-file-name nil ; this is used to pass a parameter to a sort predicate below - "" - ) - (defun flymake-master-file-compare(file-one file-two) "used in sort to move most possible file names to the beginning of the list (File.h -> File.cpp moved to top" (and (equal (file-name-sans-extension flymake-included-file-name) --- 575,580 ---- *************** *** 1270,1276 **** 2 4 nil 5) ) ;; compilation-error-regexp-alist) ! (flymake-reformat-err-line-patterns-from-compile-el compilation-error-regexp-alist-alist)) "patterns for matching error/warning lines, (regexp file-idx line-idx err-text-idx). Use flymake-reformat-err-line-patterns-from-compile-el to add patterns from compile.el" ) ;(defcustom flymake-err-line-patterns --- 1248,1254 ---- 2 4 nil 5) ) ;; compilation-error-regexp-alist) ! (flymake-reformat-err-line-patterns-from-compile-el compilation-error-regexp-alist-alist)) "patterns for matching error/warning lines, (regexp file-idx line-idx err-text-idx). Use flymake-reformat-err-line-patterns-from-compile-el to add patterns from compile.el" ) ;(defcustom flymake-err-line-patterns *************** *** 1959,1964 **** --- 1937,1954 ---- (setq minor-mode-alist (cons '(flymake-mode flymake-mode-line) minor-mode-alist)) ) + (defcustom flymake-start-syntax-check-on-newline t + "start syntax check if newline char was added/removed from the buffer" + :group 'flymake + :type 'boolean + ) + + (defcustom flymake-start-syntax-check-on-find-file t + "statr syntax check on find file" + :group 'flymake + :type 'boolean + ) + ;;;###autoload (defun flymake-mode-on() "turn flymake mode on" *************** *** 2004,2015 **** ) ) - (defcustom flymake-start-syntax-check-on-newline t - "start syntax check if newline char was added/removed from the buffer" - :group 'flymake - :type 'boolean - ) - (defun flymake-after-change-function(start stop len) "Start syntax check for current buffer if it isn't already running" ;+(flymake-log 0 "setting change time to %s" (flymake-float-time)) --- 1994,1999 ---- *************** *** 2038,2049 **** ) ) - (defcustom flymake-start-syntax-check-on-find-file t - "statr syntax check on find file" - :group 'flymake - :type 'boolean - ) - (defun flymake-find-file-hook() ;+(when flymake-start-syntax-check-on-find-file ;+ (flymake-log 3 "starting syntax check on file open") --- 2022,2027 ---- -- Kim F. Storm http://www.cua.dk