Make checkdoc and the byte-compiler happier

This commit is contained in:
TEC 2024-04-16 11:14:19 +08:00
parent 91d72e4c05
commit 98de03162e
Signed by: tec
SSH Key Fingerprint: SHA256:I+UrABB3N7OiMv1W/7B7e5SUL1CP5cmXo9tpscSs+9w
1 changed files with 33 additions and 30 deletions

View File

@ -189,7 +189,7 @@ Set to nil to disable."
(defcustom emacs-everywhere-file-dir (defcustom emacs-everywhere-file-dir
temporary-file-directory temporary-file-directory
"The default directory for temp files generated by `emacs-everywhere-filename-function'." "The default dir for`emacs-everywhere-filename-function'-generated temp files."
:type 'string :type 'string
:group 'emacs-everywhere) :group 'emacs-everywhere)
@ -214,7 +214,7 @@ Set to nil to disable."
:group 'emacs-everywhere) :group 'emacs-everywhere)
(defun emacs-everywhere-temp-filename (app-info) (defun emacs-everywhere-temp-filename (app-info)
"Generate a temp file." "Generate a temp file based on APP-INFO."
(concat "emacs-everywhere-" (concat "emacs-everywhere-"
(format-time-string "%Y%m%d-%H%M%S-" (current-time)) (format-time-string "%Y%m%d-%H%M%S-" (current-time))
(emacs-everywhere-app-class app-info))) (emacs-everywhere-app-class app-info)))
@ -234,7 +234,7 @@ Make sure that it will be matched by `emacs-everywhere-file-patterns'."
"String to search for to determine if Emacs does not have accessibility rights.") "String to search for to determine if Emacs does not have accessibility rights.")
(defvar-local emacs-everywhere-current-app nil (defvar-local emacs-everywhere-current-app nil
"The current `emacs-everywhere-app'") "The current `emacs-everywhere-app'.")
;; Prevents buffer-local variable from being unset by major mode changes ;; Prevents buffer-local variable from being unset by major mode changes
(put 'emacs-everywhere-current-app 'permanent-local t) (put 'emacs-everywhere-current-app 'permanent-local t)
@ -248,12 +248,14 @@ Make sure that it will be matched by `emacs-everywhere-file-patterns'."
(declare-function evil-insert-state "evil-states") (declare-function evil-insert-state "evil-states")
(declare-function spell-fu-buffer "spell-fu") (declare-function spell-fu-buffer "spell-fu")
(declare-function markdown-mode "markdown-mode") (declare-function markdown-mode "markdown-mode")
(declare-function w32-shell-execute "w32fns.c")
;;; Primary functionality ;;; Primary functionality
;;;###autoload ;;;###autoload
(defun emacs-everywhere (&optional file line column) (defun emacs-everywhere (&optional file line column)
"Launch the emacs-everywhere frame from emacsclient." "Launch the emacs-everywhere frame from emacsclient.
This may open FILE at a particular LINE and COLUMN, if specified."
(let* ((app-info (emacs-everywhere-app-info)) (let* ((app-info (emacs-everywhere-app-info))
(param (emacs-everywhere-command-param app-info file line column)) (param (emacs-everywhere-command-param app-info file line column))
(param-string (combine-and-quote-strings param))) (param-string (combine-and-quote-strings param)))
@ -263,7 +265,9 @@ Make sure that it will be matched by `emacs-everywhere-file-patterns'."
(_ (apply #'call-process "emacsclient" nil 0 nil param))))) (_ (apply #'call-process "emacsclient" nil 0 nil param)))))
(defun emacs-everywhere-command-param (app-info &optional file line column) (defun emacs-everywhere-command-param (app-info &optional file line column)
"Generate arguments for calling emacsclient." "Generate arguments for calling emacsclient.
The arguments are based on a particular APP-INFO. Optionally, a FILE can be
specified, and also a particular LINE and COLUMN."
(delq (delq
nil (list nil (list
(when (server-running-p) (when (server-running-p)
@ -277,8 +281,7 @@ Make sure that it will be matched by `emacs-everywhere-file-patterns'."
(if (memq system-type '(ms-dos windows-nt cygwin)) (if (memq system-type '(ms-dos windows-nt cygwin))
(expand-file-name server-name server-auth-dir) (expand-file-name server-name server-auth-dir)
(shell-quote-argument (shell-quote-argument
(expand-file-name server-name server-socket-dir))) (expand-file-name server-name server-socket-dir))))))
)))
"-c" "-F" "-c" "-F"
(prin1-to-string (prin1-to-string
(cons (cons 'emacs-everywhere-app app-info) (cons (cons 'emacs-everywhere-app app-info)
@ -363,7 +366,7 @@ buffers.")
(delete-region (point-min) (point-max))) (delete-region (point-min) (point-max)))
(defun emacs-everywhere--finish-or-ctrl-c-ctrl-c () (defun emacs-everywhere--finish-or-ctrl-c-ctrl-c ()
"Finish emacs-everywhere session or invoke `org-ctrl-c-ctrl-c' in org-mode." "Finish emacs-everywhere session or invoke `org-ctrl-c-ctrl-c' in `org-mode'."
(interactive) (interactive)
(if (and (eq major-mode 'org-mode) (if (and (eq major-mode 'org-mode)
(org-in-src-block-p)) (org-in-src-block-p))
@ -451,7 +454,7 @@ Never paste content when ABORT is non-nil."
(call-process "osascript" nil nil nil (call-process "osascript" nil nil nil
"-e" (format "display alert \"emacs-everywhere\" message \"Emacs has not been granted accessibility permissions, cannot run emacs-everywhere! "-e" (format "display alert \"emacs-everywhere\" message \"Emacs has not been granted accessibility permissions, cannot run emacs-everywhere!
Please go to 'System Preferences > Security & Privacy > Privacy > Accessibility' and allow Emacs.\"" )) Please go to 'System Preferences > Security & Privacy > Privacy > Accessibility' and allow Emacs.\"" ))
(error "MacOS accessibility error, aborting.")) (error "MacOS accessibility error, aborting"))
(string-trim (buffer-string)))) (string-trim (buffer-string))))
(defun emacs-everywhere--app-info-linux () (defun emacs-everywhere--app-info-linux ()
@ -583,27 +586,27 @@ return windowTitle"))
(defun emacs-everywhere--app-info-windows () (defun emacs-everywhere--app-info-windows ()
"Return information on the active window, on Windows." "Return information on the active window, on Windows."
(let ((window-id (emacs-everywhere--call (let* ((window-id (emacs-everywhere--call
"powershell" "powershell"
"-NoProfile" "-NoProfile"
"-Command" "-Command"
"& {Add-Type 'using System; using System.Runtime.InteropServices; public class Tricks { [DllImport(\"user32.dll\")] public static extern IntPtr GetForegroundWindow(); }'; [tricks]::GetForegroundWindow() }")) "& {Add-Type 'using System; using System.Runtime.InteropServices; public class Tricks { [DllImport(\"user32.dll\")] public static extern IntPtr GetForegroundWindow(); }'; [tricks]::GetForegroundWindow() }"))
(window-title (emacs-everywhere--call (window-title (emacs-everywhere--call
"powershell" "powershell"
"-NoProfile" "-NoProfile"
"-Command" "-Command"
(format "& {Add-Type 'using System; using System.Runtime.InteropServices; public class Tricks { [DllImport(\"user32.dll\")] public static extern int GetWindowText(IntPtr hWnd, System.Text.StringBuilder text, int count); [DllImport(\"user32.dll\")] public static extern int GetWindowTextLength(IntPtr hWnd); }'; $length = ([tricks]::GetWindowTextLength(%s)); $sb = New-Object System.Text.StringBuilder $length; [tricks]::GetWindowText(%s, $sb, $length + 1) > $null; $sb.ToString() }" window-id window-id))) (format "& {Add-Type 'using System; using System.Runtime.InteropServices; public class Tricks { [DllImport(\"user32.dll\")] public static extern int GetWindowText(IntPtr hWnd, System.Text.StringBuilder text, int count); [DllImport(\"user32.dll\")] public static extern int GetWindowTextLength(IntPtr hWnd); }'; $length = ([tricks]::GetWindowTextLength(%s)); $sb = New-Object System.Text.StringBuilder $length; [tricks]::GetWindowText(%s, $sb, $length + 1) > $null; $sb.ToString() }" window-id window-id)))
(window-class (emacs-everywhere--call (window-class (emacs-everywhere--call
"powershell" "powershell"
"-NoProfile" "-NoProfile"
"-Command" "-Command"
(format "(Get-Item (Get-Process | ? { $_.mainwindowhandle -eq %s }).Path).VersionInfo.ProductName" window-id))) (format "(Get-Item (Get-Process | ? { $_.mainwindowhandle -eq %s }).Path).VersionInfo.ProductName" window-id)))
(window-geometry (split-string (window-geometry (split-string
(emacs-everywhere--call (emacs-everywhere--call
"powershell" "powershell"
"-NoProfile" "-NoProfile"
"-Command" "-Command"
(format "& {Add-Type 'using System; using System.Runtime.InteropServices; public struct tagRECT { public int left; public int top; public int right; public int bottom; } public class Tricks { [DllImport(\"user32.dll\")] public static extern int GetWindowRect(IntPtr hWnd, out tagRECT lpRect); }'; $rect = New-Object -TypeName tagRECT; [tricks]::GetWindowRect(%s, [ref]$rect) > $null; $rect.left; $rect.top; $rect.right - $rect.left; $rect.bottom - $rect.top }" window-id))))) (format "& {Add-Type 'using System; using System.Runtime.InteropServices; public struct tagRECT { public int left; public int top; public int right; public int bottom; } public class Tricks { [DllImport(\"user32.dll\")] public static extern int GetWindowRect(IntPtr hWnd, out tagRECT lpRect); }'; $rect = New-Object -TypeName tagRECT; [tricks]::GetWindowRect(%s, [ref]$rect) > $null; $rect.left; $rect.top; $rect.right - $rect.left; $rect.bottom - $rect.top }" window-id)))))
(make-emacs-everywhere-app (make-emacs-everywhere-app
:id window-id :id window-id
:class window-class :class window-class