[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/drupal-mode b929895d51 184/308: Added own implementation o
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/drupal-mode b929895d51 184/308: Added own implementation of flymake init and temp names. |
Date: |
Tue, 25 Jan 2022 10:59:46 -0500 (EST) |
branch: elpa/drupal-mode
commit b929895d51f2549e336db595a877232834dd2ca9
Author: Arne Jørgensen <arne@arnested.dk>
Commit: Arne Jørgensen <arne@arnested.dk>
Added own implementation of flymake init and temp names.
Implemented our own versions of `flymake-create-temp-inplace` and
`flymake-create-temp-intemp`.
We need them to ensure better temporary file names to comply well with
Drupal Coder Sniffer.
We need the new `drupal/flymake-phpcs-init` to call our own temporary
file name functions.
Simplified setting `flymake-allowed-file-name-masks`.
---
drupal/flymake-phpcs.el | 73 +++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 68 insertions(+), 5 deletions(-)
diff --git a/drupal/flymake-phpcs.el b/drupal/flymake-phpcs.el
index 1ccc3932a9..0aa073ca34 100644
--- a/drupal/flymake-phpcs.el
+++ b/drupal/flymake-phpcs.el
@@ -88,13 +88,76 @@ file (and thus on the remote machine), or in the same place
as
(if (fboundp 'flymake-phpcs-load)
(flymake-phpcs-load)
(make-local-variable 'flymake-allowed-file-name-masks)
- (let ((extension (file-name-extension (or buffer-file-name
(buffer-name)))))
- (when (string-match "\\.tpl\\.php\\'" (or buffer-file-name
(buffer-name)))
- (setq extension "tpl\\.php"))
- (add-to-list 'flymake-allowed-file-name-masks
- `(,(concat "\\." extension "\\'") flymake-phpcs-init)))
+ (setq flymake-allowed-file-name-masks '(("." drupal/flymake-phpcs-init)))
(flymake-mode 1))))
+(defun drupal/flymake-phpcs-init ()
+ (let* ((temp-file (flymake-init-create-temp-buffer-copy
+ (if (and (fboundp 'flymake-create-temp-intemp)
+ (not flymake-run-in-place))
+ 'drupal/flymake-phpcs-create-temp-intemp
+ 'drupal/flymake-phpcs-create-temp-inplace)))
+ (local-file (file-relative-name temp-file
+ (file-name-directory
buffer-file-name))))
+ (list flymake-phpcs-command
+ (append
+ (list local-file)
+ (if flymake-phpcs-standard
+ (list (concat "--standard="
+ ;; Looking for "/" is hardly portable
+ (if (string-match "/" flymake-phpcs-standard)
+ (expand-file-name flymake-phpcs-standard)
+ flymake-phpcs-standard))))
+ (if flymake-phpcs-show-rule (list "-s"))))))
+
+(defun drupal/flymake-phpcs-create-temp-inplace (file-name &optional prefix)
+ "Return filename in the same directory as FILE-NAME for a
+temporary copy of the buffer editing FILE-NAME.
+
+Note that this function, despite its name, does not actually create a
+copy of the file: it only choses and returns a filename for the temp
+copy."
+ (unless (stringp file-name)
+ (error "Invalid file-name"))
+ (or prefix
+ (setq prefix "flymake"))
+ (let* ((extension (if (string-match "\\.tpl\\.php\\'" (or buffer-file-name
(buffer-name)))
+ ".tpl.php"
+ (file-name-extension file-name t)))
+ (base-name (replace-regexp-in-string (concat (regexp-quote extension)
"\\'") "" file-name))
+ (temp-name (file-truename (concat base-name "." prefix extension))))
+ (flymake-log 3 "create-temp-inplace: file=%s temp=%s" file-name temp-name)
+ temp-name))
+
+(defun drupal/flymake-phpcs-create-temp-intemp (file-name &optional prefix)
+ "Return filename in temporary directory for a temporary
+copy of the buffer editing FILE-NAME. This is a replacement for
+`flymake-create-temp-inplace'. The difference is that it gives
+a file name in `temporary-file-directory' instead of the same
+directory as FILE-NAME.
+
+For the use of PREFIX see that function.
+
+Note that not making the temporary file in another directory
+\(like here) will not work if the file you are checking depends
+relative paths to other files \(for the type of checks flymake
+makes).
+
+Note that this function, despite its name, does not actually create a
+copy of the file: it only choses and returns a filename for the temp
+copy."
+ (unless (stringp file-name)
+ (error "Invalid file-name"))
+ (or prefix
+ (setq prefix "flymake"))
+ (let* ((extension (if (string-match "\\.tpl\\.php\\'" (or buffer-file-name
(buffer-name)))
+ ".tpl.php"
+ (file-name-extension file-name t)))
+ (base-name (file-name-nondirectory (replace-regexp-in-string (concat
(regexp-quote extension) "\\'") "" file-name)))
+ (temp-name (file-truename (make-temp-file (concat base-name "."
prefix) nil extension))))
+ (flymake-log 3 "create-temp-intemp: file=%s temp=%s" file-name temp-name)
+ temp-name))
+
(add-hook 'drupal-mode-hook #'drupal/flymake-phpcs-enable)
- [nongnu] elpa/drupal-mode bd22697642 135/308: Mark `drupal/flymake-phpcs-standard' as obsolete., (continued)
- [nongnu] elpa/drupal-mode bd22697642 135/308: Mark `drupal/flymake-phpcs-standard' as obsolete., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 3ba088c812 139/308: No need for make-local-variable., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode a6a4bfa842 144/308: No quoting necessary, says wiser minds than mine., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 996081be40 157/308: Merge branch 'release/0.3.0', ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 97b60197d0 151/308: Improved rootdir detection for etags and gtags., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 8733eb2d1e 160/308: Bumped versio to 0.3.1., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 31c2b672aa 168/308: Added Api.drupalize.me as `drupal-search-url` option., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 6bb266bc11 172/308: Fixed typo in latest commit., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 2b71509ac3 171/308: Used `(buffer-name)` as fallback if `buffer-file-name` us not set., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 135c5f669e 197/308: Add interface with gtags via `ggtags.el', ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode b929895d51 184/308: Added own implementation of flymake init and temp names.,
ELPA Syncer <=
- [nongnu] elpa/drupal-mode 7402b9e9fb 201/308: Merge pull request #43 from arnested/flycheck-update, ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 60b231a125 202/308: Bumped version to 0.5.0., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode c83705239e 214/308: Merge pull request #50 from kaaresl/develop, ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 5911ac2158 211/308: Fixed bad indentation., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 76199a3c68 243/308: Bump version number to 0.6.0., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 6fbdf7946b 241/308: Fixed getting Drupal site temp folder., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode d88b39e8f5 262/308: Fixed travis.yml, ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 3cae8bea76 267/308: Merge pull request #70 from arnested/api-skeleton, ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 1545d07f0d 265/308: Use drupal/phpcs-standard in drupal-phpcs checker, ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 690f2c5592 293/308: Cleanup URLs in documentation, ELPA Syncer, 2022/01/25