Profile

Cover photo
Prakash Kailasa
89 followers|23,611 views
AboutPostsPhotosVideos

Stream

 
Is there an emacs command to list all environment variables? I could not find any, and came up with this short snippet:

(defun listenv ()
  "List all environment variables in order."
  (interactive)
  (switch-to-buffer-other-window "*env*")
  (erase-buffer)
  (insert (mapconcat 'identity process-environment "\n"))
  (sort-lines nil (point-min) (point-max)))
3
1
Christoph David Hermann's profile photo赵某某's profile photo
 
Maybe the variable  initial-environment is what you are looking for. 
Add a comment...

Prakash Kailasa

Discussion  - 
 
Perl frameworks are missing from this list. I am not sure if plans are afoot in the Catalyst, Dancer, Mojolicious and other framework communities, but it would be nice to if they submitted versions of the benchmarks to this.
4
Aaron Swenson's profile photo
 
I can't believe they didn't consider Perl at all!
Add a comment...

Prakash Kailasa

Shared publicly  - 
 
 
Really good visualization of perceived vs actual wealth inequality in the U.S.
1 comment on original post
1
Add a comment...

Prakash Kailasa

Shared publicly  - 
1
barefootmeg's profile photo
 
I totally agree about non-tested subjects getting kicked to the side. We've seen that happen in our kids schools. 

The one thing the writer didn't mention was the added stress on these tests that is passed on to the students. When I took standardized tests in school it was no big deal. We got scored, but it didn't mean much other than to provide a sense of where I was at academically. But now so much rides on these tests (mostly teachers' careers and whether or not a school will remain open or be revamped some how) that the pressure is pushed all the way down from the district to the kids. We get phone calls home a week in advance reminding us that testing is coming up. There are rewards for attendance which lead the kids to go in even when they're sick. My kids, for several years in a row, used to get stomach aches and head aches the weekend before testing. In their minds, all of their future rests upon these stupid tests. Somehow, that's what's being drilled into them at school. 
Add a comment...

Prakash Kailasa

Shared publicly  - 
 
This is awesome. Crossword puzzle + Regular expressions!
 
A puzzle from the MIT Mystery Hunt, for all you regular expression fans. PDF at http://www.coinheist.com/rubik/a_regular_crossword/grid.pdf
24 comments on original post
1
Add a comment...
 
While creating a prog-mode for a DSL that used at work, I needed to know if the point is in a comment block. Googling pointed me to a function that I never heard of (not surprising since my elisp-fu is very little): syntax-ppss, which returns the "Parse-Partial-Sexp State at POS, defaulting to point."

The return value is a list of elements, of which the 4th element is a boolean indicating if point is inside a comment or not.

So, wrapping it in a little function:

    (defun inside-comment-p ()
      "return t if point is inside a comment block"
      (nth 4 (syntax-ppss)))

This is working nicely for my purpose, but I can't help think that there must be a better way than to use a function with such un-obvious name.

Is there a better way?
3
Nick Alcock's profile photoRudolf Olah's profile photoAlex Schroeder's profile photoDmitry Gutov's profile photo
4 comments
 
syntax-ppss is a caching wrapper for parse-partial-sexp, so using the latter is only recommended when you need to calculate the state between two points.
Add a comment...
In their circles
184 people
Have them in circles
89 people
Cory Koch's profile photo
Xah Lee's profile photo
Madhu Gogulapati's profile photo
ErgoEmacs's profile photo
Marc Bernstein's profile photo
Rogério Toth's profile photo
Kanpur Info's profile photo
Ranjith Kandur's profile photo
Om Tiwari's profile photo
 
I am experiencing something weird.

I have a prog-mode for a homegrown DSL. The mode was written using generic-x and mmm-mode. It is autoloaded for files with certain extensions.

I have recently noticed that after a source file with one of the known extensions is visited, I sometimes get the message "Symbol's function definition is void: vector" (most recently, I was executing a vc-annotate command when this happened).

I checked for the function definition of vector before and after visiting the source file. The function definition existed before visiting, but after visiting, it disappeared.

I inserted (message "...") lines at appropriate places in the code for this prog-mode, but those messages indicated that the during the execution of the prog-mode code, everything was fine.

So, something else is happening after the prog-mode is completely loaded, but I don't know what it is. So, my question to all you emacs-gurus is: how do I find out what is causing this?
1
Prakash Kailasa's profile photoDmitry Gutov's profile photo
4 comments
 
+Prakash Kailasa You've installed something very broken, either that pacakge, or maybe some additional elisp code that your distribution has put into the global site-lisp dir.

That "snapshot" is very old anyway. The current snapshot version is 24.3.50.3.
Add a comment...

Prakash Kailasa

Customization  - 
 
When I am editing code, often I copy current line, comment it and paste it below before beginning to edit the cloned code. So,  after doing a lot of times this I wrote up this little function. I have used emacs for a long time, but my elisp-fu is still next to nothing, so it took me a while to get things right. Especially since I wanted it to work for either active region or current line.

    (defun copy-comment-paste ()
      "copy active region/current line, comment, and then paste"
      (interactive)
      (unless (use-region-p)
        (progn
          (beginning-of-line 2)
          (push-mark (line-beginning-position 0))))
      (kill-ring-save (region-beginning) (region-end))
      (comment-region (region-beginning) (region-end))
      (yank)
      (exchange-point-and-mark)
      (indent-according-to-mode))

Here's the gist for the same: https://gist.github.com/prakashk/5319782

Please suggest any improvements.
8
Mark Hepburn's profile photoGavin Panella's profile photobin chen's profile photoNoah Friedman's profile photo
21 comments
 
+Gavin Panella No, in fact save-excursion is the right thing to use.  I was debugging something earlier and forgot to put it back.  Thanks for the reminder :-)

Here's the latest version, which I think has somewhat more helpful behavior in a couple of corner cases.

(defun copy-and-comment-lines (beg end)
  "Insert a copy of the lines in region and comment them.
When transient-mark-mode is enabled, if no region is active then only the
current line is acted upon.

If the region begins or ends in the middle of a line, that entire line is
copied, even if the region is narrowed to the middle of a line.
The copied lines are commented according to mode.

Current position is preserved."
  (interactive "r")
  (save-excursion
    (save-restriction
      (widen)
      (when (and transient-mark-mode (not (use-region-p)))
        (setq beg (line-beginning-position)
              end (line-beginning-position 2)))

      (goto-char beg)
      (setq beg (line-beginning-position))
      (goto-char end)
      (unless (= (point) (line-beginning-position))
        (setq end (line-beginning-position 2)))

      (goto-char beg)
      (insert-before-markers (buffer-substring-no-properties beg end))
      (comment-region beg end))

    ;; Don't modify region or display if called as a function.
    (when (called-interactively-p 'all)
      ;; If narrowed, make sure newly commented lines are visible in the
      ;; narrowed region.
      (when (> (point-min) beg)
        (narrow-to-region beg (point-max)))

      ;; Make sure newly commented lines are visible in the window if at the
      ;; very top.
      (unless (pos-visible-in-window-p beg)
        (set-window-start (selected-window) beg)))))
Add a comment...

Prakash Kailasa

Shared publicly  - 
 
I have been watching  #Jeopardy for nearly 20 years. Last night's episode (second day of the Teen Tournament finals) is by far the best one I have seen in all these years.

Way to go Leonard Cooper!
1
Add a comment...

Prakash Kailasa

Shared publicly  - 
1
Add a comment...

Prakash Kailasa

Shared publicly  - 
 
Persistent little guy!!
1
1
Vijay Bandari's profile photo
Add a comment...

Prakash Kailasa
owner

Discussion  - 
 
To eliminate confusion, I will be deleting this community soon, since another, more thriving Perl community already exists (https://plus.google.com/communities/105035827361077606043).

If you are not already there, please visit and join the other community.

That's all.
Perl
Practical Extraction and Reporting Language
View community
1
Add a comment...
People
In their circles
184 people
Have them in circles
89 people
Cory Koch's profile photo
Xah Lee's profile photo
Madhu Gogulapati's profile photo
ErgoEmacs's profile photo
Marc Bernstein's profile photo
Rogério Toth's profile photo
Kanpur Info's profile photo
Ranjith Kandur's profile photo
Om Tiwari's profile photo
Links
Contributor to