all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Glenn Morris <rgm@gnu.org>
To: Luke Lee <luke.yx.lee@gmail.com>
Cc: 17854@debbugs.gnu.org
Subject: bug#17854: The patch #3 of 3 for hideif.el, a lot of bug fixes and enhancements
Date: Fri, 27 Jun 2014 21:53:15 -0400	[thread overview]
Message-ID: <75lhsh7qb8.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <CAA=xLRMBMnu0eaor7uxHEVRLugKqqG5rcgcbUQwn9shr2nG2RQ@mail.gmail.com>


> with white space changes removed (git diff -w) as attached.

I hope that the version you install will actually not change the
whitespace, rather than that just being hidden with diff -w.

>  (defcustom hide-ifdef-exclude-define-regexp nil
>    "Ignore #define names if those names match this exclusion pattern."
> -  :type 'string)
> +  :type 'string
> +  :version "24.4")

Why is the :version changing?
In any case, it is the wrong :version, since this won't be in 24.4.


> +(defcustom hide-ifdef-expand-reinclusion-protection t
> +  "Prevent hiding the whole C/C++ header file protected by a big #ifdef..#endif.

Suggestion:
"Non-nil means don't hide an entire header file enclosed by #ifndef...#endif."

> +Most C/C++ headers are usually wrapped with ifdefs to prevent re-inclusion:
> +
> +  ----- beginning of file -----
> +  #ifdef _XXX_HEADER_FILE_INCLUDED_

#ifndef?

> +  #define _XXX_HEADER_FILE_INCLUDED_
> +     xxx
> +     xxx
> +     xxx...
> +  #endif
> +  ----- end of file -----
> +
> +If we try to hide this header file, for the first time hideif will find
> +_XXX_HEADER_FILE_INCLUDED_ and have it defined.  Everything between #ifdef
> +to #endif are not hidden.

Suggestion:
"The first time we visit such a file, _XXX_HEADER_FILE_INCLUDED_ is
undefined, and so nothing is hidden.  The next time we visit it,
everything will be hidden."

> For the second time since _XXX_HEADER_FILE_INCLUDED_
> +is defined everything between the outermost #ifdef..#endif will be hidden:
> +
> +  ----- beginning of file -----
> +  #ifdef _XXX_HEADER_FILE_INCLUDED_
> +     ...
> +  #endif
> +  ----- end of file -----

I don't think the example is necessary.

> +This is not the behavior we expected, we still would like to see the content
> +of this header file.  With this flag enabled we can have the outermost #if
> +always not hidden."

Suggestion:
"This behavior is generally undesirable.  If this option is non-nil, the
outermost #if is always visible."

(I wonder: why would anyone want to set this option to nil?)

> +  :type 'boolean
> +  :version "24.4")

24.5

(Also, new options are the kind of thing to mention in a brief NEWS entry.)

> +(defcustom hide-ifdef-header-regexp
> +  "^.*\\.[hH]\\([hH]\\|[xX][xX]\\|[pP][pP]\\)?"
> +  "C/C++ header file name patterns to determine if current buffer is a header.
> +Effective only if `hide-ifdef-expand-reinclusion-protection' is t."
> +  :type 'string
> +  :group 'hide-ifdef)

Missing :version.

> -	current buffer.  Initially, the global value of `hide-ifdef-env'
> -	is used.
> +        current project.  Initially, the global value of `hide-ifdef-env'
> +        is used.  This variable was a buffer-local variable which limits

"," before which

> +        hideif to parse only one C/C++ file at a time.  We've extended
> +        hideif to support parsing a C/C++ project containing multiple C/C++
> +        source files opened simultaneously in different buffers.  Therefore
> +        `hide-ifdef-env' can no longer be buffer local but must be global.
> +
> +        We can still simulate the behavior of elder hideif versions (i.e.

s/elder/older

> +        `hide-ifdef-env' being buffer local) by clearing this variable
> +        (C-c @ C) everytime before hiding current buffer.

Does all this detail need to be in the doc-string, or can it just be a
comment in the code?

(By the way, no need to make ChangeLog entries for comments.)

> +(defun hif-clear-all-ifdef-defined ()
> +  "Clears all symbols defined in `hide-ifdef-env'.
> +It will backup this variable to `hide-ifdef-env-backup' before clearing to
> +prevent accidental clearance."

Is that backup really necessary, given that you ask for confirmation?

> +  (interactive)
> +  (when (y-or-n-p "Clear all #defined symbols?")
> +    (setq hide-ifdef-env-backup hide-ifdef-env)
> +    (setq hide-ifdef-env nil)))
>  
> +  ;; Genernally there is no need to call itself recursively since there should

Generally

> +           ((looking-at "\r") ; Sometimes MS-Windows user will leave CR in
> +            (forward-char 1)) ;  the source code. Let's don't stuck here.

"Let's not get stuck here."

> -(defun hif-possibly-hide ()
> +(defun hif-possibly-hide (expand-reinclusion)
>    "Called at #ifX expression, this hides those parts that should be hidden.
>  It uses the judgment of `hide-ifdef-evaluator'."

Doc should say what the argument means.


> +(defun hif-evaluate-macro (rstart rend)
> +  "Evaluate the macro expansion result for a region.
> +If no region active, find the current #ifdefs and evaluate the result. Currently

Use two spaces between sentences.

> +it support only math calculations, strings or argumented macros can not be

supports

> -(defun hide-ifdef-define (var)
> +(defun hide-ifdef-define (var val)

Why not make VAL optional?

> +  "Define a VAR optionally to a specific value VAL into `hide-ifdef-env'.
> +This allows #ifdef VAR from being hidden."

Suggestion:
"Define VAR to VAL (default 1) in `hide-ifdef-env'."

> @@ -1618,11 +1860,14 @@ It does not do the work that's pointless to redo on a recursive entry."
>  Assume that defined symbols have been added to `hide-ifdef-env'.
>  The text hidden is the text that would not be included by the C
>  preprocessor if it were given the file with those symbols defined.
> +If this command is prefixed, hide also the #ifdefs themselves.

Suggestion:
"With optional prefix agument ARG, also hide the #ifdefs themselves."

>    (interactive)
> -  (message "Hiding...")
> +  (let ((hide-ifdef-lines current-prefix-arg))

I think this should take an explicit prefix argument.

> +(defun hide-ifdef-block (&optional start end)
> +  "Hide the ifdef block (true or false part) enclosing or before the cursor.
> +If prefixed, it will also hide #ifdefs themselves."

Suggestion:
"With optional prefix agument ARG, also hide the #ifdefs themselves."

> +  (interactive "r")
> +  (let ((hide-ifdef-lines current-prefix-arg))

I think this should explicitly take a prefix argument.





  reply	other threads:[~2014-06-28  1:53 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-26 13:51 bug#17854: The patch #3 of 3 for hideif.el, a lot of bug fixes and enhancements Luke Lee
2014-06-26 16:56 ` Glenn Morris
2014-06-26 16:59   ` Glenn Morris
2014-06-27  9:08     ` Luke Lee
2014-06-27  9:26   ` Luke Lee
2014-06-27  9:37 ` Luke Lee
2014-06-28  1:53   ` Glenn Morris [this message]
2014-06-28  3:22     ` Glenn Morris
2014-06-30 14:42     ` Luke Lee
2014-06-30 21:47       ` Stefan Monnier
2014-07-01  1:55         ` Luke Lee
2014-07-01  6:44       ` Glenn Morris
2014-07-03  2:37         ` Luke Lee
2014-07-07  0:02           ` Glenn Morris
2014-07-07  1:00             ` Glenn Morris
2014-07-07  9:05               ` Luke Lee
2014-07-07  9:04             ` Luke Lee
2014-07-07 16:10               ` Glenn Morris
2014-07-08  2:10                 ` Luke Lee
2014-07-07  9:04 ` bug#17854: Completed Luke Lee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=75lhsh7qb8.fsf@fencepost.gnu.org \
    --to=rgm@gnu.org \
    --cc=17854@debbugs.gnu.org \
    --cc=luke.yx.lee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.