* sh-script beg-end of function @ 2007-11-19 20:43 Andreas Röhler 2007-11-21 12:05 ` Richard Stallman 0 siblings, 1 reply; 13+ messages in thread From: Andreas Röhler @ 2007-11-19 20:43 UTC (permalink / raw) To: emacs-devel Hi all, in sh-script-mode C-M-a jumped to the beginning of the buffer, C-M-e to the end with GNU Emacs 23.0.50.2 (i686-pc-linux-gnu, GTK+ Version 2.10.6) of 2007-10-30 To have a more convienent behaviour I made this: ;;;;;;;;; (require 'newcomment) (defcustom sh-beginning-of-function-regexp "^[A-Za-z_][A-Za-z_0-9]*" "" :type 'regexp :group 'sh-script) (defun sh-beginning-of-function () "Re-search-backward sh-beginning-of-function-regexp nil t 1 " (interactive) (re-search-backward sh-beginning-of-function-regexp nil t 1)) (defcustom beginning-of-defun-function 'sh-beginning-of-function "" :type 'symbol :group 'sh-script) (defun sh-end-of-function (&optional arg) "Move forward to end of a function or command in sh-script. With numeric argument, do it that many times. " (interactive "p") (or arg (setq arg 1)) (forward-line 1) ;; between functions, skip next beginning (when (eq 0 (car (parse-partial-sexp (point-min) (point)))) (setq arg (1+ arg))) (let ((erf (re-search-forward sh-beginning-of-function-regexp nil t arg))) (goto-char (match-beginning 0)) (unless erf ;; already last top level form (goto-char (point-max))) (skip-chars-backward " \t\r\n\f")) ;; skip comments (while (progn (comment-normalize-vars) (comment-beginning)) (forward-line -1) (end-of-line) (skip-chars-backward " \t\r\n\f"))) (defcustom end-of-defun-function 'sh-end-of-function "" :type 'symbol :group 'sh-script) (defun sh-set-beginning-of-function () " " (interactive) (setq beginning-of-defun-function 'sh-beginning-of-function)) (defun sh-set-end-of-function () " " (interactive) (setq end-of-defun-function 'sh-end-of-function)) (add-hook 'sh-mode-hook 'sh-set-beginning-of-function) (add-hook 'sh-mode-hook 'sh-set-end-of-function) ;;;;;;; Maybe I could use another form already existing? Comments welcome Andreas Röhler ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sh-script beg-end of function 2007-11-19 20:43 sh-script beg-end of function Andreas Röhler @ 2007-11-21 12:05 ` Richard Stallman 2007-11-21 15:52 ` Andreas Röhler 2007-11-21 20:19 ` Stefan Monnier 0 siblings, 2 replies; 13+ messages in thread From: Richard Stallman @ 2007-11-21 12:05 UTC (permalink / raw) To: Andreas Röhler; +Cc: emacs-devel This is a good change to make. Would others please check the code and send Andreas suggestions? To use this code, we'd need legal papers of some kind. Would you like to sign a copyright assignment? (A disclaimer would suffice instead, for this change.) ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sh-script beg-end of function 2007-11-21 12:05 ` Richard Stallman @ 2007-11-21 15:52 ` Andreas Röhler 2007-11-22 8:22 ` Richard Stallman 2007-11-21 20:19 ` Stefan Monnier 1 sibling, 1 reply; 13+ messages in thread From: Andreas Röhler @ 2007-11-21 15:52 UTC (permalink / raw) To: rms; +Cc: emacs-devel Am Mittwoch, 21. November 2007 13:05 schrieb Richard Stallman: > This is a good change to make. > Would others please check the code and send Andreas suggestions? > > To use this code, we'd need legal papers of some kind. > Would you like to sign a copyright assignment? > (A disclaimer would suffice instead, for this change.) > > Below the code with the disclaimer and some docstrings inserted. Please send the papers you want me to sign, so I may reflect it at least for later occasions. Adress is known by FSF. Andreas Röhler ;;; sh-beg-end.el --- Establish something useful for ;;; beginning- and end-of-defun in shell-script-mode ;; Copyright (C) 2007 by Andreas Röhler ;; <andreas.roehler@online.de> ;; This file is free software; you can redistribute it ;; and/or modify it under the terms of the GNU General ;; Public License as published by the Free Software ;; Foundation; either version 3, or (at your option) ;; any later version. ;; This file is distributed in the hope that it will be ;; useful, but WITHOUT ANY WARRANTY; without even the ;; implied warranty of MERCHANTABILITY or FITNESS FOR A ;; PARTICULAR PURPOSE. See the GNU General Public ;; License for more details. ;; You should have received a copy of the GNU General ;; Public License along with GNU Emacs; see the file ;; COPYING. If not, write to the Free Software ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;; Commentary: Jump to the beginning or end of a ;;; top-level-form in sh-mode - "Shell-script"-mode ;;; Code: (require 'newcomment) (defcustom sh-beginning-of-function-regexp "^[A-Za-z_][A-Za-z_0-9]*" "Regexp to identify the beginning of a top-level-form in shell-script-mode." :type 'regexp :group 'sh-script) (defun sh-beginning-of-function () "Re-search-backward sh-beginning-of-function-regexp nil t 1" (interactive) (re-search-backward sh-beginning-of-function-regexp nil t 1)) (defcustom beginning-of-defun-function 'sh-beginning-of-function "'sh-beginning-of-function" :type 'symbol :group 'sh-script) (defun sh-end-of-function (&optional arg) "Move forward to end of a function or command in sh-script. With numeric argument, do it that many times." (interactive "p") (or arg (setq arg 1)) (forward-line 1) ;; between functions, skip next beginning (when (eq 0 (car (parse-partial-sexp (point-min) (point)))) (setq arg (1+ arg))) (let ((erf (re-search-forward sh-beginning-of-function-regexp nil t arg))) (goto-char (match-beginning 0)) (unless erf ;; already last top level form (goto-char (point-max))) (skip-chars-backward " \t\r\n\f")) ;; skip comments (while (progn (comment-normalize-vars) (comment-beginning)) (forward-line -1) (end-of-line) (skip-chars-backward " \t\r\n\f"))) (defcustom end-of-defun-function 'sh-end-of-function "Establish useful behavior for `end-of-defun' in `shell-script-mode'." :type 'symbol :group 'sh-script) (defun sh-set-beginning-of-function () "'sh-beginning-of-function" (interactive) (setq beginning-of-defun-function 'sh-beginning-of-function)) (defun sh-set-end-of-function () "'sh-end-of-function" (interactive) (setq end-of-defun-function 'sh-end-of-function)) (add-hook 'sh-mode-hook 'sh-set-beginning-of-function) (add-hook 'sh-mode-hook 'sh-set-end-of-function) (provide 'sh-beg-end) ;;; sh-beg-end.el ends here ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sh-script beg-end of function 2007-11-21 15:52 ` Andreas Röhler @ 2007-11-22 8:22 ` Richard Stallman 0 siblings, 0 replies; 13+ messages in thread From: Richard Stallman @ 2007-11-22 8:22 UTC (permalink / raw) To: Andreas Röhler; +Cc: emacs-devel Below the code with the disclaimer and some docstrings inserted. The text you inserted is called the license notice. A disclaimer is something you sign on paper. I sent you a separate message about that. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sh-script beg-end of function 2007-11-21 12:05 ` Richard Stallman 2007-11-21 15:52 ` Andreas Röhler @ 2007-11-21 20:19 ` Stefan Monnier 2007-11-22 7:26 ` Andreas Röhler 1 sibling, 1 reply; 13+ messages in thread From: Stefan Monnier @ 2007-11-21 20:19 UTC (permalink / raw) To: rms; +Cc: Andreas Röhler, emacs-devel > This is a good change to make. > Would others please check the code and send Andreas suggestions? I've installed a simpler change which should provide comparable functionality. Stefan --- lisp/progmodes/sh-script.el 26 Sep 2007 00:27:18 -0000 1.203 +++ lisp/progmodes/sh-script.el 21 Nov 2007 20:19:32 -0000 @@ -1524,6 +1524,8 @@ skeleton-filter-function 'sh-feature skeleton-newline-indent-rigidly t sh-indent-supported-here nil) + (set (make-local-variable 'defun-prompt-regexp) + (concat "^\\(function[ \t]\\|[[:alnum:]]+[ \t]+()[ \t]+\\)")) (set (make-local-variable 'parse-sexp-ignore-comments) t) ;; Parse or insert magic number for exec, and set all variables depending ;; on the shell thus determined. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sh-script beg-end of function 2007-11-21 20:19 ` Stefan Monnier @ 2007-11-22 7:26 ` Andreas Röhler 2007-11-22 17:39 ` Stefan Monnier 0 siblings, 1 reply; 13+ messages in thread From: Andreas Röhler @ 2007-11-22 7:26 UTC (permalink / raw) To: emacs-devel; +Cc: Stefan Monnier, Richard Stallman Am Mittwoch, 21. November 2007 21:19 schrieb Stefan Monnier: > > This is a good change to make. > > Would others please check the code and send Andreas suggestions? > > I've installed a simpler change which should provide > comparable functionality. > > > Stefan > > > --- lisp/progmodes/sh-script.el 26 Sep 2007 00:27:18 -0000 1.203 > +++ lisp/progmodes/sh-script.el 21 Nov 2007 20:19:32 -0000 > @@ -1524,6 +1524,8 @@ > skeleton-filter-function 'sh-feature > skeleton-newline-indent-rigidly t > sh-indent-supported-here nil) > + (set (make-local-variable 'defun-prompt-regexp) > + (concat "^\\(function[ \t]\\|[[:alnum:]]+[ \t]+()[ \t]+\\)")) > (set (make-local-variable 'parse-sexp-ignore-comments) t) > ;; Parse or insert magic number for exec, and set all variables > depending ;; on the shell thus determined. > > Hi Stefan, I'm always pleased to see an alternative variant, a shorter one altogether. :) However, in this case, making `defun-prompt-regexp' a lokal variable away from customization seems not the appropriate way. I suggest to let the user decide about this regexp and make this decision available for all sh-scripts. For this we need a different name from defun-prompt-regexp. Functions don't play the role in sh-scripts as in other languages code. So it's probably not useful to require a "()" in that regexp. Can't figure out your solution for `end-of-defun-function'. Andreas Röhler ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sh-script beg-end of function 2007-11-22 7:26 ` Andreas Röhler @ 2007-11-22 17:39 ` Stefan Monnier 2007-11-22 18:56 ` Andreas Röhler 0 siblings, 1 reply; 13+ messages in thread From: Stefan Monnier @ 2007-11-22 17:39 UTC (permalink / raw) To: Andreas Röhler; +Cc: Richard Stallman, emacs-devel > However, in this case, making `defun-prompt-regexp' a > lokal variable away from customization seems not the > appropriate way. I suggest to let the user decide about > this regexp and make this decision available for all > sh-scripts. If you can give me some examples of other regexps which might be sometimes (but not always) preferable, send them along. > Functions don't play the role in sh-scripts as in other > languages code. Don't they? Can you expand on this? > So it's probably not useful to require > a "()" in that regexp. It requires either () or `function'. That's how the Bash manpage documents their syntax of functions. > Can't figure out your solution > for `end-of-defun-function'. See the docstring of end-of-defun. It'll just jump to the closing }. Stefan ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sh-script beg-end of function 2007-11-22 17:39 ` Stefan Monnier @ 2007-11-22 18:56 ` Andreas Röhler 2007-11-22 21:49 ` Stefan Monnier 0 siblings, 1 reply; 13+ messages in thread From: Andreas Röhler @ 2007-11-22 18:56 UTC (permalink / raw) To: emacs-devel; +Cc: Stefan Monnier, Richard Stallman Am Donnerstag, 22. November 2007 18:39 schrieb Stefan Monnier: > > However, in this case, making `defun-prompt-regexp' a > > lokal variable away from customization seems not the > > appropriate way. I suggest to let the user decide about > > this regexp and make this decision available for all > > sh-scripts. > > If you can give me some examples of other regexps which might be > sometimes (but not always) preferable, send them along. > > > Functions don't play the role in sh-scripts as in other > > languages code. > > Don't they? Can you expand on this? > > > So it's probably not useful to require > > a "()" in that regexp. > > It requires either () or `function'. That's how the Bash manpage > documents their syntax of functions. > > > Can't figure out your solution > > for `end-of-defun-function'. > > See the docstring of end-of-defun. It'll just jump to the closing }. > > > Stefan > The misunderstanding we seem to have might lie in different interpretation of what's at stake. Your code adresses a function in it's literally sence, whereas my code adresses "top-level-form", a more abstract thing. A "top-level-form" form BTW already is adressed by Emacs-Lisp `end-of-defun' or `beginning-of-defun' and I already remarked the naming as somehow misleading therefore, but that's a matter from the past. Now, jumping to the beginning of a top-level-form doesn't mean necessarily beginning of a function and "end" must not mean end of a function, however it can. My "end"-code expresses something like "end of last part of code before beginning of next toplevel-form, if any, or end of last part..." Certainly we may discuss if that interpretation useful or not. Andreas Röhler ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sh-script beg-end of function 2007-11-22 18:56 ` Andreas Röhler @ 2007-11-22 21:49 ` Stefan Monnier 2007-11-23 15:33 ` Andreas Röhler 2007-11-23 15:56 ` Andreas Röhler 0 siblings, 2 replies; 13+ messages in thread From: Stefan Monnier @ 2007-11-22 21:49 UTC (permalink / raw) To: Andreas Röhler; +Cc: Richard Stallman, emacs-devel > Your code adresses a function in it's literally sence, > whereas my code adresses "top-level-form", a more > abstract thing. A "top-level-form" form BTW already > is adressed by Emacs-Lisp `end-of-defun' or > `beginning-of-defun' and I already remarked the naming > as somehow misleading therefore, but that's a matter > from the past. I understand, but the way I see it, either you're in an sh buffer which has functions, in which case the defun-prompt-regexp will work fine, or you're in an sh buffer which basically only contains "unstructured" "straight-line" code. You want to cater to this latter case as well. It might be OK, but in my experience which units are useful in this case is hard to know in general because it depends a lot on the writing style used (which is anything but standardized sadly). In many cases paragraph-based navigation will work best. I don't claim that my defun-prompt-regexp setting is the end-all-be-all here. It's just a good starting point. But also any replacement should be at least as good. Most importantly: jumping to the end of a real function should jump to the closing "}". If you want to submit an improvement, please send it as a patch against the current sh-script.el code. This will make it easier for us to integrate your code. BTW, `end-of-defun-function' seems to be used in end-of-defun in a ... weird way, so maybe you'll want to fix that first. Maybe I'll post a suggestion about it on this list later. Stefan PS: Comments about your original code: - the "defcustom beginning-of-defun-function" is wrong: you can only use defcustom for variable you *create* (that are your own), not to set variables defined in other packages. - The docstring of sh-beginning-of-function is unusable. It could instead explain what is considered as a "defun". - Instead of (parse-partial-sexp (point-min) (point)), you can use syntax-ppss. - the docstring of `comment-beginning' says "Find the beginning of the enclosing comment" so I'm wondering why you decided to use that in a context where you have no idea whether or not you're inside a comment. Why don't you just use (forward-comment (- (point-max))) and skip the newcomment madness altogether? ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sh-script beg-end of function 2007-11-22 21:49 ` Stefan Monnier @ 2007-11-23 15:33 ` Andreas Röhler 2007-11-23 16:34 ` Stefan Monnier 2007-11-23 15:56 ` Andreas Röhler 1 sibling, 1 reply; 13+ messages in thread From: Andreas Röhler @ 2007-11-23 15:33 UTC (permalink / raw) To: emacs-devel; +Cc: Stefan Monnier, Richard Stallman Am Donnerstag, 22. November 2007 22:49 schrieb Stefan Monnier: > > Your code adresses a function in it's literally sence, > > whereas my code adresses "top-level-form", a more > > abstract thing. A "top-level-form" form BTW already > > is adressed by Emacs-Lisp `end-of-defun' or > > `beginning-of-defun' and I already remarked the naming > > as somehow misleading therefore, but that's a matter > > from the past. > > I understand, but the way I see it, either you're in an sh buffer which > has functions, in which case the defun-prompt-regexp will work fine, or > you're in an sh buffer which basically only contains "unstructured" > "straight-line" code. You want to cater to this latter case as well. > > It might be OK, but in my experience which units are useful in this case > is hard to know in general because it depends a lot on the writing style > used (which is anything but standardized sadly). In many cases > paragraph-based navigation will work best. > That's true. Took your hint to make changes rely on paragraph-. > I don't claim that my defun-prompt-regexp setting is the > end-all-be-all here. It's just a good starting point. But also any > replacement should be at least as good. Most importantly: jumping to > the end of a real function should jump to the closing "}". > Not, if exists usually no closing "}" while writing. I prefer to set closings last and manually - the reports I get then are more valuable than possible savings before. > If you want to submit an improvement, please send it as a patch against > the current sh-script.el code. This will make it easier for us to > integrate your code. Here a small diff to enable modes to set beginning-of-defun-function without disturbing each other: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff -c emacs-lisp/lisp.el lisp.el *** /emacs-lisp/lisp.el 2007-07-26 07:26:47.000000000 +0200 --- lisp.el 2007-11-23 15:49:52.000000000 +0100 *************** *** 178,183 **** --- 178,184 ---- The function (of no args) should go to the line on which the current defun starts, and return non-nil, or should return nil if it can't find the beginning.") + (make-variable-buffer-local 'beginning-of-defun-function) (defun beginning-of-defun (&optional arg) "Move backward to the beginning of a defun. *************** *** 291,296 **** --- 292,298 ---- This is used to find the end of the defun instead of using the normal recipe (see `end-of-defun'). Major modes can define this if the normal method is not appropriate.") + (make-variable-buffer-local 'end-of-defun-function) (defun buffer-end (arg) "Return the \"far end\" position of the buffer, in direction ARG. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > BTW, `end-of-defun-function' seems to be used in end-of-defun in > a ... weird way, so maybe you'll want to fix that first. This should be done with this diff above. Remaining bugs AFAIS occur occasionally but are deep-rooted from underlying move-functions and not to adress here. > Maybe I'll > post a suggestion about it on this list later. > > > Stefan > > > PS: Comments about your original code: > - the "defcustom beginning-of-defun-function" is wrong: you can only > use defcustom for variable you *create* (that are your own), not to set > variables defined in other packages. OK, thanks. Dropped that part. > - The docstring of sh-beginning-of-function is unusable. It could > instead explain what is considered as a "defun". Changed. > - Instead of (parse-partial-sexp (point-min) (point)), you can use > syntax-ppss. Dropped that part of code completely. BTW, reading doku of `syntax-ppss' "The returned value is the same as `parse-partial-sexp' except that the 2nd and 6th values of the returned state cannot be relied upon." I say: so let's take `parse-partial-sexp' and rely upon... Maybe I'm wrong here? > - the docstring of `comment-beginning' says "Find the beginning of the > enclosing comment" so I'm wondering why you decided to use that in > a context where you have no idea whether or not you're inside > a comment. Why don't you just use (forward-comment (- (point-max))) Thanks. Simply wasn't aware of that. Rewrote the code. Changed "function" to "form" too in order to avoid misunderstandings. > and skip the > newcomment madness Wouldn't dare to speak that out :) ... Thanks again Andreas Röhler ;;; sh-beg-end.el --- Something for C-M-a, ;;; C-M-e, M-a and M-e in shell-script-mode ;; Copyright (C) 2007 by Andreas Röhler ;; <andreas.roehler@online.de> ;; Keywords: languages ;; This file is free software; you can redistribute it ;; and/or modify it under the terms of the GNU General ;; Public License as published by the Free Software ;; Foundation; either version 3, or (at your option) ;; any later version. ;; This file is distributed in the hope that it will be ;; useful, but WITHOUT ANY WARRANTY; without even the ;; implied warranty of MERCHANTABILITY or FITNESS FOR A ;; PARTICULAR PURPOSE. See the GNU General Public ;; License for more details. ;; You should have received a copy of the GNU General ;; Public License along with GNU Emacs; see the file ;; COPYING. If not, write to the Free Software ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;; Commentary: ;; C-M-a, C-M-e: jump to the beginning or end of a ;; top-level-form in sh-mode - "Shell-script"-mode. ;; M-a, M-e: jump to the beginning or end of command in ;; a given line, forward or backward next beginning or ;; end with. With argument do this as many times. ;;; Code: ;; this belongs into sh-script.el (make-variable-buffer-local 'beginning-of-defun-function) (make-variable-buffer-local 'end-of-defun-function) (defcustom sh-beginning-of-form-regexp "^[A-Za-z_][A-Za-z_0-9]*" " " :type 'regexp :group 'lisp) (defun sh-beginning-of-form () "Move to the beginning of a top-level-form in sh-script. With numeric argument, do it that many times." (interactive) (re-search-backward sh-beginning-of-form-regexp nil t 1)) (defun sh-end-of-form (&optional arg) "Move to the end of a top-level-form in sh-script. With numeric argument, do it that many times." (interactive "p") (let ((arg (or arg 1))) (while (forward-comment 1) (forward-comment 1)) (unless (looking-back "^[ \t]*") (setq arg (1+ arg))) (forward-paragraph arg) (skip-chars-backward " \t\r\n\f") (unless (looking-at "}") (back-to-indentation)) (if (looking-back "^[ \t]+") (progn (end-of-line) (sh-end-of-form)) (end-of-line) (skip-chars-backward " \t\r\n\f")))) (defun sh-set-beginning-of-form () "'sh-beginning-of-form" (interactive) (setq beginning-of-defun-function 'sh-beginning-of-form)) (defun sh-set-end-of-form () "'sh-end-of-form" (interactive) (setq end-of-defun-function 'sh-end-of-form)) (defun sh-beginning-of-command (&optional arg) "Move point to successive beginnings of commands." (interactive "p") (let ((arg (or arg 1)) (pos (point))) (back-to-indentation) (unless (eq pos (point)) (setq arg (1- arg))) (while (< 0 arg) (forward-line (- arg)) (setq arg (1- arg)) ;; skip comments and empty lines and closing braces (let ((pos (point))) (if (forward-comment -1) (while (forward-comment -1) (forward-comment -1)) (goto-char pos))) (while (or (empty-line-p) (looking-at "}")) (forward-line -1)) (back-to-indentation)))) (defun sh-end-of-command (&optional arg) "Move point to successive ends of commands." (interactive "p") (let ((arg (or arg 1)) (pos (point))) (end-of-line) (skip-chars-backward " \t\r\n\f" (line-beginning-position)) (unless (eq pos (point)) (setq arg (1- arg))) (while (< 0 arg) (forward-line arg) (setq arg (1- arg))) (end-of-line) (skip-chars-backward " \t\r\n\f" (line-beginning-position)) (while (or (empty-line-p) (forward-comment 1)) (forward-line 1) (end-of-line)) (skip-chars-backward " \t\r\n\f"))) (add-hook 'sh-mode-hook 'sh-set-beginning-of-form) (add-hook 'sh-mode-hook 'sh-set-end-of-form) (provide 'sh-beg-end) ;;; sh-beg-end.el ends here ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sh-script beg-end of function 2007-11-23 15:33 ` Andreas Röhler @ 2007-11-23 16:34 ` Stefan Monnier 2007-11-24 13:45 ` Andreas Röhler 0 siblings, 1 reply; 13+ messages in thread From: Stefan Monnier @ 2007-11-23 16:34 UTC (permalink / raw) To: Andreas Röhler; +Cc: Richard Stallman, emacs-devel >> replacement should be at least as good. Most importantly: jumping to >> the end of a real function should jump to the closing "}". > Not, if exists usually no closing "}" while writing. I prefer to > set closings last and manually - the reports I get then > are more valuable than possible savings before. The case where a function is not yet completed is the rare exception and shouldn't drive the decision as to what the main behavior should be. > Here a small diff to enable modes to set beginning-of-defun-function without > disturbing each other: They can (and should/must) already do that by using `make-local-variable'. Grep for beginning-of-defun-function in lisp/**/*.el to see how other modes do it. >> - the docstring of `comment-beginning' says "Find the beginning of the >> enclosing comment" so I'm wondering why you decided to use that in >> a context where you have no idea whether or not you're inside >> a comment. Why don't you just use (forward-comment (- (point-max))) > Thanks. Simply wasn't aware of that. That's odd: seeing your posts on this list, you clearly spent a fair bit of time dealing with `comment-beginning': the first thing you should do in such a case is read its docstring. Again, please send your code as a *patch*. Stefan ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sh-script beg-end of function 2007-11-23 16:34 ` Stefan Monnier @ 2007-11-24 13:45 ` Andreas Röhler 0 siblings, 0 replies; 13+ messages in thread From: Andreas Röhler @ 2007-11-24 13:45 UTC (permalink / raw) To: emacs-devel; +Cc: Stefan Monnier, Richard Stallman Am Freitag, 23. November 2007 17:34 schrieb Stefan Monnier: > >> replacement should be at least as good. Most importantly: jumping to > >> the end of a real function should jump to the closing "}". > > > > Not, if exists usually no closing "}" while writing. I prefer to > > set closings last and manually - the reports I get then > > are more valuable than possible savings before. > > The case where a function is not yet completed is the rare exception and > shouldn't drive the decision as to what the main behavior should be. > > > Here a small diff to enable modes to set beginning-of-defun-function > > without disturbing each other: > > They can (and should/must) already do that by using > `make-local-variable'. Grep for beginning-of-defun-function in > lisp/**/*.el to see how other modes do it. > > >> - the docstring of `comment-beginning' says "Find the beginning of the > >> enclosing comment" so I'm wondering why you decided to use that in > >> a context where you have no idea whether or not you're inside > >> a comment. Why don't you just use (forward-comment (- (point-max))) > > > > Thanks. Simply wasn't aware of that. > > That's odd: seeing your posts on this list, you clearly spent a fair bit > of time dealing with `comment-beginning': Sure? Can you prove this? Or better let's come to more serious questions: Indeed I stumbled over commenting at a time quite early with Emacs. Estimate it's now two years I sent you as maintainer my concerns with newcomment.el. And still I think, as commenting (and fontifying) are basics for all editors, everyone would expect Emacs being strong here. But is not, rather bug-ridden, sometimes lacking basic-features. Just to give a visual impression: open an empty buffer in Emacs-lisp mode, write "foo" and M-x comment-dwim `comment-dwim' places a comment-sign in column 41. foo ; No one would expect that. DWIM could mean before or after, but not at column 41. Certainly there is more than one way to change that, I could spent 10 minutes, one or two hours or half a day digging trough newcomment.el. Probably I simply should set this or another variable. BTW, checked comment-column: is a variable defined in `newcomment.el'. Its value is 0 But that's all not the point: An Editor should meet expectations of a wider range of people first and than offer more. Emacs sometimes comes with a lot of more, missing the first. Notwithstanding I use Emacs with growing pleasure. I'm not criticing Emacs as such: idea is valid, Emacs Lisp is fine, altogether an excellent tool. So why not simply cure things? Consider the amount of code spent to commenting in C-source already, simple.el deals with it a lot, then newcomment.el. Also we have "Comments in C" and probably in a lot of mode-files. The amount of code seems reciprocal to the outcome. Well, that's life. We all have experienced that situation. It's not your fault, not mine. Looking through the commenting-code I got the impression: fiddling one bug might be produce the next that way. Considering my decent Emacs Lisp knowledge, there was nothing to do for me this time. That may change slowly. > the first thing you should do > in such a case is read its docstring. > Sincerely Andreas Röhler ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sh-script beg-end of function 2007-11-22 21:49 ` Stefan Monnier 2007-11-23 15:33 ` Andreas Röhler @ 2007-11-23 15:56 ` Andreas Röhler 1 sibling, 0 replies; 13+ messages in thread From: Andreas Röhler @ 2007-11-23 15:56 UTC (permalink / raw) To: emacs-devel; +Cc: Stefan Monnier, Richard Stallman Just see empty-line-p is my own: (defcustom empty-line-p-chars "^[ \t\f\r]*$" "empty-line-p-chars" :type 'regexp :group 'convenience) (defun empty-line-p (&optional ispec) "Returns t if cursor is at an empty line, nil otherwise." (interactive "p") (save-excursion (beginning-of-line) (when ispec (message "%s" (looking-at empty-line-p-chars))) (looking-at empty-line-p-chars))) ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2007-11-24 13:45 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-11-19 20:43 sh-script beg-end of function Andreas Röhler 2007-11-21 12:05 ` Richard Stallman 2007-11-21 15:52 ` Andreas Röhler 2007-11-22 8:22 ` Richard Stallman 2007-11-21 20:19 ` Stefan Monnier 2007-11-22 7:26 ` Andreas Röhler 2007-11-22 17:39 ` Stefan Monnier 2007-11-22 18:56 ` Andreas Röhler 2007-11-22 21:49 ` Stefan Monnier 2007-11-23 15:33 ` Andreas Röhler 2007-11-23 16:34 ` Stefan Monnier 2007-11-24 13:45 ` Andreas Röhler 2007-11-23 15:56 ` Andreas Röhler
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.