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

Lots of seemingly unused defun's in csharp-mode #71

Closed
josteink opened this issue Mar 26, 2016 · 5 comments
Closed

Lots of seemingly unused defun's in csharp-mode #71

josteink opened this issue Mar 26, 2016 · 5 comments

Comments

@josteink
Copy link
Collaborator

Amongst other the following private functions are defined, but does not seem to be used by any internal code:

  • csharp--on-ctor-close-curly-p
  • csharp--on-defun-close-curly-p
  • csharp--on-namespace-close-curly-p
  • csharp--on-enum-close-curly-p
  • csharp--on-intf-close-curly-p
  • csharp--on-class-close-curly-p

In this general area of the code almost all the defined functions are unused. Maybe this should be cleaned up?

@josteink
Copy link
Collaborator Author

I guess the initial job should be map out all unused functions to get the full picture about how many lines of code we're talking about here.

I guess taking out these functions, will again cause the list of actually used csharp-regexes in the regex-alist to be reduced as well.

I've git grepped across all revisions. These functions have never been used by csharp-mode code:

$ git grep "csharp--on-class-close-curly-p" $(git rev-list --all) | grep -v defun
$ git grep "csharp--on-ctor-close-curly-p" $(git rev-list --all) | grep -v defun
$ git grep "csharp--on-defun-close-curly-p" $(git rev-list --all) | grep -v defun
$ git grep "csharp--on-namespace-close-curly-p" $(git rev-list --all) | grep -v defun
$ git grep "csharp--on-enum-close-curly-p" $(git rev-list --all) | grep -v defun
$ git grep "csharp--on-intf-close-curly-p" $(git rev-list --all) | grep -v defun
$ git grep "csharp--on-class-close-curly-p" $(git rev-list --all) | grep -v defun
$

So if they're not used, and we don't plan to use them, I really so no need to keep them around...

@josteink
Copy link
Collaborator Author

I did a big grep across all the code-base to see what things have never been referenced:

$ grep "^(defun " csharp-mode.el | perl -pe "s/\(defun ([a-z0-9-]+) .*$/\1/" | sort >defuns.txt
$ for line in `cat defuns.txt` ; do echo -n "$line: " ;git grep "$line" $(git rev-list --all) | grep -v defun | wc -l ; done >use-count.txt
$ grep ": 0" use-count.txt
c-inside-bracelist-p: 0
csharp-max-beginning-of-stmt: 0
csharp-move-back-to-beginning-of-defun: 0
csharp-move-back-to-beginning-of-namespace: 0
csharp-move-fwd-to-end-of-class: 0
csharp-move-fwd-to-end-of-defun: 0
csharp--on-class-close-curly-p: 0
csharp--on-ctor-close-curly-p: 0
csharp--on-defun-close-curly-p: 0
csharp--on-defun-open-curly-p: 0
csharp--on-enum-close-curly-p: 0
csharp--on-intf-close-curly-p: 0
csharp--on-namespace-close-curly-p: 0
$ 

That's going back through all revisions, so these are things which has never been used. Checking the current affairs, gives equal results:

$ for line in `cat defuns.txt` ; do echo -n "$line: " ;grep "$line" csharp-mode.el | grep -v defun | wc -l ; done >use-count.txt
$ grep ": 0" use-count.txt
c-inside-bracelist-p: 0
csharp-max-beginning-of-stmt: 0
csharp-move-back-to-beginning-of-defun: 0
csharp-move-back-to-beginning-of-namespace: 0
csharp-move-fwd-to-end-of-class: 0
csharp-move-fwd-to-end-of-defun: 0
csharp--on-class-close-curly-p: 0
csharp--on-ctor-close-curly-p: 0
csharp--on-defun-close-curly-p: 0
csharp--on-defun-open-curly-p: 0
csharp--on-enum-close-curly-p: 0
csharp--on-intf-close-curly-p: 0
csharp--on-namespace-close-curly-p: 0
$ 

Most of these seems privateish, and in like good candidates for stripping if we're not going to use them.

@wasamasa
Copy link
Collaborator

There's more:

  • csharp-line-up-region/csharp-lineup-if-and-region (referencing each other only, not interactive)
  • There's a few more movement commands that are not in use, but they all are interactive, so not worth removing them as users could be still binding them
  • csharp-max-beginning-of-stmt
  • I don't get what the c-forward-objc-directive advice is for. It seems like a thing better fixed in cc-mode itself if it is supposedly problematic. Appears to be used in c-guess-basic-syntax which was called "the easily most obfuscated code in Emacs" by quotemstr.
  • Monkeypatching cc-mode generally looks like a bad idea to me, I'd like getting rid of that entirely. The problem is just that I don't know what exactly the monkeypatches addresses...

@josteink
Copy link
Collaborator Author

Not touching the monkey-patching as I too don't feel fully qualified to know if they're needed or not anymore.

Not touching interactive commands either.

Investigating csharp-line-up-region and csharp-lineup-if-and-region which supposedly controls indentation behaviour if the user decides to use them, I cannot see how anything in any way behaves differently, so I'm all OK for dropping those two.

With that done, this issue should be considered complete.

josteink added a commit that referenced this issue May 30, 2016
**Main features:**

* all data collected through single scan, using standard regexpes.
* most code is 100% pure and functional, with near zero state kept. (Good bye FSM)
* orders of magnitudes faster than before
* orders of magnitudes more maintainable than before (you can make feature-requests now!)
* less hierarchies, less clicky (for those using the menus)
* indexes "everything": fields, props, methods, ctors, indexers, classes, enums, etc.

**Inherent limitations:**

* Does not support/resolve names correctly for nested types. At all. Will not be supported.
* Some imenu targets are hard to pick by regexp without getting tons of noise. For this reason methods and props does *require* access-modifiers to be indexed. Other types are less strict.

**Otherwise**

This commit fixes or addresses the following github issues:

* #71
* #68
* #67
* #60
@josteink
Copy link
Collaborator Author

Closed by #74.

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

No branches or pull requests

2 participants