emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/arduino-mode 6d2d112 2/2: Fix warnings when flycheck is un


From: ELPA Syncer
Subject: [nongnu] elpa/arduino-mode 6d2d112 2/2: Fix warnings when flycheck is unavailable and some minor code
Date: Tue, 7 Sep 2021 10:57:21 -0400 (EDT)

branch: elpa/arduino-mode
commit 6d2d1122924370ffa17ce337e3b02ecab79d861b
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: stardiviner <numbchild@gmail.com>

    Fix warnings when flycheck is unavailable and some minor code
    
    Make it work under Emacs ELPA.
---
 .gitignore          |   2 +
 arduino-mode.el     | 127 +++++++++++++++++++++++++---------------------------
 ede-arduino.el      |  99 ++++++++++++++++++++--------------------
 flycheck-arduino.el |   7 ++-
 ob-arduino.el       |  19 ++++----
 5 files changed, 127 insertions(+), 127 deletions(-)

diff --git a/.gitignore b/.gitignore
index 9b4291b..d7747cf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
 # Compiled
 *.elc
+/arduino-mode-autoloads.el
+/arduino-mode-pkg.el
 
 # Packaging
 .cask
diff --git a/arduino-mode.el b/arduino-mode.el
index 9de266b..a24ec4c 100644
--- a/arduino-mode.el
+++ b/arduino-mode.el
@@ -1,4 +1,4 @@
-;;; arduino-mode.el --- Major mode for editing Arduino code
+;;; arduino-mode.el --- Major mode for editing Arduino code  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 2008  Christopher Grim
 ;; Authors: Christopher Grim <christopher.grim@gmail.com>
@@ -45,7 +45,7 @@
   ;; fall back on c-mode
   (c-add-language 'arduino-mode 'c-mode))
 
-(require 'flycheck-arduino)
+;; (require 'flycheck-arduino)
 
 (defgroup arduino-mode nil
   "Customize arduino-mode."
@@ -178,11 +178,12 @@ Value is a symbol.  The possible values are the symbols 
in the
     ("while" "while" c-electric-continued-statement 0)))
 
 (defvar arduino-mode-map
-  (let ((map (c-make-inherited-keymap)))
-    (define-key map (kbd "C-c C-c") 'arduino-upload)
-    (define-key map (kbd "C-c C-v") 'arduino-verify)
-    (define-key map (kbd "C-c C-m") 'arduino-serial-monitor)
-    (define-key map (kbd "C-c C-x") 'arduino-open-with-arduino)
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map c-mode-base-map)
+    (define-key map (kbd "C-c C-c") #'arduino-upload)
+    (define-key map (kbd "C-c C-v") #'arduino-verify)
+    (define-key map (kbd "C-c C-m") #'arduino-serial-monitor)
+    (define-key map (kbd "C-c C-x") #'arduino-open-with-arduino)
     map)
   "Keymap used in arduino-mode buffers.")
 
@@ -209,22 +210,22 @@ Value is a symbol.  The possible values are the symbols 
in the
   (interactive)
   (setq arduino-upload-process-buf (buffer-name))
   (let* ((proc-name "arduino-upload")
-         (proc-buffer "*arduino-upload*")
-         (proc (make-process
-                :command (list arduino-executable "--upload" 
(buffer-file-name))
-                :name proc-name
-                :buffer proc-buffer
-                :sentinel (lambda (proc event)
-                            (if (string= event "finished\n")
-                                (progn
-                                  (with-current-buffer 
arduino-upload-process-buf
-                                    (setq mode-line-process nil))
-                                  (message "Arduino upload succeed."))
-                              (with-current-buffer arduino-upload-process-buf
-                                (display-buffer "*arduino-upload*")))
-                            (setq-local mode-line-process nil)
-                            (with-current-buffer arduino-upload-process-buf
-                              (when spinner-current (spinner-stop)))))))
+         (proc-buffer "*arduino-upload*"))
+    (make-process
+     :command (list arduino-executable "--upload" (buffer-file-name))
+     :name proc-name
+     :buffer proc-buffer
+     :sentinel (lambda (_proc event)
+                 (if (string= event "finished\n")
+                     (progn
+                       (with-current-buffer arduino-upload-process-buf
+                         (setq mode-line-process nil))
+                       (message "Arduino upload succeed."))
+                   (with-current-buffer arduino-upload-process-buf
+                     (display-buffer "*arduino-upload*")))
+                 (setq-local mode-line-process nil)
+                 (with-current-buffer arduino-upload-process-buf
+                   (when spinner-current (spinner-stop)))))
     (spinner-start arduino-spinner-type)
     (setq mode-line-process proc-name)))
 
@@ -235,21 +236,23 @@ Value is a symbol.  The possible values are the symbols 
in the
   (interactive)
   (setq arduino-verify-process-buf (buffer-name))
   (let* ((proc-name "arduino-verify")
-         (proc-buffer "*arduino-verify*")
-         (proc (make-process
-                :command (list arduino-executable "--verify" 
(buffer-file-name))
-                :name proc-name
-                :buffer proc-buffer
-                :sentinel (lambda (proc event)
-                            (if (string= event "finished\n")
-                                (progn
-                                  (with-current-buffer 
arduino-verify-process-buf
-                                    (setq mode-line-process nil))
-                                  (message "Arduino verify build succeed."))
-                              (display-buffer "*arduino-verify*"))
-                            (setq-local mode-line-process nil)
-                            (with-current-buffer arduino-verify-process-buf
-                              (when spinner-current (spinner-stop)))))))
+         (proc-buffer "*arduino-verify*"))
+    ;; FIXME: Reduce redundancy with `arduino-upload' and
+    ;; `arduino-open-with-arduino'.
+    (make-process
+     :command (list arduino-executable "--verify" (buffer-file-name))
+     :name proc-name
+     :buffer proc-buffer
+     :sentinel (lambda (_proc event)
+                 (if (string= event "finished\n")
+                     (progn
+                       (with-current-buffer arduino-verify-process-buf
+                         (setq mode-line-process nil))
+                       (message "Arduino verify build succeed."))
+                   (display-buffer "*arduino-verify*"))
+                 (setq-local mode-line-process nil)
+                 (with-current-buffer arduino-verify-process-buf
+                   (when spinner-current (spinner-stop)))))
     (spinner-start arduino-spinner-type)
     (setq mode-line-process proc-name)))
 
@@ -260,31 +263,29 @@ Value is a symbol.  The possible values are the symbols 
in the
   (interactive)
   (setq arduino-open-process-buf (buffer-name))
   (let* ((proc-name "arduino-open")
-         (proc-buffer "*arduino-open*")
-         (proc (make-process
-                :command (list arduino-executable (buffer-file-name))
-                :name proc-name
-                :buffer proc-buffer
-                :sentinel (lambda (proc event)
-                            (if (string= event "finished\n")
-                                (progn
-                                  (with-current-buffer arduino-open-process-buf
-                                    (setq mode-line-process nil))
-                                  (message "Opened with Arduino succeed.")))
-                            (setq-local mode-line-process nil)
-                            (with-current-buffer arduino-open-process-buf
-                              (when spinner-current (spinner-stop)))))))
+         (proc-buffer "*arduino-open*"))
+    (make-process
+     :command (list arduino-executable (buffer-file-name))
+     :name proc-name
+     :buffer proc-buffer
+     :sentinel (lambda (_proc event)
+                 (if (string= event "finished\n")
+                     (progn
+                       (with-current-buffer arduino-open-process-buf
+                         (setq mode-line-process nil))
+                       (message "Opened with Arduino succeed.")))
+                 (setq-local mode-line-process nil)
+                 (with-current-buffer arduino-open-process-buf
+                   (when spinner-current (spinner-stop)))))
     (spinner-start arduino-spinner-type)
     (setq mode-line-process proc-name)))
 
-;;; NOTE: Because command-line arduino does not support search and list out
-;;; boards and libraries. So I will not write a sentinel for installing 
process.
+;; NOTE: Because command-line arduino does not support search and list out
+;; boards and libraries. So I will not write a sentinel for installing process.
 (defun arduino-install-boards (board)
   "Install `BOARD' support for Arduino."
-  (interactive (list (completing-read "Arduino install board: "
-                                      '()
-                                      nil nil
-                                      "arduino:sam")))
+  (interactive (list (read-string "Arduino install board: "
+                                  "arduino:sam")))
   (start-process
    "arduino-install-boards"
    "*arduino-install-boards*"
@@ -292,10 +293,8 @@ Value is a symbol.  The possible values are the symbols in 
the
 
 (defun arduino-install-library (library)
   "Install `LIBRARY' support for Arduino."
-  (interactive (list (completing-read "Arduino install library: "
-                                      '()
-                                      nil nil
-                                      "Bridge:1.0.0")))
+  (interactive (list (read-string "Arduino install library: "
+                                  "Bridge:1.0.0")))
   (start-process
    "arduino-install-library"
    "*arduino-install-library*"
@@ -344,12 +343,10 @@ Value is a symbol.  The possible values are the symbols 
in the
   ;; initialization to get the syntactic analysis and similar things working.
   (c-common-init 'arduino-mode)
   
-  (when (version<= emacs-version "28.1")
-    (easy-menu-add arduino-menu))
   (set (make-local-variable 'c-basic-offset) 2)
   (set (make-local-variable 'tab-width) 2)
 
-  (flycheck-arduino-setup))
+  (if (fboundp 'flycheck-mode) (flycheck-arduino-setup)))
 
 ;;;###autoload
 (add-to-list 'auto-mode-alist '("\\.pde\\'" . arduino-mode))
diff --git a/ede-arduino.el b/ede-arduino.el
index e2ff526..0262ecb 100644
--- a/ede-arduino.el
+++ b/ede-arduino.el
@@ -1,4 +1,4 @@
-;;; ede-arduino.el --- EDE support for arduino projects / sketches
+;;; ede-arduino.el --- EDE support for arduino projects / sketches  -*- 
lexical-binding: t; -*-
 ;;
 ;; Copyright (C) 2012 Eric M. Ludlam
 ;;
@@ -106,7 +106,7 @@ Emacs back to the Arduino IDE."
          (kill nil))
     
     (when (not ede-arduino-active-prefs)
-      (setq ede-arduino-active-prefs (ede-arduino-prefs)))
+      (setq ede-arduino-active-prefs (make-instance 'ede-arduino-prefs)))
     
     ;; Only update the prefs if the prefs file changed.
     (when (or (not (oref ede-arduino-active-prefs timestamp))
@@ -172,7 +172,7 @@ This is also where Arduino.mk will be found."
     (with-current-buffer b
       (setq default-directory cd)
       (erase-buffer))
-    (apply 'start-process "arduino" b ede-arduino-arduino-command nil)))
+    (apply #'start-process "arduino" b ede-arduino-arduino-command nil)))
 
 (defun ede-arduino-find-install (&optional full-path)
   "Return the `FULL-PATH' where arduino IDE code is installed.
@@ -336,14 +336,14 @@ Data returned is the intputs needed for the Makefile."
         
         (when kill (kill-buffer buff))
         
-        (ede-arduino-board boardname
-                           :name name
-                           :protocol protocol
-                           :speed speed
-                           :maximum-size size
-                           :mcu mcu
-                           :f_cpu f_cpu
-                           :core core)))))
+        (make-instance 'ede-arduino-board ;; boardname
+                       :name name
+                       :protocol protocol
+                       :speed speed
+                       :maximum-size size
+                       :mcu mcu
+                       :f_cpu f_cpu
+                       :core core)))))
 
 ;;;###autoload
 (defun ede-arduino-root (&optional dir basefile)
@@ -386,14 +386,14 @@ to check."
   (ede-arduino-root dir t))
 
 ;;;###autoload
-(defun ede-arduino-load (dir &optional rootproj)
+(defun ede-arduino-load (dir &optional _rootproj)
   "Return an Arduino project object if there is one.
 Return nil if there isn't one.
 Argument DIR is the directory it is created for.
-ROOTPROJ is nil, sinc there is only one project for a directory tree."
+ROOTPROJ is not used, sinc there is only one project for a directory tree."
   (let* ((root (ede-arduino-root dir))
          (proj (and root (ede-directory-get-open-project root)))
-         (prefs (ede-arduino-sync)))
+         (_prefs (ede-arduino-sync)))
     (if proj
         (progn
           (message "Opening existing project")
@@ -447,25 +447,25 @@ ROOTPROJ is nil, sinc there is only one project for a 
directory tree."
 
 ;;;###autoload
 (defclass ede-arduino-project (ede-project)
-  ((keybindings :initform (("U" . ede-arduino-upload)))
+  ((keybindings :initform '(("U" . ede-arduino-upload)))
    (menu :initform
-         (
-          [ "Upload Project to Board" ede-arduino-upload ]
-          [ "Serial Monitor" cedet-arduino-serial-monitor ]
-          "--"
-          [ "Edit Projectfile" ede-edit-file-target
-            (ede-buffer-belongs-to-project-p) ]
-          "--"
-          [ "Update Version" ede-update-version ede-object ]
-          [ "Version Control Status" ede-vc-project-directory ede-object ]
-          "--"
-          [ "Rescan Project Files" ede-rescan-toplevel t ]
-          )))
+         '(
+           [ "Upload Project to Board" ede-arduino-upload ]
+           [ "Serial Monitor" cedet-arduino-serial-monitor ]
+           "--"
+           [ "Edit Projectfile" ede-edit-file-target
+             (ede-buffer-belongs-to-project-p) ]
+           "--"
+           [ "Update Version" ede-update-version ede-object ]
+           [ "Version Control Status" ede-vc-project-directory ede-object ]
+           "--"
+           [ "Rescan Project Files" ede-rescan-toplevel t ]
+           )))
   "EDE Arduino project.")
 
 ;;; TARGET MANAGEMENT
 ;;
-(cl-defmethod ede-find-target ((proj ede-arduino-project) buffer)
+(cl-defmethod ede-find-target ((proj ede-arduino-project) _buffer)
   "Find an EDE target in PROJ for BUFFER.
 If one doesn't exist, create a new one for this directory."
   (let* ((targets (oref proj targets))
@@ -473,11 +473,11 @@ If one doesn't exist, create a new one for this 
directory."
          (ans (object-assoc dir :path targets))
          )
     (when (not ans)
-      (setq ans (ede-arduino-target dir
-                                    :name (file-name-nondirectory
-                                           (directory-file-name dir))
-                                    :path dir
-                                    :source nil))
+      (setq ans (make-instance 'ede-arduino-target ;; dir
+                               :name (file-name-nondirectory
+                                      (directory-file-name dir))
+                               :path dir
+                               :source nil))
       (object-add-to-list proj :targets ans))
     ans))
 
@@ -511,19 +511,19 @@ Argument COMMAND is the command to use when compiling."
   ;; 2) Call MAKE
   (compile (or command ede-arduino-make-command)))
 
-(cl-defmethod project-compile-target ((obj ede-arduino-target) &optional 
command)
+(cl-defmethod project-compile-target ((_obj ede-arduino-target) &optional 
command)
   "Compile the current target OBJ.
 Argument COMMAND is the command to use for compiling the target."
   (project-compile-project (ede-current-project) command))
 
-(cl-defmethod project-debug-target ((target ede-arduino-target))
+(cl-defmethod project-debug-target ((_target ede-arduino-target))
   "Run the current project derived from TARGET in a debugger."
   (error "No Debugger support for Arduino"))
 
 ;;; C/C++ support
 (require 'semantic/db)
 
-(cl-defmethod ede-preprocessor-map ((this ede-arduino-target))
+(cl-defmethod ede-preprocessor-map ((_this ede-arduino-target))
   "Get the pre-processor map for some generic C code."
   ;; wiring.h and pins_arduino.h have lots of #defines in them.
   ;; TODO: realpath
@@ -539,9 +539,9 @@ Argument COMMAND is the command to use for compiling the 
target."
       (setq filemap (append filemap (oref table lexical-table))))
     filemap))
 
-(cl-defmethod ede-system-include-path ((this ede-arduino-target))
+(cl-defmethod ede-system-include-path ((_this ede-arduino-target))
   "Get the system include path used by project THIS."
-  (let* ((prefs (ede-arduino-sync))
+  (let* ((_prefs (ede-arduino-sync))
          (iphardware (expand-file-name "hardware/arduino/cores/arduino"
                                        (ede-arduino-find-install)))
          (libs (ede-arduino-guess-libs))
@@ -580,7 +580,8 @@ Argument COMMAND is the command to use for compiling the 
target."
          (vers (ede-arduino-Arduino-Version))
          (sketch (ede-arduino-guess-sketch))
          (orig-buffer nil)
-         (buff-to-kill nil))
+         ;; (buff-to-kill nil)
+         )
     (when (and (string= (file-name-extension sketch) "ino")
                (version< vers "1.0"))
       (error "Makefile doesn't support .ino files until Arduino 1.0"))
@@ -588,9 +589,10 @@ Argument COMMAND is the command to use for compiling the 
target."
                (version<= "1.0" vers))
       (error "Makefile doesn't support .pde files after Arduino 1.0"))
 
-    (save-current-buffer
-      (setq orig-buffer (get-file-buffer mfilename))
-      (set-buffer (setq buff-to-kill (find-file-noselect mfilename)))
+    (setq orig-buffer (get-file-buffer mfilename))
+    (with-current-buffer
+        ;; (setq buff-to-kill
+        (find-file-noselect mfilename)
       (save-excursion
         (goto-char (point-min))
         (if (and (not (eobp))
@@ -605,7 +607,7 @@ Argument COMMAND is the command to use for compiling the 
target."
         (ede-srecode-insert
          "arduino:ede-empty"
          "TARGET" (oref proj name)
-         "ARDUINO_LIBS" (mapconcat 'identity (ede-arduino-guess-libs) " ")
+         "ARDUINO_LIBS" (mapconcat #'identity (ede-arduino-guess-libs) " ")
          "MCU" (oref board mcu)
          "F_CPU" (oref board f_cpu)
          "PORT" (oref prefs port)
@@ -626,8 +628,7 @@ Argument COMMAND is the command to use for compiling the 
target."
   (let* ((libs nil)
          (sketch (ede-arduino-guess-sketch))
          (sketch-buffer (find-file-noselect sketch))
-         (arduino-libraries (save-current-buffer
-                              (set-buffer sketch-buffer)
+         (arduino-libraries (with-current-buffer sketch-buffer
                               (if (boundp 'arduino-libraries)
                                   arduino-libraries
                                 nil))))
@@ -636,13 +637,11 @@ Argument COMMAND is the command to use for compiling the 
target."
       (dolist (lib (split-string arduino-libraries))
         (push lib libs)))
      (t
-      (let* ((libdir nil)
-             (orig-buffer (get-file-buffer sketch))
+      (let* ((orig-buffer (get-file-buffer sketch))
              (buff nil)
              (tmp nil))
-        (save-current-buffer
-          (setq buff (find-file-noselect sketch))
-          (set-buffer buff)
+        (with-current-buffer
+            (setq buff (find-file-noselect sketch))
           (save-excursion
             (goto-char (point-min))
             (while (re-search-forward "#include <\\([[:word:]_]+\\).h>" nil t)
diff --git a/flycheck-arduino.el b/flycheck-arduino.el
index 03eecf4..1fe0bd6 100644
--- a/flycheck-arduino.el
+++ b/flycheck-arduino.el
@@ -1,4 +1,4 @@
-;;; flycheck-arduino.el --- Arduino support for flycheck.
+;;; flycheck-arduino.el --- Arduino support for flycheck.  -*- 
lexical-binding: t; -*-
 
 ;; Authors: stardiviner <numbchild@gmail.com>
 ;; Version: 0.1
@@ -49,7 +49,10 @@ Add `arduino' to `flycheck-checkers'."
   (add-to-list 'flycheck-checkers 'arduino))
 
 
+;; Can't be compiled when `flycheck' is not available.
+;; Local Variables:
+;; no-byte-compile: t
+;; End:
 
 (provide 'flycheck-arduino)
-
 ;;; flycheck-arduino.el ends here
diff --git a/ob-arduino.el b/ob-arduino.el
index f77915b..a988b4b 100644
--- a/ob-arduino.el
+++ b/ob-arduino.el
@@ -1,4 +1,4 @@
-;;; ob-arduino.el --- Org-mode Babel support for Arduino.
+;;; ob-arduino.el --- Org-mode Babel support for Arduino.  -*- 
lexical-binding: t; -*-
 ;;
 ;; Authors: stardiviner <numbchild@gmail.com>
 ;; Package-Requires: ((emacs "24.4") (org "24.1"))
@@ -41,32 +41,31 @@
 
 (defcustom ob-arduino:program "arduino"
   "Default Arduino program name."
-  :group 'ob-arduino
   :type 'string)
 
 (defcustom ob-arduino:port "/dev/ttyACM0"
   "Default Arduino port."
-  :group 'ob-arduino
   :type 'string)
 
 (defcustom ob-arduino:board "arduino:avr:uno"
   "Default Arduino board."
-  :group 'ob-arduino
   :type 'string)
 
 
-(defvar org-babel-default-header-args:sclang nil)
+(defvar org-babel-default-header-args:sclang nil) ;;FIXME: What's this for??
+(defvar org-babel-temporary-directory)
 
 ;;;###autoload
 (defun org-babel-execute:arduino (body params)
   "org-babel arduino hook."
   (let* ((port (cdr (assoc :port params)))
          (board (cdr (assoc :board params)))
-         (cmd (mapconcat 'identity (list
-                                    ob-arduino:program "--upload"
-                                    (if port (concat "--port " port))
-                                    (if board (concat "--board " board))
-                                    ) " "))
+         ;; (cmd (mapconcat #'identity (list
+         ;;                             ob-arduino:program "--upload"
+         ;;                             (if port (concat "--port " port))
+         ;;                             (if board (concat "--board " board))
+         ;;                             )
+         ;;                 " "))
          (code (org-babel-expand-body:generic body params))
          (src-file (org-babel-temp-file "ob-arduino-" ".ino")))
     ;; delete all `ob-arduino' temp files, otherwise arduino will compile all



reply via email to

[Prev in Thread] Current Thread [Next in Thread]