This commit is contained in:
Mark Oteiza 2015-09-20 23:05:39 -04:00
parent 6071c2349c
commit 175d45fee6
2 changed files with 14 additions and 13 deletions

View File

@ -148,13 +148,13 @@
(systemd-company--setup-company enable))) (systemd-company--setup-company enable)))
(defun systemd-company-section-p () (defun systemd-company-section-p ()
"Return t if current line begins with \"[\", otherwise nil" "Return t if current line begins with \"[\", otherwise nil."
(save-excursion (save-excursion
(beginning-of-line) (beginning-of-line)
(looking-at "\\["))) (looking-at "\\[")))
(defun systemd-company-network-p () (defun systemd-company-network-p ()
"Return non-nil if `buffer-name' has a network-type extension, otherwise nil" "Return non-nil if `buffer-name' has a network-type extension, otherwise nil."
(string-match "\\.\\(link\\|netdev\\|network\\)\\'" (buffer-name))) (string-match "\\.\\(link\\|netdev\\|network\\)\\'" (buffer-name)))
(with-eval-after-load "company" (with-eval-after-load "company"

View File

@ -90,13 +90,13 @@
;; exec prefixes ;; exec prefixes
("=\\(-@\\|@-\\|[@-]\\)" ("=\\(-@\\|@-\\|[@-]\\)"
1 'font-lock-negation-char-face)) 1 'font-lock-negation-char-face))
"Default expressions to highlight in `systemd-mode'. See systemd.unit(5) "Default expressions to highlight in `systemd-mode'.
for details on unit file syntax.") See systemd.unit(5) for details on unit file syntax.")
(defun systemd-get-value (start) (defun systemd-get-value (start)
"Joins lines in the key value starting at buffer position START, "Return the value of the key whose value begins at position START.
possibly broken by a backslash, and returns a string containing Lines ending in a backslash are concatenated with the next
the value." according to systemd.unit(5)."
(let ((break "\\\\\n") (let ((break "\\\\\n")
end) end)
(save-excursion (save-excursion
@ -107,8 +107,8 @@ the value."
(replace-regexp-in-string break " " (buffer-substring start end))))) (replace-regexp-in-string break " " (buffer-substring start end)))))
(defun systemd-doc-find () (defun systemd-doc-find ()
"Find the value of the unit's “Documentation” keys and return "Find the value of the unit's “Documentation” keys.
as a list of strings, otherwise nil." Return values in a list of strings, otherwise nil."
(let ((key "^Documentation=") (let ((key "^Documentation=")
string) string)
(save-excursion (save-excursion
@ -119,15 +119,16 @@ as a list of strings, otherwise nil."
(remove "\\" (split-string string))))) (remove "\\" (split-string string)))))
(defun systemd-doc-man (page) (defun systemd-doc-man (page)
"Open a manual page with `systemd-man-function'." "Open a manual page PAGE with `systemd-man-function'."
(pcase (symbol-name systemd-man-function) (pcase (symbol-name systemd-man-function)
("woman" (woman (replace-regexp-in-string "([[:alnum:]]+)" "" page))) ("woman" (woman (replace-regexp-in-string "([[:alnum:]]+)" "" page)))
("man" (man page)) ("man" (man page))
(_ (apply 'systemd-man-function page)))) (_ (apply 'systemd-man-function page))))
(defun systemd-doc-open (url) (defun systemd-doc-open (url)
"Open URL. Interactively completes the documentation in the "Prompt to open URL.
current unit file, defaulting to the link under point, if any." Interactively completes the documentation in the current unit
file, defaulting to the link under point, if any."
(interactive (interactive
(let* ((completion-cycle-threshold t) (let* ((completion-cycle-threshold t)
(collection (systemd-doc-find)) (collection (systemd-doc-find))
@ -146,7 +147,7 @@ current unit file, defaulting to the link under point, if any."
(_ (user-error "Invalid link"))))) (_ (user-error "Invalid link")))))
(defun systemd-doc-directives () (defun systemd-doc-directives ()
"Open systemd.directives(7)" "Open systemd.directives(7)."
(interactive) (interactive)
(systemd-doc-man "systemd.directives(7)")) (systemd-doc-man "systemd.directives(7)"))