home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / gnu / emacs / bug / 1498 < prev    next >
Encoding:
Text File  |  1992-11-19  |  2.2 KB  |  97 lines

  1. Newsgroups: gnu.emacs.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!ll.mit.edu!cogen
  3. From: cogen@ll.mit.edu (David Cogen)
  4. Subject: c++ mode has problems.
  5. Message-ID: <9211191033.AA06489@LL.MIT.EDU>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Thu, 19 Nov 1992 05:33:38 GMT
  10. Approved: bug-gnu-emacs@prep.ai.mit.edu
  11. Lines: 84
  12.  
  13. I have noticed several problems with c++ mode. Is c++ mode a supported part of
  14. gnuemacs? I am using emacs version 18.57.3, and the file c++-mode.el begins as
  15. follows:
  16.  
  17.   ;; C++ code editing commands for Emacs
  18.   ;; 1987 Dave Detlefs  (dld@cs.cmu.edu) 
  19.   ;; and  Stewart Clamen (clamen@cs.cmu.edu).
  20.   ;; Done by fairly faithful modification of:
  21.   ;; c-mode.el, Copyright (C) 1985 Richard M. Stallman.
  22.  
  23. (Is this the right one?)
  24.  
  25. Anyway, here are the problems:
  26.  
  27.  
  28. 1) Parenthesis-like characters are treated as such even if they are embedded in
  29. a string or character constant. For example:
  30.  
  31.   // -*- C++ -*-
  32.  
  33.   static char chars [80];
  34.   
  35.   int fun ()
  36.   {
  37.     int i,j,k;
  38.     for (i=0; chars[i]!=']'; i++);
  39.     return i;
  40.   }
  41.  
  42. The embedded `]` matches the parenthesis following the for.
  43.  
  44.  
  45. 2) Comments are not ignored for the purpose of matching parentheses. Examples:
  46.  
  47.   int ff ()
  48.   {
  49.     // This comment should be ignored. }
  50.     more_code_here ();
  51.   }
  52.  
  53.   int gg ()
  54.   {
  55.     /* This comment should be ignored. } */
  56.     mode_code_here ();
  57.   }
  58.  
  59. In both cases, the } inside the comment terminates the { at the beginning of
  60. the function. But really, all text inside a command must be ignored. (I realize
  61. that this may be difficult with /* ... */ comments, but with // comments it
  62. should be very easy to implement.)
  63.  
  64.  
  65. 2.5) The above applies to conditionally defined code as well. For example,
  66. braces inside an #if 0...#endif construct. I believe these should be ignored as
  67. well. 
  68.  
  69.  
  70. 3) Old style comments are messed up when doing c++-indent-defun (ESC C-x).
  71. Before: 
  72.  
  73.   int hh ()
  74.   {
  75.     /* A multiline comment in a c++ function.
  76.        I'll make it span several lines.
  77.        Another line.
  78.        Yet another. 
  79.      */
  80.   }
  81.  
  82. After:
  83.  
  84.   int hh ()
  85.   {
  86.     /* A multiline comment in a c++ function.
  87.       I'll make it span several lines.
  88.         Another line.
  89.           Yet another. 
  90.             */
  91.   }
  92.  
  93.  
  94. David Cogen.
  95.  
  96.  
  97.