Skip to content

Commit

Permalink
Fix excessively long lines in all libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsius committed Feb 24, 2020
1 parent e52931f commit a96c73c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 20 deletions.
6 changes: 4 additions & 2 deletions rustic-cargo.el
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ When calling this function from `rustic-popup-mode', always use the value of
(rustic-compilation command :buffer buf :process proc :mode mode))
(message "Could not find test at point.")))

(defconst rustic-cargo-mod-regexp "^\s*mod\s+\\([[:word:][:multibyte:]_][[:word:][:multibyte:]_[:digit:]]*\\)\s*{")
(defconst rustic-cargo-fn-regexp "^\s*fn\s+\\([^(]+\\)\s*(")
(defconst rustic-cargo-mod-regexp
"^\s*mod\s+\\([[:word:][:multibyte:]_][[:word:][:multibyte:]_[:digit:]]*\\)\s*{")
(defconst rustic-cargo-fn-regexp
"^\s*fn\s+\\([^(]+\\)\s*(")

(defun rustic-cargo--get-current-fn-fullname()
"Return full name of the fn around point including module name if any."
Expand Down
14 changes: 9 additions & 5 deletions rustic-compile.el
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,10 @@ buffers are formatted after saving if turned on by `rustic-format-trigger'."
nil))))
(when (and saved-p (rustic-format-on-save-p) (eq major-mode 'rustic-mode))
(let* ((file (buffer-file-name buffer))
(proc (rustic-format-start-process 'rustic-format-file-sentinel
:buffer buffer
:command `(,rustic-rustfmt-bin ,file))))
(proc (rustic-format-start-process
'rustic-format-file-sentinel
:buffer buffer
:command `(,rustic-rustfmt-bin ,file))))
(while (eq (process-status proc) 'run)
(sit-for 0.1))))))))))

Expand All @@ -379,8 +380,11 @@ This hook temporarily sets `default-directory' to the project's root."

(defun rustic-compile-goto-error-hook (orig-fun &rest args)
"Provide possibility use `compile-goto-error' on line numbers in compilation buffers.
This hook checks if there's a line number at the beginning of the current line in an error section."
(-if-let* ((line-contents (buffer-substring-no-properties (line-beginning-position) (line-end-position)))
This hook checks if there's a line number at the beginning of the
current line in an error section."
(-if-let* ((line-contents (buffer-substring-no-properties
(line-beginning-position)
(line-end-position)))
(line-number-p (string-match "^[0-9]+\s+\|" line-contents))
(line-number (car (split-string line-contents))))
(save-excursion
Expand Down
31 changes: 21 additions & 10 deletions rustic-interaction.el
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@
;;
((skip-dot-identifier
(lambda ()
(when (and (rustic-looking-back-ident) (save-excursion (forward-thing 'symbol -1) (= ?. (char-before))))
(when (and (rustic-looking-back-ident)
(save-excursion
(forward-thing 'symbol -1)
(= ?. (char-before))))
(forward-thing 'symbol -1)
(backward-char)
(- (current-column) rustic-indent-offset)))))
Expand Down Expand Up @@ -157,7 +160,8 @@

;; Indent to the same level as the previous line, or the
;; start of the string if the previous line starts the string
(if (= (line-number-at-pos end-of-prev-line-pos) (line-number-at-pos string-begin-pos))
(if (= (line-number-at-pos end-of-prev-line-pos)
(line-number-at-pos string-begin-pos))
;; The previous line is the start of the string.
;; If the backslash is the only character after the
;; string beginning, indent to the next indent
Expand Down Expand Up @@ -279,14 +283,19 @@
(= (point) 1)
;; ..or if the previous line ends with any of these:
;; { ? : ( , ; [ }
;; then we are at the beginning of an expression, so stay on the baseline...
;; then we are at the beginning of an
;; expression, so stay on the baseline...
(looking-back "[(,:;?[{}]\\|[^|]|" (- (point) 2))
;; or if the previous line is the end of an attribute, stay at the baseline...
(progn (rustic-rewind-to-beginning-of-current-level-expr) (looking-at "#")))))
;; or if the previous line is the end of an
;; attribute, stay at the baseline...
(progn
(rustic-rewind-to-beginning-of-current-level-expr)
(looking-at "#")))))
baseline

;; Otherwise, we are continuing the same expression from the previous line,
;; so add one additional indent level
;; Otherwise, we are continuing the same
;; expression from the previous line, so add one
;; additional indent level
(+ baseline rustic-indent-offset))))))))))

(when indent
Expand Down Expand Up @@ -354,8 +363,9 @@ which calls this, does that afterwards."
(catch 'done
(dotimes (_ magnitude)
;; Search until we find a match that is not in a string or comment.
(while (if (re-search-backward (concat "^\\(" (or regex rustic-top-item-beg-re) "\\)")
nil 'move sign)
(while (if (re-search-backward
(concat "^\\(" (or regex rustic-top-item-beg-re) "\\)")
nil 'move sign)
(rustic-in-str-or-cmnt)
;; Did not find it.
(throw 'done nil)))))
Expand All @@ -380,7 +390,8 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
(condition-case nil
(forward-sexp)
(scan-error
;; The parentheses are unbalanced; instead of being unable to fontify, just jump to the end of the buffer
;; The parentheses are unbalanced; instead of being unable
;; to fontify, just jump to the end of the buffer
(goto-char (point-max)))))
;; There is no opening brace, so consider the whole buffer to be one "defun"
(goto-char (point-max))))
Expand Down
10 changes: 7 additions & 3 deletions rustic-util.el
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,15 @@ with `lsp-rust-switch-server'."
;; Fonts
(setq-local font-lock-defaults '(rustic-font-lock-keywords
nil nil nil nil
(font-lock-syntactic-face-function . rustic-syntactic-face-function))))
(font-lock-syntactic-face-function
. rustic-syntactic-face-function))))

(defun rustic-analyzer-macro-expand (result)
"Default method for displaying macro expansion results."
(interactive)
(let* ((root (lsp-workspace-root default-directory))
(buf (get-buffer-create (get-buffer-create (format "*rust-analyzer macro expansion %s*" root)))))
(buf (get-buffer-create
(format "*rust-analyzer macro expansion %s*" root))))
(with-current-buffer buf
(let ((inhibit-read-only t))
(erase-buffer)
Expand Down Expand Up @@ -370,7 +372,9 @@ src-block or buffer on the Rust playpen."
(t
(setq data (buffer-substring (point-min) (point-max)))))
(let* ((escaped-data (url-hexify-string data))
(escaped-playpen-url (url-hexify-string (format rustic-playpen-url-format escaped-data))))
(escaped-playpen-url (url-hexify-string
(format rustic-playpen-url-format
escaped-data))))
(if (> (length escaped-playpen-url) 5000)
(error "encoded playpen data exceeds 5000 character limit (length %s)"
(length escaped-playpen-url))
Expand Down

0 comments on commit a96c73c

Please sign in to comment.