From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Liu Newsgroups: gmane.emacs.bugs Subject: bug#16077: 24.3; cleanup flymake Date: Sat, 07 Dec 2013 01:04:49 +0800 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1386349766 22132 80.91.229.3 (6 Dec 2013 17:09:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 6 Dec 2013 17:09:26 +0000 (UTC) To: 16077@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 06 18:09:30 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VoyuA-0000bM-3y for geb-bug-gnu-emacs@m.gmane.org; Fri, 06 Dec 2013 18:09:30 +0100 Original-Received: from localhost ([::1]:60462 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Voyu9-00012D-H2 for geb-bug-gnu-emacs@m.gmane.org; Fri, 06 Dec 2013 12:09:29 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Voyqz-00059j-QM for bug-gnu-emacs@gnu.org; Fri, 06 Dec 2013 12:06:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Voyqp-0004Yy-HZ for bug-gnu-emacs@gnu.org; Fri, 06 Dec 2013 12:06:13 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48591) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Voyqp-0004Yj-6Y for bug-gnu-emacs@gnu.org; Fri, 06 Dec 2013 12:06:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Voyqo-0008MF-K9; Fri, 06 Dec 2013 12:06:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Leo Liu Original-Sender: "Debbugs-submit" Resent-CC: monnier@iro.umontreal.ca, bug-gnu-emacs@gnu.org Resent-Date: Fri, 06 Dec 2013 17:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 16077 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: Stefan Monnier Original-Received: via spool by submit@debbugs.gnu.org id=B.138634952932080 (code B ref -1); Fri, 06 Dec 2013 17:06:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 6 Dec 2013 17:05:29 +0000 Original-Received: from localhost ([127.0.0.1]:34376 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VoyqF-0008LL-OV for submit@debbugs.gnu.org; Fri, 06 Dec 2013 12:05:29 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:37997) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VoyqC-0008LC-St for submit@debbugs.gnu.org; Fri, 06 Dec 2013 12:05:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Voyq3-0004OK-Po for submit@debbugs.gnu.org; Fri, 06 Dec 2013 12:05:24 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:54964) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Voyq3-0004OE-NE for submit@debbugs.gnu.org; Fri, 06 Dec 2013 12:05:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Voypv-0003sX-7B for bug-gnu-emacs@gnu.org; Fri, 06 Dec 2013 12:05:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Voypm-000415-Mh for bug-gnu-emacs@gnu.org; Fri, 06 Dec 2013 12:05:07 -0500 Original-Received: from mail-pb0-x235.google.com ([2607:f8b0:400e:c01::235]:32975) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Voypm-00040Z-9K for bug-gnu-emacs@gnu.org; Fri, 06 Dec 2013 12:04:58 -0500 Original-Received: by mail-pb0-f53.google.com with SMTP id ma3so1389617pbc.40 for ; Fri, 06 Dec 2013 09:04:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:mime-version:content-type; bh=uenZ9+Yz60Wg+bz3g1CpRDNqCPJIx6a+T/iwSDGLBFk=; b=JRgSBsGa4dCX636M0ldkpp9JVOhdyBsqxETkGRLfSZ8v2nN59aDDdDogv/DaiPS0HF EDGx0/xFvYs8hSJ6ww5qOew7RTYvyIEC19T58LO4d855R3C/XQE7KHRtLJybmhAuU7dd r9X8jTq/MNAoD8brA6PMuBtTLYkYP/sgwlLwSNP5h4JZ3oNg9Xoh+uIFUk+L9khIr2yf +B1fgAUDR/5jBfzL00HyArOV+5T45CE7mpK67SKjiRTvd4on2RrzuMoqOXoYe4gqHtfM p8/XtPwQZEhx/2Y9VfKvp3gLpJR5hXHUReslEKVMcVID+0IHuWCMb49Uu1oDsMUK8uAv ghZQ== X-Received: by 10.66.142.132 with SMTP id rw4mr5469696pab.6.1386349496811; Fri, 06 Dec 2013 09:04:56 -0800 (PST) Original-Received: from localhost ([123.119.93.169]) by mx.google.com with ESMTPSA id hn5sm1993513pbb.25.2013.12.06.09.04.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Dec 2013 09:04:55 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:81543 Archived-At: --=-=-= Content-Type: text/plain First patch to clean up flymake and more to come. This basically removes xemacs support. Any reasons not to? Leo --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=flymake.diff Content-Description: flymake.diff diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index ab86b83f..0f1f4fff 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -1,4 +1,4 @@ -;;; flymake.el --- a universal on-the-fly syntax checker +;;; flymake.el --- a universal on-the-fly syntax checker -*- lexical-binding: t; -*- ;; Copyright (C) 2003-2013 Free Software Foundation, Inc. @@ -36,77 +36,27 @@ ;;; Code: (eval-when-compile (require 'cl-lib)) -(if (featurep 'xemacs) (require 'overlay)) -(defvar flymake-is-running nil +(defvar-local flymake-is-running nil "If t, flymake syntax check process is running for the current buffer.") -(make-variable-buffer-local 'flymake-is-running) -(defvar flymake-timer nil +(defvar-local flymake-timer nil "Timer for starting syntax check.") -(make-variable-buffer-local 'flymake-timer) -(defvar flymake-last-change-time nil +(defvar-local flymake-last-change-time nil "Time of last buffer change.") -(make-variable-buffer-local 'flymake-last-change-time) -(defvar flymake-check-start-time nil +(defvar-local flymake-check-start-time nil "Time at which syntax check was started.") -(make-variable-buffer-local 'flymake-check-start-time) -(defvar flymake-check-was-interrupted nil +(defvar-local flymake-check-was-interrupted nil "Non-nil if syntax check was killed by `flymake-compile'.") -(make-variable-buffer-local 'flymake-check-was-interrupted) -(defvar flymake-err-info nil +(defvar-local flymake-err-info nil "Sorted list of line numbers and lists of err info in the form (file, err-text).") -(make-variable-buffer-local 'flymake-err-info) -(defvar flymake-new-err-info nil +(defvar-local flymake-new-err-info nil "Same as `flymake-err-info', effective when a syntax check is in progress.") -(make-variable-buffer-local 'flymake-new-err-info) - -;;;; [[ cross-emacs compatibility routines -(defsubst flymake-makehash (&optional test) - "Create and return a new hash table using TEST to compare keys. -It uses the function `make-hash-table' to make a hash-table if -you use GNU Emacs, otherwise it uses `makehash'." - (if (fboundp 'make-hash-table) - (if test (make-hash-table :test test) (make-hash-table)) - (with-no-warnings - (makehash test)))) - -(defalias 'flymake-float-time - (if (fboundp 'float-time) - 'float-time - (if (featurep 'xemacs) - (lambda () - (multiple-value-bind (s0 s1 s2) (values-list (current-time)) - (+ (* (float (ash 1 16)) s0) (float s1) (* 0.0000001 s2))))))) - -(defalias 'flymake-replace-regexp-in-string - (if (eval-when-compile (fboundp 'replace-regexp-in-string)) - 'replace-regexp-in-string - (lambda (regexp rep str) - (replace-in-string str regexp rep)))) - -(defalias 'flymake-split-string - (if (condition-case nil (equal (split-string " bc " " " t) '("bc")) - (error nil)) - (lambda (str pattern) (split-string str pattern t)) - (lambda (str pattern) - "Split STR into a list of substrings bounded by PATTERN. -Zero-length substrings at the beginning and end of the list are omitted." - (let ((split (split-string str pattern))) - (while (equal (car split) "") (setq split (cdr split))) - (setq split (nreverse split)) - (while (equal (car split) "") (setq split (cdr split))) - (nreverse split))))) - -(defalias 'flymake-get-temp-dir - (if (fboundp 'temp-directory) - 'temp-directory - (lambda () temporary-file-directory))) (defun flymake-posn-at-point-as-event (&optional position window dx dy) "Return pixel position of top left corner of glyph at POSITION. @@ -120,12 +70,11 @@ (defun flymake-posn-at-point-as-event (&optional position window dx dy) selected window. DX and DY specify optional offsets from the top left of the glyph." - (unless window (setq window (selected-window))) - (unless position (setq position (window-point window))) - (unless dx (setq dx 0)) - (unless dy (setq dy 0)) - - (let* ((pos (posn-at-point position window)) + (let* ((window (or window (selected-window))) + (position (or position (window-point window))) + (dx (or dx 0)) + (dy (or dy 0)) + (pos (posn-at-point position window)) (x-y (posn-x-y pos)) (edges (window-inside-pixel-edges window)) (win-x-y (window-pixel-edges window))) @@ -135,25 +84,16 @@ (defun flymake-posn-at-point-as-event (&optional position window dx dy) (+ (cdr x-y) (cadr edges) (- (cadr win-x-y)) dy))) (list 'mouse-1 pos))) +;;; XXX: get rid of the following two functions + (defun flymake-popup-menu (menu-data) "Pop up the flymake menu at point, using the data MENU-DATA. POS is a list of the form ((X Y) WINDOW), where X and Y are pixels positions from the top left corner of WINDOW's frame. MENU-DATA is a list of error and warning messages returned by `flymake-make-err-menu-data'." - (if (featurep 'xemacs) - (let* ((pos (flymake-get-point-pixel-pos)) - (x-pos (nth 0 pos)) - (y-pos (nth 1 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 (if (eval-when-compile (fboundp 'posn-at-point)) - (flymake-posn-at-point-as-event) - (list (flymake-get-point-pixel-pos) (selected-window))) - (flymake-make-emacs-menu menu-data)))) + (x-popup-menu (flymake-posn-at-point-as-event) + (flymake-make-emacs-menu menu-data))) (defun flymake-make-emacs-menu (menu-data) "Return a menu specifier using MENU-DATA. @@ -167,72 +107,12 @@ (defun flymake-make-emacs-menu (menu-data) menu-items))) (list menu-title (cons "" menu-commands)))) -(if (featurep 'xemacs) (progn - -(defun flymake-nop () - "Do nothing." - nil) - -(defun flymake-make-xemacs-menu (menu-data) - "Return a menu specifier using MENU-DATA." - (let* ((menu-title (nth 0 menu-data)) - (menu-items (nth 1 menu-data)) - (menu-commands nil)) - (setq menu-commands (mapcar (lambda (foo) - (vector (nth 0 foo) (or (nth 1 foo) '(flymake-nop)) t)) - menu-items)) - (cons menu-title menu-commands))) - -)) ;; xemacs - -(unless (eval-when-compile (fboundp 'posn-at-point)) - -(defun flymake-current-row () - "Return current row number in current frame." - (if (fboundp 'window-edges) - (+ (car (cdr (window-edges))) (count-lines (window-start) (point))) - (count-lines (window-start) (point)))) - -(defun flymake-selected-frame () - "Return the frame that is now selected." - (if (fboundp 'window-edges) - (selected-frame) - (selected-window))) - -(defun flymake-get-point-pixel-pos () - "Return point position in pixels: (x, y)." - (let ((mouse-pos (mouse-position)) - (pixel-pos nil) - (ret nil)) - (if (car (cdr mouse-pos)) - (progn - (set-mouse-position (flymake-selected-frame) (current-column) (flymake-current-row)) - (setq pixel-pos (mouse-pixel-position)) - (set-mouse-position (car mouse-pos) (car (cdr mouse-pos)) (cdr (cdr mouse-pos))) - (setq ret (list (car (cdr pixel-pos)) (cdr (cdr pixel-pos))))) - (progn - (setq ret '(0 0)))) - (flymake-log 3 "mouse pos is %s" ret) - ret)) - -) ;; End of (unless (fboundp 'posn-at-point) - -;;;; ]] - (defcustom flymake-log-level -1 "Logging level, only messages with level lower or equal will be logged. -1 = NONE, 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG" :group 'flymake :type 'integer) - -;; (defcustom flymake-log-file-name "~/flymake.log" -;; "Where to put the flymake log if logging is enabled. -;; -;; See `flymake-log-level' if you want to control what is logged." -;; :group 'flymake -;; :type 'string) - (defun flymake-log (level text &rest args) "Log a message at level LEVEL. If LEVEL is higher than `flymake-log-level', the message is @@ -241,13 +121,7 @@ (defun flymake-log (level text &rest args) are the string substitutions (see the function `format')." (if (<= level flymake-log-level) (let* ((msg (apply 'format text args))) - (message "%s" msg) - ;;(with-temp-buffer - ;; (insert msg) - ;; (insert "\n") - ;; (flymake-save-buffer-in-file "~/flymake.log") ; make log file name customizable - ;;) - ))) + (message "%s" msg)))) (defun flymake-ins-after (list pos val) "Insert VAL into LIST after position POS. @@ -266,8 +140,7 @@ (defun flymake-set-at (list pos val) (defvar flymake-processes nil "List of currently active flymake processes.") -(defvar flymake-output-residual nil) -(make-variable-buffer-local 'flymake-output-residual) +(defvar-local flymake-output-residual nil) (defgroup flymake nil "Universal on-the-fly syntax checker." @@ -356,7 +229,7 @@ (defun flymake-get-real-file-name-function (file-name) (or (nth 2 (flymake-get-file-name-mode-and-masks file-name)) 'flymake-get-real-file-name)) -(defvar flymake-find-buildfile-cache (flymake-makehash 'equal)) +(defvar flymake-find-buildfile-cache (make-hash-table :test #'equal)) (defun flymake-get-buildfile-from-cache (dir-name) "Look up DIR-NAME in cache and return its associated value. @@ -537,6 +410,7 @@ (defun flymake-check-patch-master-file-buffer (flymake-log 2 "found master file %s" master-file-name)) found)) +;;; XXX: remove (defun flymake-replace-region (beg end rep) "Replace text in BUFFER in region (BEG END) with REP." (save-excursion @@ -689,7 +563,7 @@ (defun flymake-post-syntax-check (exit-status command) (setq warn-count (flymake-get-err-count flymake-err-info "w")) (flymake-log 2 "%s: %d error(s), %d warning(s) in %.2f second(s)" (buffer-name) err-count warn-count - (- (flymake-float-time) flymake-check-start-time)) + (- (float-time) flymake-check-start-time)) (setq flymake-check-start-time nil) (if (and (equal 0 err-count) (equal 0 warn-count)) @@ -978,7 +852,7 @@ (defun flymake-split-output (output) Return last one as residual if it does not end with newline char. Returns ((LINES) RESIDUAL)." (when (and output (> (length output) 0)) - (let* ((lines (flymake-split-string output "[\n\r]+")) + (let* ((lines (split-string output "[\n\r]+" t)) (complete (equal "\n" (char-to-string (aref output (1- (length output)))))) (residual nil)) (when (not complete) @@ -1163,18 +1037,18 @@ (defun flymake-get-project-include-dirs-imp (basedir) (shell-quote-argument basedir) " DUMPVARS=INCLUDE_DIRS dumpvars")) (output (shell-command-to-string command-line)) - (lines (flymake-split-string output "\n")) + (lines (split-string output "\n" t)) (count (length lines)) (idx 0) (inc-dirs nil)) (while (and (< idx count) (not (string-match "^INCLUDE_DIRS=.*" (nth idx lines)))) (setq idx (1+ idx))) (when (< idx count) - (let* ((inc-lines (flymake-split-string (nth idx lines) " *-I")) + (let* ((inc-lines (split-string (nth idx lines) " *-I" t)) (inc-count (length inc-lines))) (while (> inc-count 0) (when (not (string-match "^INCLUDE_DIRS=.*" (nth (1- inc-count) inc-lines))) - (push (flymake-replace-regexp-in-string "\"" "" (nth (1- inc-count) inc-lines)) inc-dirs)) + (push (replace-regexp-in-string "\"" "" (nth (1- inc-count) inc-lines)) inc-dirs)) (setq inc-count (1- inc-count))))) (flymake-add-project-include-dirs-to-cache basedir inc-dirs) inc-dirs))) @@ -1190,9 +1064,9 @@ (defun flymake-get-project-include-dirs (basedir) (defun flymake-get-system-include-dirs () "System include dirs - from the 'INCLUDE' env setting." (let* ((includes (getenv "INCLUDE"))) - (if includes (flymake-split-string includes path-separator) nil))) + (if includes (split-string includes path-separator t) nil))) -(defvar flymake-project-include-dirs-cache (flymake-makehash 'equal)) +(defvar flymake-project-include-dirs-cache (make-hash-table :test #'equal)) (defun flymake-get-project-include-dirs-from-cache (base-dir) (gethash base-dir flymake-project-include-dirs-cache)) @@ -1280,7 +1154,7 @@ (defun flymake-start-syntax-check-process (cmd args dir) (setq flymake-is-running t) (setq flymake-last-change-time nil) - (setq flymake-check-start-time (flymake-float-time)) + (setq flymake-check-start-time (float-time)) (flymake-report-status nil "*") (flymake-log 2 "started process %d, command=%s, dir=%s" @@ -1332,7 +1206,7 @@ (defun flymake-on-timer-event (buffer) (with-current-buffer buffer (when (and (not flymake-is-running) flymake-last-change-time - (> (- (flymake-float-time) flymake-last-change-time) + (> (- (float-time) flymake-last-change-time) flymake-no-changes-timeout)) (setq flymake-last-change-time nil) @@ -1512,12 +1386,12 @@ (defcustom flymake-start-syntax-check-on-newline t (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)) + ;;+(flymake-log 0 "setting change time to %s" (float-time)) (let((new-text (buffer-substring start stop))) (when (and flymake-start-syntax-check-on-newline (equal new-text "\n")) (flymake-log 3 "starting syntax check as new-line has been seen") (flymake-start-syntax-check)) - (setq flymake-last-change-time (flymake-float-time)))) + (setq flymake-last-change-time (float-time)))) (defun flymake-after-save-hook () (if (local-variable-p 'flymake-mode (current-buffer)) ; (???) other way to determine whether flymake is active in buffer being saved? @@ -1631,14 +1505,14 @@ (defun flymake-create-temp-with-folder-structure (file-name _prefix) ;; trying to remove the leading / of absolute file names. (slash-pos (string-match "/" dir)) (temp-dir (expand-file-name (substring dir (1+ slash-pos)) - (flymake-get-temp-dir)))) + temporary-file-directory))) (file-truename (expand-file-name (file-name-nondirectory file-name) temp-dir)))) (defun flymake-delete-temp-directory (dir-name) "Attempt to delete temp dir created by `flymake-create-temp-with-folder-structure', do not fail on error." - (let* ((temp-dir (flymake-get-temp-dir)) + (let* ((temp-dir temporary-file-directory) (suffix (substring dir-name (1+ (length temp-dir))))) (while (> (length suffix) 0) --=-=-=--