Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed dependency on s.el. #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

amno1
Copy link
Contributor

@amno1 amno1 commented Oct 8, 2021

Hi Wilfred, is this still interesting to you?

Wilfred/helpful#1
#1

Dash is included in Elpa, so it is really only s.el left :-).

Regardless of including into Elpa or Emacs, I would like to use your package in a project of mine, at least for a while. For my own preference, I have removed dependency on s.el. If you check the patch it wasn't really much to do, it is barely like 10 lines of code. I did have to change the algorithm in you 'elisp-refs--unindent-rigidly', since I couldn't come up with a pretty replacement for 's-match'. The new one should be a slight improvement since it does not use intermediate list to find the minimum but does it in-place, but it is really nothing noticeable, the search is anyway dominated by I/O and string comparisons, not by this function.

The compatibility should go back to Emacs 24.4. It is 'string-join' that it is the "newest" of the bunch, otherwise the patch would be compatible with 24.1.

If you are considering to contribute this to Emacs core or Elpa, I personally have signed the FSF copyrights; but this would probably not even count as a "significant" contribution.

Best regards, thanks for the Helpful! I have been using it a lot, and really like it.

Copy link

@basil-conto basil-conto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, just a couple of comments in passing from me.

lines))
(min-indent (-min (--map (length it) indents))))
(let* ((lines (split-string string "\n"))
(min-indent most-positive-fixnum) (indent 0))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Elisp has bignums now so I would find it more elegant to do away with the arbitrary fixnum limit, e.g. by continuing to use Dash helpers (min-by, reduce), or by using nil or similar as an initial value.

  • The indent variable can be moved into the loop to avoid the need for setq (which should make it slightly more efficient too).

(let* ((lines (split-string string "\n"))
(min-indent most-positive-fixnum) (indent 0))
(dolist (line lines)
(setq indent (or (string-match-p "[^[:blank:]]" line) 0))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the use of rx?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants