Skip to content

Commit 76a5f30

Browse files
maxnikulinyantar92
authored andcommitted
ol-info: Use org function instead of subr-x
* lisp/org-macs.el (org-unbracket-string): Handle empty suffix string. * lisp/ol-info.el (org-info--link-file-node): (org-info-description-as-command): Use `org-trim' and `org-unbracket-string' instead of `string-trim' and `string-remove-prefix' from the subr-x package.
1 parent 1b647b0 commit 76a5f30

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lisp/ol-info.el

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
;;; Code:
3232

33-
(require 'subr-x) ; `string-trim', `string-remove-prefix'
3433
(require 'org-macs)
3534
(org-assert-version)
3635

@@ -78,11 +77,11 @@ File may be a virtual one, see `Info-virtual-files'."
7877
'("dir" . "Top")
7978
(string-match "\\`\\([^#:]*\\)\\(?:[#:]:?\\(.*\\)\\)?\\'" path)
8079
(let* ((node (match-string 2 path))
81-
;; Do not reorder, `string-trim' modifies match.
82-
(file (string-trim (match-string 1 path))))
80+
;; Do not reorder, `org-trim' modifies match.
81+
(file (org-trim (match-string 1 path))))
8382
(cons
8483
(if (org-string-nw-p file) file "dir")
85-
(if (org-string-nw-p node) (string-trim node) "Top")))))
84+
(if (org-string-nw-p node) (org-trim node) "Top")))))
8685

8786
(defun org-info-description-as-command (link desc)
8887
"Info link description that can be pasted as command.
@@ -106,7 +105,7 @@ If LINK is not an info link then DESC is returned."
106105
(need-file-node (and (not (org-string-nw-p desc))
107106
(string-prefix-p prefix link))))
108107
(pcase (and need-file-node
109-
(org-info--link-file-node (string-remove-prefix prefix link)))
108+
(org-info--link-file-node (org-unbracket-string prefix "" link)))
110109
;; Unlike (info "dir"), "info dir" shell command opens "(coreutils)dir invocation".
111110
(`("dir" . "Top") "info \"(dir)\"")
112111
(`(,file . "Top") (format "info %s" file))

lisp/org-macs.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,8 @@ removed. Return the new string. If STRING is nil, return nil."
11011101
(and string
11021102
(if (and (string-prefix-p pre string)
11031103
(string-suffix-p post string))
1104-
(substring string (length pre) (- (length post)))
1104+
(substring string (length pre)
1105+
(and (not (string-equal "" post)) (- (length post))))
11051106
string)))
11061107

11071108
(defun org-strip-quotes (string)

0 commit comments

Comments
 (0)