Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Feature/center content #88

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

Merged
merged 19 commits into from
Feb 25, 2019

Conversation

jkdufair
Copy link
Contributor

Hello @rakanalh. This PR addresses #77
I approached this by creating a macro that can insert arbtrary sections and returns the maximum line length for that section. Then 'dashboard-insert-startupify-lists finds the maximum of the maximums and moves all items over accordingly. I initially looked at adjusting the margins and/or the gutter but neither looked very attractive.

Additionally, I'd be willing to be a maintainer. I've been looking for something fun to hack on for a while. Thanks for considering.

@jkdufair
Copy link
Contributor Author

Just realized I need to update the readme. Sorry about that.

@jkdufair
Copy link
Contributor Author

  • Page break lines are now not "centered"
  • Documentation added about centering

@rakanalh
Copy link
Contributor

Hello @jkdufair,

Thank you so much for putting together a PR.

Before i review the code, please fix back the code indentation to be able to properly review the other parts of the code. I think we should introduce some lint to that because every contributor seems to have their own indentation style / settings.

@jkdufair
Copy link
Contributor Author

Sure thing. Do you have a style guide I can refer to?

@rakanalh
Copy link
Contributor

Not really... now i am considering it to be honest.

@jkdufair
Copy link
Contributor Author

Ok. I tried not to make any whitespace-only changes to existing functions. I'll revert any that I may have created inadvertently. Thank you.

@jkdufair
Copy link
Contributor Author

Ok sorry about that! I didn't realize I had those whitespace-only changes. Thanks for taking a look.

,list))
max-line-length))

(defmacro dashboard-insert-section (section-name list list-size shortcut action &rest widget-params)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did this become a macro rather than a function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to have each section insert return its longest line so I could do centering calculations. Each of the section and section list inserts was similar and I didn't want to just boilerplate it in there. So I refactored the section and section list inserts into a macro and replaced the repetitive sections with calls to the macro. This should also make it easy to create new sections in the future with less boilerplate code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also it should make the intent of creating sections more clean and more declarative

(defun dashboard-insert-recents (list-size)
"Add the list of LIST-SIZE items from recently edited files."
(recentf-mode)
(when (dashboard-insert-recentf-list
Copy link
Contributor

Choose a reason for hiding this comment

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

Dashboard let's you configure widgets to include... this is why the when statement is there. Why was it removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this still works as intended? When I remove, i.e. 'recents from 'dashboard-items, the section no longer appears on the dashboard. Am I understanding correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry. I should add there is a when-let in dashboard-insert-section that I believe accomplishes the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, the linter seems to have had trouble with when-let so I just did a let and if. This still appears to allow the configurability of which widgets to include.

@rakanalh rakanalh force-pushed the master branch 3 times, most recently from f7974e5 to 09d6f20 Compare February 23, 2019 00:54
@JesusMtnez
Copy link
Contributor

@jkdufair sorry for the conflict, just merge a PR that deletes `:follow-link "\C-m" which makes your macro change a conflict. 😅

Copy link
Contributor

@rakanalh rakanalh left a comment

Choose a reason for hiding this comment

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

I am not sure i like this macro approach as it'll probably break people's custom widgets that are not provided by Dashboard itself. But i like the refactoring in general so i am willing to merge this.

@JesusMtnez if you have a better idea please feel free to chime in

dashboard.el Outdated
@@ -62,6 +62,11 @@
"Settings that are used in the Dashboard"
:group 'dashboard)

(defcustom dashboard-center-content t
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rather have the default value as nil (non-centered)... might need to update the documentation with this change.

@jkdufair
Copy link
Contributor Author

I agree. I don’t want to break backward compatibility @rakanalh. The more I think about it, the less I like putting the responsibility of returning max-line-length on each section. If I remove that requirement, I believe custom widgets will work just fine as-is. And people can use the new macros as well to easily develop more custom widgets. Should be a simple change and it will also make the macros simpler.

Sound ok?

@jkdufair
Copy link
Contributor Author

@JesusMtnez no problem. I’ll get it fixed shortly.

@JesusMtnez
Copy link
Contributor

@rakanalh I don't have any possible idea to that.

@jkdufair I like you approach, but if it is possible to keep backwards compatibility, let's try it.

In case we do not find a way, I would suggest making an stable release before merging this, so next release is a major release.

Also, good documentation is important if this change is going to include breaking changes.

@jkdufair
Copy link
Contributor Author

@rakanalh @JesusMtnez I have done the following

  • Removed the need for sections to return their maximum width. I calculate it, instead, as the sections are inserted
  • Verified it is backward compatible by adding a custom section
  • Set the default centering to nil and updated the documentation accordingly
  • Merged upstream master and resolved conflicts.

Thank you for your assistance with this.

Copy link
Contributor

@rakanalh rakanalh left a comment

Choose a reason for hiding this comment

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

Thanks @jkdufair for all of your work

@rakanalh rakanalh merged commit 29ecbd8 into emacs-dashboard:master Feb 25, 2019
@jkdufair
Copy link
Contributor Author

Glad to help. Count me in as a regular contributor.

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

Successfully merging this pull request may close these issues.

3 participants