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
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
:group 'emacs-everywhere)
@ -214,7 +214,7 @@ Set to nil to disable."
:group 'emacs-everywhere)
(defun emacs-everywhere-temp-filename (app-info)
"Generate a temp file."
"Generate a temp file based on APP-INFO."
(concat "emacs-everywhere-"
(format-time-string "%Y%m%d-%H%M%S-" (current-time))
(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.")
(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
(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 spell-fu-buffer "spell-fu")
(declare-function markdown-mode "markdown-mode")
(declare-function w32-shell-execute "w32fns.c")
;;; Primary functionality
;;;###autoload
(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))
(param (emacs-everywhere-command-param app-info file line column))
(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)))))
(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
nil (list
(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))
(expand-file-name server-name server-auth-dir)
(shell-quote-argument
(expand-file-name server-name server-socket-dir)))
)))
(expand-file-name server-name server-socket-dir))))))
"-c" "-F"
(prin1-to-string
(cons (cons 'emacs-everywhere-app app-info)
@ -363,7 +366,7 @@ buffers.")
(delete-region (point-min) (point-max)))
(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)
(if (and (eq major-mode 'org-mode)
(org-in-src-block-p))
@ -451,7 +454,7 @@ Never paste content when ABORT is non-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!
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))))
(defun emacs-everywhere--app-info-linux ()
@ -583,27 +586,27 @@ return windowTitle"))
(defun emacs-everywhere--app-info-windows ()
"Return information on the active window, on Windows."
(let ((window-id (emacs-everywhere--call
"powershell"
"-NoProfile"
"-Command"
"& {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
"powershell"
"-NoProfile"
"-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)))
(window-class (emacs-everywhere--call
"powershell"
"-NoProfile"
"-Command"
(format "(Get-Item (Get-Process | ? { $_.mainwindowhandle -eq %s }).Path).VersionInfo.ProductName" window-id)))
(window-geometry (split-string
(emacs-everywhere--call
"powershell"
"-NoProfile"
"-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)))))
(let* ((window-id (emacs-everywhere--call
"powershell"
"-NoProfile"
"-Command"
"& {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
"powershell"
"-NoProfile"
"-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)))
(window-class (emacs-everywhere--call
"powershell"
"-NoProfile"
"-Command"
(format "(Get-Item (Get-Process | ? { $_.mainwindowhandle -eq %s }).Path).VersionInfo.ProductName" window-id)))
(window-geometry (split-string
(emacs-everywhere--call
"powershell"
"-NoProfile"
"-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)))))
(make-emacs-everywhere-app
:id window-id
:class window-class