texts: How do I use tramp to launch a remote PowerShell?

texts:
I'm trying to launch a PowerShell on a remote Windows system using tramp.  So far all I've been able to do is start a PowerShell inside Emacs on the local (Windows) machine.  What is the connection incantation to, from within Emacs, launch a PowerShell on a remote Windows machine?  I know how to use tramp to connect to a *nix system using ssh in the connection string, but I don't know what the syntax is for connecting to a Windows system (using tramp). Here is my elisp so far. What do I need to add to connect to a remote machine?

(defun remote-powershell (machine)
  "Run PowerShell on MACHINE."
  (interactive "smachine: ")
  (let ((explicit-shell-file-name "powershell")
    (explicit-powershell-args '("-file" "-")))
    (call-interactively 'shell)))


texts: elpy - This feature requires the ‘jedi‘ package to be installed

texts:
I am getting following error when I do M-x elpy-goto-definition, even though I have installed jedi. I have followed following answer and this one.

Error message: This feature requires the ‘jedi‘ package to be installed.

My configuration as follows:

(use-package elpy
  :ensure t
  :init
  (elpy-enable))

(setq elpy-rpc-backend "jedi")

;;;;;;; Standard Jedi.el setting
(add-hook 'python-mode-hook 'jedi:setup)
(add-hook 'python-mode-hook 'jedi:ac-setup)
(setq jedi:setup-keys t)                      ; optional
(setq jedi:complete-on-dot t)                 ; optional
(add-hook 'elpy-mode-hook (lambda () (highlight-indentation-mode -1)))

[Q] How could I combine elpy and jedi?


texts:
Given a string in elisp, I'd like to simulate emacs receiving whatever keypresses are necessary to re-create that string. So given the string "Hello" emacs would act exactly the same as if I had pressed Shift+H,e,l,l,o. Note that this is not always the same thing as inserting text into the buffer -- some modes like isearch-mode listen to keypress events directly.

The reason this is necessary is because there are lots of modes and extensions that make the assumption that all input comes from the keyboard or make the assumption that any buffer/window/frame change will be associated with the keyboard input event, and a lot of the time they inspect data associated with that event. For the speech recognition mode that I work on to work seamlessly with the existing body of code, it can't just call directly into elisp to perform actions, instead it needs to tell elisp to press keys to cause those actions to happen.

I have found unread-command-events, but I'm not aware of any existing code that will translate strings to the necessary key sequences. Does something like that already exist?


texts: Flycheck could not find file under load-path

texts:
I have some elips *.el file in my ~/.emacs.d/gman/ folder, e.g. smart-inputp-methods.el. This folder is added to my load path at the beginning of .emacs file:

(add-to-list 'load-path "~/.emacs.d/gman")

Leter I importing it:

(require 'smart-input-methods)

Functions defined there successfully loaded, however Flycheck reports me error on that line, that file could not be found:

  Cannot open load file: no such file or directory, smart-input-methods

This is quite annoying, how can I fix that?


texts: Programmatically setting an org-mode heading

texts:
There exist functions to set tags, keywords, and priority values (org-set-tags-to, org-todo, and org-priority respectively), but what about setting the heading (item) itself?

For example:

*** TODO [#B] Some existing heading                      :URGENT:

(my/org-set-heading "The new heading")

*** TODO [#B] The new heading                            :URGENT:

Setting the heading is non-trivial; the logic needs to be mindful of outline folding, heading stars, the priority label, and tags-- at the very least.  Is there an org function that accomplishes this (or a 3rd-party library that includes one)?

I haven't found any org functions that accomplish this, but my apropos-fu has certainly failed me before.

A fairly thorough search suggests that I'll need to employ org-complex-heading-regexp, special care to the subtree/folding, and possibly a patch request.


texts: Can Emacs 25 use the new macOS Sierra tab features?

texts:
Can Emacs 25 on macOS leverage the new tab features introduced in macOS Sierra (10.12)?

If not, what is required for it to start supporting tabs?


texts: doc-view not working with emacs 25.2.1. (x86_64-w64-mingw32)

texts:
I am definitely no newbie and I think I now followed every little advice I could find online, and after 2 days doc-view is still not working :-( (it works fine on my older laptop under windows 10)

On my new laptop (windows 10) I installed emacs 25.2.1 (x86_64-w64-mingw32), I installed 64-bit-Ghostscript, I put the line

(setq doc-view-ghostscript-program "C:\gs\gs9.20\bin")

in my .emacs, I checked the PATH, I copied the dlls zlib1.dll, libtiff-5.dll, libpng16-16.dll, gsdll64.dll in the emacs bin directory.

Yesterday, I installed cygwin64 and it worked partly, but doc-view was breaking from time to time when the document contains images, and I thought it could be a problem, when my ming32-based emacs uses some cygwin programming or dlls. But now, without cygwin, doc-view stopped to work.

I am not really familiar with emacs lisp, but evaluating

(image-type-available-p 'png)

yields t. Opening a pdf-File yield just the pdf source text. Forcing Emacs to enter doc-view-mode yields Unable to render file. View extraced text instead?

The ghostscript executables are in my PATH.

Any suggestions, how I can debug this problem?


texts: Under Cygwin, how do we get a list of available printers?

texts:
I would like to choose which printer is used for printing in Emacs.  Before I can set printer-name to something, I need to know the names of the available printers.  Under Windows, I can see the available printers in the "Devices and Printers" control panel, but that does not give me names I can use in Emacs.  Under BSD or Linux I could use lpstat -d, but lpstat doesn't seem to be available in either Windows or the Cygwin command sets.  cygcheck -p /lpstat only returns entries related to lpstat and not the tool its self.  Is there another way to enumerate the available printers under Cygwin/Windows?

Windows 10 Professional Ver 10.0 Build 14393
emacs-w32                  25.1-1


texts: Retrieve a agenda view of days with scheduled or appointed tasks

texts:
I could get a:

1,  org-agenda-day-view
2,  org-agenda-week-view
3,  org-agenda-month-view
4,  org-agenda-year-view

How could I get a real agenda which filter the days with scheduled tasks

I collect all the scheduled tasks in ticker.org but unable to read them all in a calendar view

my org-agenda-file in .emacs.d/init.el

(setq org-agenda-files '("~/GTD/inbox.org"
                         "~/GTD/gtd.org"
                         "~/GTD/tickler.org"
                         "~/GTD/today.org"
                         "~/GTD/two_minutes.org"
                         "~/GTD/next_action.org"))


texts: How remove lines which are not equal in two buffers?

texts:
Consider the following buffers

buffer_1:

11111111
22222222
33333333
44444444

buffer_2:

55555555
66666666
22222222
44444444

I need to remove all lines which are not equal in buffer_1 and buffer_2.
The resulting buffer_3 must only contain equal lines, i.e.
buffer_3 must be like this

22222222
44444444

The lines which where NOT EQUAL and are removed from buffer_2 are

55555555
66666666

Is it possible in Emacs?


texts: Looking for feedback/review of emacs package?

texts:
That's meta-ish question but google isn't helpful in this case.

Are there any standardized habits of where/how/whether one should look for feedback on his (or her) new emacs package? Especially - before publishing it.

My particular case is that I started extracting and packaging longer and possibly reusable parts of my .emacs (first item is theme-switcher, but I have a few further ideas). As it is possible that someone else would benefit from this code (and maybe offer improvements), I consider publishing it to melpa. Still, my elisp knowledge is, well, very basic, so I hesitate offering my package without any screening – and unfortunately I have no colleagues who know elisp.

Is there a place where one could post here is my package, could you review it question?  Is this stackexchange right place? Or mayhaps some newsgroup or email list?


texts: When I archive a repeated task (let's say, a learning project of 15 minutes every Wednesday day for 2 month), the task gets archived in a date tree all under the day it was closed (cancelled) as a whole (to avoid repetition), with having under LOG all individual instances of repetition. It would be great if each of these individual "task happenings" were archived under the date and time they were completed individually, and not just all as one block. Not sure if I made myself understood! :))


texts: How to exclude ncurses when building Emacs from source

texts:
I have a building environment/setup that contains ncurses, and I am looking to build Emacs master branch without that library.  I did not see any obvious option in the .configure --help dialog, or by Googling.

Q:  How, please, can I tell Emacs during the configure process to forget about ncurses -- i.e., pretend that it doesn't exist?

Background:  When the building environment contains ncurses, an Emacs version built from that environment will always look for it when it launches.  If ncurses is not there, Emacs fails to launch.  I would like to build Emacs that does not look for ncurses each time it launches.  gdb confirms that Emacs is looking for ncurses.  The only workaround I have found is to remove ncurses entirely from my building environment, which is not an ideal solution.

I've tried excluding everything I can think of, but Emacs is still looking for ncurses when it launches:

./configure \
--with-ns \
--without-dbus \
--without-gconf \
--without-gif \
--without-gnutls \
--without-gpm \
--without-imagemagick \
--without-jpeg \
--without-libotf \
--without-makeinfo \
--without-m17n-flt \
--without-png \
--without-rsvg \
--without-gsettings \
--without-sound \
--without-tiff \
--without-x \
--without-xaw3d \
--without-xft \
--without-xml2 \
--without-xpm \
--without-zlib \
--with-file-notification=no \
--disable-acl \
--enable-checking='glyphs' \
--without-compress-install


texts: Don't display module name in which-function-mode

texts:
When using which-function-mode, emacs displays not only the current function name but also the name of the module I am in. Is there a way to have which-function-mode display only the immediate function name, without the module name?

For example, instead of seeing this:

MyApp::Controller::some_function

I would like to only see:

some_function


texts: How to export top-level headings of org-mode buffer to separate files?

texts:
How can each top-level heading of an org-mode buffer be exported to a separate file named after the value of the corresponding CUSTOM_ID + (sanitized) title?

Let's say a buffer contains:

* Title of Heading 1
  :PROPERTIES:
  :CUSTOM_ID: fibrillogenesis
  :END:
  Suspendisse potenti. Mauris ac felis vel velit tristique imperdiet.

** Sub-Heading
   Nullam rutrum.

* Another Title for Heading 2
  :PROPERTIES:
  :CUSTOM_ID: mitochondrion
  :END:
  Mauris mollis tincidunt felis.  Sed bibendum.

The final result would be a directory containing two files, one for each of the two top-level headings, with the format chosen at export time (HTML, LaTeX, etc.), with the following file names and content:

Filename of first exported heading: fibrillogenesis-title-of-heading-1.[ext]

Exported content, corresponding to the original first top-level heading:

* Title of Heading 1
  :PROPERTIES:
  :CUSTOM_ID: fibrillogenesis
  :END:
  Suspendisse potenti. Mauris ac felis vel velit tristique imperdiet.

** Sub-Heading
   Nullam rutrum.

Filename of second exported heading: mitochondrion-another-title-for-heading-2.[ext]

Exported content, corresponding to the original second top-level heading:

* Another Title for Heading 2
:PROPERTIES:
:CUSTOM_ID: mitochondrion
:END:
Mauris mollis tincidunt felis.  Sed bibendum.

I would be very grateful for any hint, direction, pseudocode, or (better) real code.


texts: end of file during parsing during org-mode export to latex

texts:
I have a weird thing going on with emacs on Fedora 29.

Once in a blue moon, my Emacs will go HA! you cannot export to LaTeX with the "error": end of file during parsing during. However, if I move the file to my Mac with macOS Mojave with the same version of Emacs (26.1) and org-mode, and try to export the file, I do not get the error. Any ideas what can cause this issue and how to solve it?

The packages I have installed:

auctex
flycheck
flyspell-corect
flyspell-popup
json-mode
powerline
magit
rust-mode


texts: Export org-mode code blocks with minted style

texts:
I am trying to export org-mode source blocks to pdf via Latex and I use minted to get syntax highlighting. My org file looks like this:

#+latex_header: \usepackage[utf8]{inputenc} %% For unicode chars

#+latex_header: \usepackage{minted}
#+latex_header: \usepackage{xcolor}
#+latex_header: \usemintedstyle{monokai}    %% sets default for all source-code blocks
#+latex_header: \definecolor{dark}{HTML}{272822}   %% custom colour for background

#+attr_latex: :options bgcolor=dark
#+BEGIN_SRC bash -i
    rosrun rosbag topic_renamer.py <in topic> <in bag> <out topic> <out bag>
#+END_SRC

I read on this latex thread, that I have to manually specify the background colour, which is why I use that additional #+attr_latex: specifying bgcolor. That definitely does seem to help, but I cannot get the bash language to be correctly coloured. I get black text on the manually applied dark background:

So it seems the colour of the text is somehow affected by the bgcolor I manually apply to the source-block.

If I change the language, e.g. to c, I get something more like what I expect (which also happens to look pretty cool!):

#+attr_latex: :options bgcolor=dark
#+BEGIN_SRC c -i
    rosrun rosbag topic_renamer.py <in topic> <in bag> <out topic> <out bag>
#+END_SRC

trying to set the style manually for the source-block also doesn't seem to help. Using this:

#+attr_latex: :options style=monokai, bgcolor=dark
#+BEGIN_SRC bash -i
    rosrun rosbag topic_renamer.py <in topic> <in bag> <out topic> <out bag>
#+END_SRC

makes no difference, and I get the same as above, without the style option:

I can see in the generated tex files that options are being passed correctly to the minted block:

\begin{minted}[breaklines=true,breakanywhere=true,bgcolor=dark]{shell}
    rosrun rosbag topic_renamer.py <in topic> <in bag> <out topic> <out bag>
\end{minted}

I have the following setup in my init file:

(setq org-latex-listings 'minted
    org-latex-packages-alist '(("newfloat" "minted"))
    org-latex-pdf-process
    '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
      "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))

which was taken from here.

I have tried looking in the list of language names to language modes (a mapping) that org-mode maintains, and see that bash was there, I also added (shell shell) so the name "shell" is mapped the shell-mode.
Otherwise I don't really know where to start

EDIT:

Output when editing the .tex file and compiling in terminal:

\begin{minted}[style=monokai,bgcolor=dark]{bash}
  #!/usr/bin/bash
  for (( i=0; i != 10; i=i+1)); do
  echo $i
  done
\end{minted}

some text remains dark and un-readable


texts: I've been running into a problem with Helm recently with ispell. If I run ispell-change-dictionary first to set the dictionary, I can't figure out how to run ispell afterward through helm-M-x. The problem is that ispell-change-dictionary shows up in the Emacs Commands History section, and I can't figure out how to get down to the Emacs Commands list below that. C-n just moves within the commands history and never moves down.


texts: Org-mode header properties from .authinfo.gpg?

texts:
I was just looking at This literate SQL / org-mode example and see that org-mode supports username and password fields in a SQL source code block. As illustrated there:

** MySQL Analysis
  :PROPERTIES:
  :engine:   mysql
  :dbhost:   localhost
  :database: <redacted>
  :dbuser:   <redacted>
  :dbpassword: <redacted>
  :cmdline:  --protocol=tcp
  :exports:  both
  :END:

As fun as storing credentials in plain text is, I'm hoping someone can suggest a straightforward path to pulling those critical bits from a gpg-encrypted .authinfo.gpg file.

What's the best way of pulling those properties from .authinfo.gpg, emacs gurus?


texts:
This is migrated from the LaTeX stack exchange. I am using Emacs on the Mavericks OSX Terminal. I can open the TeX file fine, but I can compile a pdf via C-c C-c. Is there some way that I can open the pdf in an external window via the command line? I tried running C-c C-c and then C-c C-c again, but it said that was undefined. I have also looked here:

https://tex.stackexchange.com/questions/11613/launching-an-external-pdf-viewer-from-emacs-auctex-on-a-mac-osx-fails

But that didn't work either. I would really like to be able to run LaTeX in Emacs from the command line, but I do a lot of live TeXing and I need to continuously check the pdf. Can someone help me fix this problem?


texts: How can I access certain field information of a BBDB3 record?

texts: I'd like to write a command so that for a particular record (found for example with (bbdb-search (bbdb-records) regexp)) I'm able to extract just the name part of it (or e. g. the mail part, or any part of the xfields). How would you lisp this?


texts: Is there a mode to automatically update copyright years in files?

texts:
Usually around this time of year people start to realize that their copyright year is out of date in their files. This is particularly annoying if you like to put the copyright in every source file. I was wondering if emacs could help here.

Is there a mode that would automatically update the copyright year in a file? Ideally, I would setup the mode with my name and affiliations, so that it only updates the copyright for those. It would also only update the copyright automatically when a change is made (although it would be nice to also have an easy way to do a bulk change to a project).


texts: Org Latex Preview: Generates SVG But Doesn't Display

texts:
I'm running Emacs v25.1 + Orgmode v9.0.9 on a Mac.

Based on this stack, I changed my org-latex-create-formula-image-program to dvisvgm by adding the following to my init.el:

(setq org-latex-create-formula-image-program 'dvisvgm)

I am trying to use C-c C-x C-l to preview some equations:

Problem: The images seem to be properly generated (they appear in the folder ltximg) ...

but they are not displayed ...

Question: What is going on? Previewing the equations worked fine with dvipng (albeit at a lower resolution, that's why I'm trying to use dvisvgm), but with dvisvgm they are not being displayed and I don't get any errors. How can I fix it?

Thanks for helping!


texts: Using (dolist) to set multiple keybindings

texts:
I have a list with the pattern (list (cons key-binding1 file-name1) (cons key-binding2 file-name2)...)

(setq hot-list
      (list
       (cons "H-g" "~/Documents/goals")
       (cons "H-h" "~/Documents/things")
       (cons "H-1" "~/Files/C/abc.c")
       (cons "H-2" "~/Files/C/abc2.c")
       (cons "H-3" "~/Files/C/abc3.c")
       (cons "H-e" "~/.emacs") ))

Now I want to bind each key-binding to the respective file. But I don't want to do write a (global-set-key) form for each file. Instead I use (dolist) :

(dolist (i hot-list)
  (global-set-key (kbd (car i))
          (list `lambda (list i)
            `(interactive)
            `(find-file (cdr ,i)))))

When I try "H-1", it gives an error: " Invalid function: (lambda (("H-1" . "~/Files/C/abc.c")) (interactive) (find-file (cdr ("H-1" . "~/Files/C/abc.c")))) "

Although I don't find anything wrong with my code. (global-set-key) accept a command. And the test: (commandp (lambda (("H-1" . "~/Files/C/abc.c")) (interactive) (find-file (cdr ("H-1" . "~/Files/C/abc.c"))))) returns t

How should I do this?


texts:
Is there any way to bind a command to a key combination like AltGr-f?

The reason I ask is the following:  I use the “US international” keyboard layout (on Linux), which remaps the right Alt key to AltGr (aka Level3 shift), so that I can type certain accented characters I need. But this keyboard layout also has the nice side-effect of making some new (and very convenient) key combinations available; for instance, AltGr-t inserts þ, which I never use, so I can rebind it to something else.  The problem is that AltGr-f inserts an f, and not some useless symbol, so I can't bind that key to a command (similar issue with the characters g, h, b).  I know I could use xmodmap to assign some random symbol to AltGr-f, but is there a pure Emacs way to do that?


texts: I would like to export org file to ODT. Is there any nice ready to use ODT template that can be used for exported documents? Default template is not good looking. I had the same problem with html export where I was able to find some very nice themes.


texts: Why does `insert` not insert colorized text?

texts: For instance, why does (insert #("abc" 0 3 (face (:foreground "red")))) not insert red text?


texts:
To make it so that, i.e., \vdots is displayed as ⁞ one can:

(add-to-list 'org-entities-user
             '("vdots" "\\vdots{}" t "&x2999" "..." "..." "⁞")
              )

However, I get "invalid function" errors when I try to get i.e. \mathbb{R} to display as ℝ:

(add-to-list 'org-entities-user
             '("vdots" "\\vdots{}" t "&x2999" "..." "..." "⁞")
             ("mathcal{R}" "\\mathcal{R}" t "&x211D" "R" "R" "R")
              )

Question: Is there a way to add the mathbb alphabet to org-entities-user?


texts: Emacs 26.3: Weird frame title issue with KDE

texts: I recently switched to CentOS 7.7, KDE 4.x, and Emacs 26.3. Previously, I was using GNOME and a much older version of Emacs. Before, whenever I opened Emacs, the titlebar of a lone Emacs window was emacs@hostname. Now, it's emacs@hostname <@hostname>, which seems less than desirable. I can't figure out if the issue is with Emacs or KDE. Any ideas as to what is wrong here and what I can do to get it back to emacs@hostname?


texts: Remove extra blank lines before lists when exporting to html

texts:
When exporting org files to html, the orgmode exporter adds a <br> blank line before org-ul lists. I'd like to get rid of these extra blank lines (which are not visually "standard", in french documents at least).

I’ve tried to tweak the css (readtheorg.css here) with a negative margin-top for org-ul. Not only this solution is inelegant, but it fails where a list directly follows a headline (headline is then overlapped).

Any stronger workaround ? Within a org-export hook ? (beyond my skills)


texts: Emacs keeps overwriting files in Haskell mode

texts:
I'm using emacs:

GNU Emacs 26.3
Copyright (C) 2019 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

And I seem to be seeing a particularly strange problem: emacs, in haskell-mode keeps writing to the file repeatedly after each keystroke (also at times after a few keystrokes).
I've read online that some of the common tips to debug issues like these, and to identify the culprit mode, one must selectively disable modes one by one and see which one is causing this.

However, I was wondering if there was a better and less ad-hoc way for going about this: setting breakpoints.

I've tried to set debug points on save-buffer, write-file, and save-some-buffers, but this file-write operation doesn't seem to hit those breakpoints.

Are there more functions in elisp that deal with writing to files? If so, which ones?
And is my technique in trying to identify the culprit sound? Or is setting breakpoints not the ideal way of going about this?

Thanks.

Edit: similar issue.


texts: How to auto highlight buffer or region in web-mode?

texts:
I'm using web-mode 13.1.25, but was until today on 12.x with the same issue.

It seems I need to continually choose Highlight buffer (C-c C-h) as otherwise, certain functions misbehave.

These steps demonstrate the problem:

Adding
Foo into the body...

Foo

When beginning to type the closing tag

Foo</

3. It completes to the wrong tag.

Foo

If, however, I type
Foo, then type C-C C-h to update highlighting, then when typing the closing tag it auto-completes correctly.

Is it possible to have the current region or the entire buffer's syntax highlighting auto-updated when entering text or a tag?

Is there some setting I'm missing? Is there a recommended workflow?

Thanks!


texts: Sharing helm-buffers-list between multiple windows

texts: I use two separate windows in emacs, and when I use helm-buffers-list, it displays a list of files sorted with the most recently visited files near the top, however, this list is sorted differently for each window.  I'd like this list to be sorted the same way between all windows, rather than have a per-window sorted buffer list. Can anyone tell me how I can modify this behaviour?


texts: How to create a patch (git diff) with a specific name

texts:
I would like to create a patch (git diff) with custom name -- e.g., hello-world.diff.  Emacs doesn't seem to be able to handle git diff > hello-world.diff, perhaps because of the greater-than sign that works in regular terminals.

I have tried using start-process, but it fails:

(defun create-diff-patch ()
  (interactive)
    (let ((name-of-patch
           (read-string "Name of Patch:  " nil nil "patch.diff" nil)))
      (start-process "process-name" "*output-buffer*"
                     "git" "diff" ">" name-of-patch)))

Here is the error message:

fatal: ambiguous argument '>': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

Process process-name exited abnormally with code 128

The following two examples create automatic names, but I'd like to use my own name instead:

(apply #'magit-call-git
       (magit-process-quote-arguments '("format-patch" "-1" "SHA1")))

(apply #'magit-call-git
       (magit-process-quote-arguments '("format-patch" "HEAD~~")))


texts:
I'm using spacemacs for the convenience of largely not having to maintain my own emacs configuration, after 25 years of emacs use. For graphical frames and high-color unicode terminals, the fancy mode-line is fine.

However, I'm sometimes using a monochrome terminal, and the spacemacs mode-line is a lot worse on it than the traditional (emacs -Q) mode-line.

Is there a relatively simple way to toggle off the spacemacs mode-line for certain terminals?


texts: How to limit gnus article buffer to specific time period?

texts: When using Gnus, how can I display old messages from a certain time period in article buffer?


texts: I want to get the first line of the buffer I'm actually in. More generally, I'm looking for a utility that returns Nth line from a supplied buffer. Is there some built-in for that?


texts: Always show the last lines with a lower indentation than the first line that's visible in a window

texts:
I often find myself scrolling up in a code file to see which context I am in (class/method definition, yaml-key, etc). It would be super handy if I could somehow "freeze" the last lines of each indentation level that's lower than the last currently visible line.

For example:

class X:
  def a():
    # ...

  def b():
    # ...
    def some_local_function():
      # lots of code
      # ---- this is last line visible in the buffer/window
      # more visible code

In this case I would like the window to look like this:

class X:
  def b():
    def some_local_function():
      # some demarcation to indicate the lines above are separate from those below
      # ---- this is last line visible in the window
      # more visible code

Is there already a way to do this? If not, how would I go about implementing it?


texts: org-agenda-ndays stopped working after package update

texts:
the org-mode-ndays setting stopped having any effect on my agenda view after updating all packages. I would like to get this working again. :)
When I open the agenda the Week-agenda is shown (should be day-agenda), if I change it to day-agenda
and then refresh I'm back in Week-agenda. This is really annoying but I have no idea how to investigate this issue. Any suggestions?

my setup

  (setq org-agenda-custom-commands
        '(("d" "Daily agenda and all TODOs"
           (
            (agenda ""
                    ((org-agenda-ndays 1)
                     (org-agenda-skip-function '(org-agenda-skip-entry-if 'nottodo 'any))))
            )
       )))

GNU Emacs 25.1.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.8) of 2016-10-20

Org mode version 9.0.4 (9.0.4-elpaplus @ /home/ibayer/.emacs.d/elpa/org-plus-contrib-20170124/)


texts: Omit ~ before the \ref command (with RefTeX+AUCTeX)

texts: The default behaviour of C-c ) is to insert \ref and prefix it with~. I don't need the tilde after \S (i.e. I need the output to look like \S\ref{label}, rather than \S~\ref{label}). Is there a short code to insert into .emacs without copy pasting the whole reftex-reference function and adding exceptions there?


texts:
In the org-mode manual says

  Unlike LATEX_HEADER, contents from LATEX_HEADER_EXTRA keywords will not be loaded when previewing LaTeX snippets

If I start Emacs using emacs -q, it loads org version 8.2.10 from the shared libraries and the following fragment works fine.

#+LATEX_HEADER_EXTRA: \newcommand{\test}{testing}
$\test$

The newcommand has no effect on the preview and when I use org-preview-latex-fragment I simply get a blank image. However, in org version 9.0.9, starting emacs with an empty config file and using org-toggle-latex-fragment, this fragment creates an image with the text "testing". It is using the command inside the preview (!).

Is it possible to use LATEX_HEADER_EXTRA on 9.0.9? I have tried byte-recompiling org and org-plus, and my Emacs is being loaded without any initial configuration but I have not been able to use it.


texts:
Emacs 26.1, Windows 10, package iedit

Suppose I want to delete text onMessage

I select this text by iedit-mode (C-;)

To remove selected text I press many times button Backspace

Nice. It's work.

But it slow. Is is possible to delete selected text faster?

Here result:

P.S. I found solution by kill-region

and after kill-region


texts: Speedbar and org-mode only shows subheadings, but not 3rd level+ subheadings?

texts:
I'm toying around with Org-mode and Speedbar/Sr-speedbar.

I like that it shows Task and subtasks. But it doesn't show anything lower, e.g:

* Task (shown)
** subtask (shown)
*** Sub-sub task (not shown)
**** sub sub sub task (not shown)

Is it possible for it to actually show full depth?


texts: Inconsistent point when inserting into a buffer that is visible in another frame

texts:
While working on a sort of "background processing" function, I noticed that my logs would print backwards if the buffer was in another frame. I cannot seem to figure out why it is happening.

I am not looking for a solution to make the log print correctly, I can just specify that during logging, to move to (point-max) and everything is fine.

My question is, why does the point seem to update while modifying a buffer in the current frame, but not when the buffer is visible in another frame?

It is hard to fully describe so I will include code:

Test Code

Copy the code and run it in *scratch* in these two different frame configurations

With one frame, showing both *scratch* and test-buffer
With two frames, one showing *scratch* and one showing *test-buffer*

(defvar test-buffer (get-buffer-create "test-buffer"))

(progn
  (with-current-buffer test-buffer (delete-region 1 (point-max)))
  (run-with-timer
   1 nil (lambda () (with-current-buffer test-buffer (insert "first\n"))))
  (run-with-timer
   2 nil (lambda () (with-current-buffer test-buffer (insert "second\n"))))
  (run-with-timer
   3 nil (lambda () (with-current-buffer test-buffer (insert "third\n")))))

You will see that at the end of the first test, test-buffer will contain

first
second
third

and after the second test, test-buffer will contain

third
second
first

What is causing this? Is this a documented feature or perhaps even a bug?

Here is a gif of me running the tests:


texts: Reload init.el without restart, with CEDET

texts:
CEDET prevents me from doing M-x load-file init.el with the error:

progn: CEDET Version 2.0 already loaded.

How do I modify my CEDET load line to load conditionally? The current line looks like:

(load-file "~/.emacs.d/cedet/cedet-devel-load.el")


texts: How to insert character or word N times in a buffer or file?

texts:
Just curious to know how to do this, since i already know in other languages (bash, etc).

I know how to insert a character in elisp, just not sure on how to do it when it's done nth time (in succession) in elisp.

Here an example:

Basically, inserting (in file or buffer) the character X, 10 times.

XXXXXXXXXX something like that.


texts: Can't start an emacsclient process with xbindkeys

texts:
I'm trying to launch the Emacs calculator with the XF86Calc key. I have

"emacsclient -c -e '(calc nil t)'" XF86Calc

in ~/.xbindkeysrc

I can launch it from "Run Action" in xbindkeys-config. But pressing XF86Calc doesn't do anything. How does one use xbindkeys to launch an emacsclient frame ?


texts: Open a file from the desktop in a single window (without home screen splitscreen)

texts:
When I open a file from the context menu by choosing "Open with Emacs", Emacs starts with a horizontal splitscreen. The first window shows the desired file and the other one the home screen.

Is it possible to change the behaviour of emacs so that only the file is opened without the home screen?


texts: How to define normal-mode keychords in evil mode

texts:
A vim user trying to make the leap to emacs here. A roadblock I'm facing right now is a small convenience-remapping. These remaps aren't important, but my difficulty in making them makes me worry I'm fundamentally misunderstanding something.

The maps as I have them now:

(evil-define-key 'normal evil-normal-state-map (kbd "<key-chord> C-w C-k") 'evil-window-up)
(evil-define-key 'normal evil-normal-state-map (kbd "<key-chord> C-w C-j") 'evil-window-down)

These are meant to make the usual vim window motion commands (C-w k, C-w j, etc.) a bit more forgiving on my often rather stupid fingers. Am I missing something fundamental, still, about this? Do I need to create my own minor mode / separate keymapping just for this tiny addition?

The symptom: Even with these mappings in my .emacs, I still can't switch between windows with C-w C-k and C-w C-j keychords. The minibuffer helpfully reports that those chords are unbound.


texts: Record Emacs interactive function invocations

texts:
I want to optimize my keybindings, in a way that the more a command invoked interactively, the more accessible will be a key-binding for it.

Is there a way to record all interactive function invocations (excluding insert would be nice) to a file?


texts: How to use the regexp for digits with an interactive search?

texts:
For example, I have the following content in the buffer:

123
1234
12345
123456
1234567

To match the 4 numbers, I need the regular expression of \d{4}.
I would like to do the same in Emacs, when I press C-s and type the regexp.

When I'm looking in the documentation of Emacs regexp, many various regexp, Emacs own regexp, applications in Emacs Lisp, and so on, it's intensively documented.

I just want to have interactive search, type the regexp \d{4} and find the match. How could I apply that? The documentation gave no directly answer on this.


texts: How do I show org links pointing to an entry?

texts:
I have org-capture templates setup (but the default Todo template works the same way) to create a link in the resultant file to the text that was selected when org-capture was invoked.  This allows me to go to my TODO item - that was created by org-capture - where the originally selected text is now a link to the position in the file from where org-capture was called.

My question is, how can I see - from the original file, line or header in org mode - all the links that are pointing to that particular place?

My use cases are, for instance:

I would like to navigate to notes I've made for a particular group of clock entries
I would like to see all the linked TODO's for a particular line of code


texts: Open in Org Mode attached files in external programs doesn't work

texts:
When I open an attached file in Org Mode with C-a o or its directory with C-a f it always opens in Emacs instead of the right external program or file browser.

[ What do I mean with "attached": I attach files to an outline with C-a c (or y or m or...).  ]

What can I do about that? Problem ist solved.

The Problem appeared in the combination of Ubuntu 17.10 and Emacs 25.2 (or whatever is shipped with Ubuntu 17.10, definitel > 25).

With Windows 10 / Emacs 25.3 and Ubuntu 16.04.3 / emacs 24 shortcuts do what they should do.


texts: Comparison of quoted symbols fails using equal

texts:
I'm trying to compare (quote foo) with 'foo using equal, but the equality is failing. Here is a trace of what is happening with my code. I don't understand why the comparison fails -- does it have something to do with the reader, or chained evaluation?

How can write the code to make the comparison succeed?  Thanks

(plist-get (gethash "key" table) 'type)
(quote ctkb)

(equal 'ctkb (quote ctkb))
t

(equal 'ctkb (plist-get (gethash "key" table) 'type))
nil


texts:
I'm a newbie in emacs configuration, I've just discovered the possibility to define my own keybindings to fit my needs. It is realy cool, but emacs has so many keybindings that some default keybindings often overlap mine.

For example, I would like to have proper keys window splitting and navigation, and I like do this with arrows.

This is what I may like :

;; Wind-split
(global-set-key (kbd "C-x <C-down>") 'split-window-below)
(global-set-key (kbd "C-x <C-left>") 'split-window-right)
(global-set-key (kbd "C-x <C-up>") 'find-file-other-window)
(global-set-key (kbd "C-x <C-right>") 'switch-to-buffer-other-window)
;; Wind-move
(global-set-key (kbd "C-c <left>") 'windmove-left)
(global-set-key (kbd "C-c <down>") 'windmove-down)
(global-set-key (kbd "C-c <up>") 'windmove-up)
(global-set-key (kbd "C-c <right>") 'windmove-right)
;; Wind-resize
(global-set-key (kbd "C-c <C-up>") 'enlarge-window)
(global-set-key (kbd "C-c <C-down>") 'shrink-window)
(global-set-key (kbd "C-c <C-right>") 'enlarge-window-horizontally)
(global-set-key (kbd "C-c <C-left>") 'shrink-window-horizontally)
(global-set-key (kbd "C-c =") 'balance-windows)
;; Wind-arranging
(global-set-key (kbd "C-c C-d") 'delete-window)
(global-set-key (kbd "C-c C-c C-d") 'kill-buffer-and-window)

You'll probably notice that I have used C-c a lot and it's normal that it's overlapped since C-c is traditionally used in modes, but C-x seems less accessible and I other characters are often used for other commands.

So what easy keybindings to use for these basic operations ?

How do you manage your keybindings ?


texts:
I would like my emacs to call

dropbox status

every 30 seconds and display whether Dropbox is up-to-date at the bottom of the buffer (where info such as the line-number and file name is).

How could I do this?

EDIT to add:

On my linux (with dropbox installed), the command line dropbox status returns the Dropbox status:

$ dropbox status
Up to date

Unfortunately it seems like this doesn't work on OSX (https://superuser.com/questions/678925/using-dropbox-from-the-command-line-on-osx).


texts: How can I evaluate a file-local eval pseudo-variable lexically?

texts:
I have a use-case with a directory-local eval variable where it's necessary (or at least, more convenient) that it's evaluated with lexical binding.
Specifically, the form to be evaluated looks something like this, which should be a MWE if foolib is replaced with an actual feature:
(cl-flet ((avoid-repetitive-code (arg)
            (format "%s-baz" arg)))
  (with-eval-after-load 'foo-lib
    (setq foo-option (avoid-repetitive-code foo-option)))
  (with-eval-after-load 'bar-lib
    (setq bar-option (avoid-repetitive-code bar-option))))

(Originally I had just set the variables, until I realised that the defining library wasn't always loaded before opening the file.)
cl-flet expands into code that binds the function to a variable --cl-avoid-repetitive-code-- and replaces calls with funcall forms.  As a result, with dynamic binding, if foolib is loaded later, the function binding will be gone, resulting in an error:

Symbol’s value as variable is void: --cl-avoid-repetitive-code--

On the other hand, if the form was evaluated with lexical binding, this problem would go away because with-eval-after-load wraps the body forms with lambda and the lambda expression would evaluate to a closure instead.
In this case, I can avoid the error by replacing the function calls with the code directly, but I'd rather not.  In general, though, with a more complicated local function, this might not be possible.
Is it possible to have file-local/directory-local eval variables evaluated with lexical binding?


texts: Calling `doc-view-goto-page` in other buffer

texts:
I'm trying to control paging of a PDF file in doc-view mode. Say we have the following snippet

(let ((origin-frame (window-frame)))
  (with-selected-frame (make-frame-command)
    (let ((pdf-buffer (find-file "./test.pdf")))
      (set-window-buffer (get-buffer-window) pdf-buffer)
      (select-frame-set-input-focus origin-frame)
      (with-current-buffer pdf-buffer
        (doc-view-goto-page 5)))))

we make a new frame the display the pdf buffer then go back to our origin frame and try to scroll the pdf buffer to page 5 in the origin buffer.

eval the snippet, we can see the pdf buffer is actually displaying the content page 5, while the mode line says P1/12 DocView.(Note that the first time you open the pdf it may take some time to convert the pdf and causes the snippet fail) Switch to the pdf buffer and press n which calls doc-view-next-page, we can see the buffer goes to page 2.

That is to say, the buffer is not really went to page 5 just now but its 'content display' did. Using doc-view-goto-page in the pdf buffer will not have this problem as the modeling says P5/12 DocView after evaluation.

How to fix this? Is with-current-buffer not the way to go here? Thanks in advance!


texts: Use magit to find out who wrote the line at point and when

texts:
Someone showed me how to do this with "ruby mine" but I don't use ruby mine so hoping emacs / magit can do this.

A file in a git repository is opened up in emacs. Point is at line 23, and you want to quickly find out some "extra info" about this line, such as, who authored this line of code, and when was it last touched upon by someone.


texts: Is init.el used for emacs, when emacs is viewed as an editor or as an interpreter of elisp?

texts:
If I am correct, emacs is both an editor and an interpreter (or compiler?) of the elisp language.

Is emacs init.el used for emacs as an editor or as an interpreter of elisp?

If we use Emacs as an editor, the its init.el can be seen as the configuration file for this software.
If we use Emacs with the --batch option, is it similar to what .bashrc is for bash as an interpreter of bash language? Does the init.el get loaded then?


texts: crypto-newbie: how to securely sign outgoing email with `smtpmail` (or simplest alternative)?

texts:
I'm running

$ cat /etc/debian_version
jessie/sid
$ uname -rv
3.11-2-amd64 #1 SMP Debian 3.11.8-1 (2013-11-13)
$ gcc --version | head -n 1
gcc (Debian 4.8.2-1) 4.8.2
$ emacs --version | head -n 1
GNU Emacs 24.3.1
$ gpg --version | head -n 1
gpg (GnuPG) 1.4.15

The current (minimal) extent of my crypto use is:

My local workstation's hard drives, and its backups, are encrypted.
I regularly use SSH with key authentication and keychain.
I send unencrypted email from Emacs using smtpmail, but I connect to my email service with TLS.

Unfortunately, someone I know recently had their email spoofed with non-trivial consequences, so I'm thinking I should start securely signing my outgoing email with a public key. So I've got some clueless/lazy/newbie questions:

What's the easiest way to sign my outgoing email? Particularly, can I do this (easily) with smtpmail or must I convert to one of the many more-capable Emacs email clients? Which I've been putting off for, oh, about 20 years now :-)
What must I {do, get, have} in order to generate keys with which to sign outgoing email?

Note again that I'm not yet ready to encrypt my outgoing mail (though I should probably be preparing to do that): for now I just want to securely sign it to {deter, reduce harm from} spoofing.

Pointers to docs are appreciated: I RTFM when I know what to read, but have been unable to find suitable-fine-looking doc with either DDG nor their main competitor.


texts:
Description

Anaconda Mode only complete module variables, get No Matches for
assigned variables on linux server accessed via ssh

Reproduction guide

Observed behaviour:
- Start Emacs

execute import pandas as pd
type pd. tab, it shows list of candidates
execute df = pd.DataFrame()
type df. tab, it says No Matches

Expected behaviour:
Show completion for df. tab

anaconda mode buffer shows no error. I also tried pip install
--upgrade jedi json-rpc service_factory. I am more than happy to
provide more info.

System Info

OS: gnu/linux
Emacs: 25.3.1
Spacemacs: 0.200.13
Spacemacs branch: master (rev. c7a103a77)
Graphic display: nil
Distribution: spacemacs
Editing style: vim
Completion: helm
Layers:
elisp
(helm auto-completion better-defaults emacs-lisp git markdown org sdefaults sdired sorg c-c++ python html yaml sql csv docker
  (latex :variables latex-enable-auto-fill t latex-enable-folding t)
  semantic spell-checking syntax-checking)

System configuration features: XPM JPEG TIFF GIF PNG SOUND NOTIFY LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS LUCID X11


texts: ?? in the modeline instead of the line number

texts:
I have seen posts on the topic of getting "??" in the modeline instead of the line number. However despite my best efforts I can't get rid of the problem.

I have put those settings in my config:

  (setq line-number-display-limit nil)
  (setq line-number-display-limit-width most-positive-fixnum)

I'm pretty sure they help, sometimes now it's OK. But at least half of the time it's not. It's funny, I made myself a test file and it's kind of randomly working or not...

I'm using spacemacs and put my config on github.

By the way, this is the relevant code in spacemacs if that helps...


texts: Open org-mode links to info in different window?

texts:
I was wondering if anyone knew of a way to open links to info pages (Emacs manual) from org-mode without changing the current buffer to that info page?

The reason I would like to do this is because I have a list of helpful Emacs info pages in an org file and would like to be able to follow these links without leaving that org file.

Even if I have an info buffer already open in another window, it will just open that buffer in my current window and then follow the link instead of just going to that link using the current info buffer and not changing my current buffer.

It would also be nice to be able to open an info page like a help screen using keybindings, but I would at least like to be able to do this for links.

I have tried playing with org-link-frame-setup but have not been able to get it to work. The following is my current value for that variable in my init file.

;; Attempt to open info files in new windows.
(setq org-link-frame-setup
      '((vm . vm-visit-folder-other-frame)
        (vm-imap . vm-visit-imap-folder-other-frame)
        (gnus . org-gnus-no-new-news)
        (file . find-file-other-window)
        (wl . wl-other-frame)))

I am using "GNU Emacs 26.1 (build 1, x86_64-w64-mingw32)
 of 2018-05-30"


texts: How to change mode of buffer created by with-help-window

texts:
I have a buffer with name *fsharp info* which I want to change (programmatically) the mode from help-mode to my custom mode.

I created a simple major mode fsharp-info-mode to highlight fsharp documentation using markdown's font-lock.

(define-derived-mode fsharp-info-mode help-mode "fsharp-info-mode"
  "major mode for fsharp info."
  (setq font-lock-defaults '(markdown-mode-font-lock-keywords)))

With no success, I tried to enable it to the buffer with name *fsharp info* using

(add-to-list 'auto-mode-alist '("\\*fsharp info\\*" . fsharp-info-mode))

Looking in fsharp-mode, I discovered that the use with-help-window to create *fsharp info*.  In the documentation, it says that help-mode is activate in the buffer (maybe that is why I can't change?)

EDIT:

I solved my problem temporarily advising fsharp-ac/show-info-window which is the function called by fsharp-mode to display the documentation.

(defadvice fsharp-ac/show-info-window (after fsharp-ac/show-info-window-after activate)
  (save-excursion
    (switch-to-buffer "*fsharp info*")
    (fsharp-info-mode)))


texts: drawing graph with math formula in org-mode

texts:
My goal is to:

Generate graph (with math symbols / equations) from org-mode source block.
Display result inside buffer

My best attempt was to use dot and graphviz:

But I'm unable to add math symbol or equation to the graph.
Which is, to the best of my knowledge, impossible with dot. - Please correct me if I'm mistaken.

Whole process inside Emacs looks like this:

Any suggestion is appreciated.


texts: How to make minor mode keybindings for C-c prefix?

texts:
I am trying to define a minor mode that makes 2 keybindings. This is code i am defining it with:

(define-minor-mode parinfer-mode
  "Uses Parinfer to Format lispy code"
  :lighter " parinfer"
  :keymap '(let ((map (make-sparse-keymap)))
             (define-key map (kbd "C-c t") 'parinfer-mode--toggle)
             (define-key map (kbd "C-c r") 'parinfer-mode--refresh)
             map)
  (if parinfer-mode
      (parinfer-mode--refresh)))

However, when i later eval parinfer-mode, those bindings remain undefined, and value of parinfer-mode-map is:

 (67 keymap
     (45 keymap
         (99 keymap
             (32 keymap
                 (114 . parinfer)
                 (116 . parinfer-mode--toggle))))))

What should i change to set keymap the way i want?

P.S. I am not interested in defining mode separately, but in understanding what goes wrong in using an approach described in documentation.


texts: Is it possible to start company completion without a prefix?

texts:
Autocompletion is particularly useful in writing CSS, to see the available options for a given property. Company provides company-minimum-prefix-length to control how many characters I have to type before it starts offering options.

However, I want completion without any characters, so I get this:

Currently, I can only get this by either:

Explicitly calling M-x company-complete
Setting (setq company-minimum-prefix-length 0), typing a single character and backspace, e.g. a DEL.

Is this possible? Ideally I'd be able to do it for both properties and their values.


texts: Sane settings to show context when doing search and replace in org-mode

texts:
If I run certain functions like isearch-forward (with C-s) in an org-mode buffer, all content become temporarily visible. When I end the search, headings automagically collapse the way they were before I searched. Nice.

But if I run something like query-replace (with M-%), trees stay collapsed. The point essentially hidden inside them. I am asked to confirm a change that I can't see. That's not good at all!

Surely functions like query-replace should behave more like isearch-forward does. I swear I found a simple solution to this at some point. (A variable with a smart setting, I thought?) But I seem to have lost track of it. Please help me.


texts: Adjusting indenting for lisp if statements

texts:
I am learning common lisp and am trying to follow the style guide suggested by lisp-lang.org. In this style guide is an if statement style that I think makes the code more readable:

(if (cond)
    (true-branch)
    (false-branch))

That is, the branches line up. I find this to be syntactically easier to read. Using lisp-mode with no extra goodies the default seems to be:

(if (cond)
    (true-branch)
  (false-branch))

For some strange reason. The false block is pushed back to line up with the f of the if statement. I find this a little jarring.

Is there a way to clean this up so I can have the default formatting conform the linked styleguide?


texts:
So I'm trying to figure out why the following produces unexpected output:

(setq var 1)
(pp var)
(princ var)

Put the cursor just after the closing ) in the expression (setq var 1) and then press C-xC-e to evaluate it.  I see the following in the echo area: 1 (#o1 #x1 ?\C-a).  I think this makes sense - it's just listing the number 1 several different ways.

I go on to evaluate (C-xC-e again) (pp var) and then see the following: 1"1"

Why do I see the 1 twice?

Why is it listed inside the double-quotes the second time

Likewise, when I go on to evaluate (C-xC-e) (princ var) and then see the following: 11 (#o1 #x1 ?\C-a)

Why is there an 11 at the start?  I'm guessing that it's printing the value 1 twice, right next to each other (instead of printing the number 11), but why is it printing 1 twice?


texts: How to copy into mintty xterm clipboard from terminal emacs

texts:
My host machine is Windows, but I'm working in Linux virtualbox machine over ssh from mintty in MSYS2 environment. As you may know, in mintty you copy via C-insert and paste via C-S-insert. When I ssh from mintty to my linux guest and open in it Emacs (emacs-nox) I can paste with default shortcut for mintty, it triggers Emacs function xterm-paste. My problem is that I can not find way to copy, there's no xterm-copy function at all. Also there's no X so I can not use xsel as I used before.

So my question is how to copy to mintty clipboard from terminal emacs, is there any way? I always had problems with all those clipboard possibilities and can not figure it out.


texts: How to copy org-table to postgresql database?

texts:
With sqlite one can easily populate a table in a database via a org-table like so:

[EDIT](using only one sqlite-scr-block with org-table variable parameter)[/EDIT]

#+NAME: A
| val1 | val2 |
|------+------|
|    2 |   16 |
|    4 |   25 |
|   10 |    2 |

#+begin_src sqlite :db */path/to/db* :var orgtable=A :colnames yes
drop table if exists A;
create table A(val1 int, val2 int);
.mode csv A
.import $orgtable A
select * from a;
#+end_src

#+RESULTS:
| val1 | val2 |
|------+------|
|    2 |   16 |
|    4 |   25 |
|   10 |    2 |

I want to do this with postgresql. I tried with some COPY commands, but did not find other concrete info, on how to do this with org-variables.

How can I populate a table in postgresql with the contents of an org-mode-table?

EDIT (after @Martín's answer and @NickD's comment):
I "merged" the answer and the comment.

1) Export table to tmp-file

#+begin_src emacs-lisp :var orgtable=A
(write-region (orgtbl-to-csv orgtable nil) nil "/tmp/test.csv")
#+end_src

2) Import to db via localcopy \copy in sql-src-block

#+name: my-query
#+header: :engine postgresql
#+header: :dbhost localhost
#+header: :dbuser USER
#+header: :dbpassword PW
#+header: :database org-db
#+begin_src sql
drop table if exists A;
create table A(val1 int, val2 int);
\copy A(val1,val2) FROM '/tmp/test.csv' DELIMITER ',';
#+end_src

This comes quite close…
But before I start to improve this, I'd love hints and answers how to do this with variable as input (w/o the detour with 2 src-blocks and a transfer tmp file).


texts: Text entered right-to-left in chunks using polymode

texts:
I use polymode when editing Rmarkdown files in Emacs 26.1 and have the following problem. I visit a new file, test.Rmd, and type the following at the top of the file (this creates a yaml chunk):

---         ;; self-insert-command * 3
RET         ;; markdown-enter-key
---         ;; self-insert-command * 3
C-a         ;; move-beginning-of-line
RET         ;; markdown-enter-key
C-p         ;; previous-line
123         ;; self-insert-command * 3
C-n         ;; next-line
C-e         ;; move-end-of-line
RET         ;; markdown-enter-key
123         ;; self-insert-command * 3
RET         ;; markdown-enter-key

The result is that the text inside the chunk displays and is entered right to left, which is backwards; outside the chunk it is entered left to right, as expected. This is what I see and this is also how the file is saved:

---
321
---
123

I first encountered this with Emacs 26.2 under Ubuntu 18.04, but I was able to reproduce it with a fresh install of Emacs 26.1 in Ubuntu 19.04. Here is the complete .emacs:

(require 'package)
(add-to-list 'package-archives
             '("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'package-archives
         '("melpa-stable" . "http://melpa-stable.milkbox.net/packages/") t)
(when (< emacs-major-version 24)
  ;; For important compatibility libraries like cl-lib
  (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)
(custom-set-variables
 '(package-selected-packages (quote (poly-R poly-markdown poly-noweb polymode))))

(autoload 'markdown-mode "markdown-mode"
  "Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(require 'poly-R)
(require 'poly-markdown)
(add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown+r-mode))
(add-to-list 'auto-mode-alist '("\\.Rnw" . poly-noweb+r-mode))
(add-to-list 'auto-mode-alist '("\\.md" . poly-markdown-mode))

And here are the contents of the  elpa directory:

archives
gnupg
markdown-mode-2.3
poly-markdown-0.1.5
polymode-0.1.5
poly-noweb-0.1.5
poly-R-0.1.5

This also happens with the latest available versions of these packages and it also sometimes happens with R chunks.


texts: Suppress new buffer when running typeset command (C-c C-c) in AUCTeX

texts: When running C-c C-c to typeset/compile the LaTeX code in the current buffer, a second buffer pops up to show the compilation -- is there a way to suppress this buffer if there are no errors?


texts: Eshell will enter "Text is read only" and freeze

texts:
Basically I try to enable showing git branch I'm in in eshell buffer. The elisp I got works fine. But I will constantly run into "Text is read only " and have to kill the eshell buffer to start over.

;; eshell promopt
(defun my-current-git-branch ()
  (let ((branch (car (loop for match in (split-string (shell-command-to-string "git branch") "\n")
                           when (string-match "^\*" match)
                           collect match))))
    (if (not (eq branch nil))
        (concat ":" (substring branch 2))
      "")))

(defun my-eshell-prompt ()
  (concat (propertize (abbreviate-file-name (eshell/pwd)) 'face 'eshell-prompt)
          (propertize (my-current-git-branch) 'face 'font-lock-function-name-face)
          (propertize " λ " 'face 'font-lock-constant-face)))

;; em-prompt
(setq eshell-prompt-function 'my-eshell-prompt)

I am using Arch Linux and Emacs25. Does anyone have any idea to solve or a better approach?


texts: Avoid extra tabs when generating Haskell code with ghc-mod

texts:
I'm following the Haskell Emacs Tutorial here and Emacs is annoying me with the way it adds some extra TAB characters. E.g.

When I have this code:

data ExampleType = ExampleType Int Int

instance Eq ExampleType where

If I position myself in instance and execute C-u M-t, it generates

instance Eq ExampleType where
  x == y = _body
           x /= y = _body

Instead of:

instance Eq ExampleType where
  x == y = _body
  x /= y = _body

Anyone knows why the 2nd line is added with an extra TAB? How do you avoid Emacs doing this?

Cheers,
Galder


texts: Workgroups doesn't load the files from last session on startup

texts:
I needed emacs to startup and show me all the files I worked on last time (whom I didn't close explicitly) before M-x kill-emacs. I installed Workgroups for it and my prefix is C-c w. I split the window, ran a few files and I saved a workgroup. After restarting, it showed me all the files I closed last time (first usage).
After I worked on some other files, I closed emacs. But the next time I tried to start it, it shows me the files from the first session. My last session wasn't saved and instead my first session files are being shown.

I want to automatically load the files I ran the last time before closing to be arranged just the way it was.
How do I fix this?


texts: Using org-image-actual-width will both downscale and upscale. I just want to downscale big images to fit the current width. Any ideas?


texts: Why does the behavior of magit's pull operations differ?

texts:
The story here is that I use magit at work, where our workflow involves the use of a preposterous number of branches on our central remote (used for various purposes, but most notably as part of our deploy and manual testing processes). For my local development purposes, I have no need to stay up-to-date on most of these extraneous references. Before adopting magit, when using git porcelain I'd generally use specific pull and fetch commands, both to save time and to leave my repo un-cluttered. Whenever I wanted to update master, for instance, I'd usually use

git checkout master
git pull origin master
git checkout -

When I adopted magit, I was initially puzzled by how long pulling (using  magit-pull-from-upstream) would take. As time went on I eventually discovered (using the magit-process buffer) that magit was using the command git pull origin to update my master branch. That command, in addition to updating master, fetches every remote branch under the sun (which is  lot of pointless references I don't need, remember).

I've solved this issue for myself (i.e. I'm not looking for a solution here) by switching to using magit-pull-from-pushremote instead, after configuring the push-to remote. That, evidently, uses git pull origin master (as I expected I'd get from the other command).

I'm looking for an explanation for the different behavior of these two commands. Why would one yield git pull origin and one yield git pull origin master? Why wouldn't both do the (in my opinion objectively more useful) git pull origin master?


texts: Some UTF-8 characters break my ansi-term. How to fix it?

texts:
I've got a script that generates some output. Some parts of the output are cyrillic letters, and they cause my ansi-term to break - I guess they are treated as control characters(they are displayed like \320\272, and this makes me restart the ansi-term hoping it won't happen again(that I skip this part of output). However, this isn't a fix, but a hack.

How can I make these characters appear correctly/not break my con


texts: org-publish, how to wrap content before first headline in a div

texts:
If I have the following org file:
#+TITLE: Foo & Bar

This is all about foo and bar.

* Foo

...

* Bar

...

when I org-publish to html, I'll get something like the following in the content section:
...

Foo & Bar

This is all about foo and bar.

Foo

...

Foo

...

...

I'd like

Foo & Bar

This is all about foo and bar.

i.e. the page title and all content before the first org headline, to also be wrapped in their own div (or similar containing element) within the main div, so that I can target this container specifically with css.
In summary, I would like the following output:
...

Foo & Bar

This is all about foo and bar.

Foo

...

Foo

...

...

How would I go about that?


texts:
the image is self explanatory, I recently switched to doom emacs and I'm still learning.
How can I fix this problem? I tried to switch off anything related to checkers in the init.el file but it doesn't help.
The problem is that rainbow-delimiters is recognizing (0,1] as a "not matching parenthesis" in latex environment, so it is highlighting everything from that point on. Now I really tried to disable the whole package in doom-emacs but I failed. It can easily toggled off with M-x rainbow-delimiters , but I want it disabled by default


texts: How do I toggle Magit enumerating untracked files?

texts:
git status in my configuration is extremely slow at enumerating untracked files, for reasons not relevant here. I'd like to have Magit use the -uno argument in most cases, in order to avoid a long delay every time I refresh the buffer, but also have the option of doing a full status (including untracked files) at will.

I'm not seeing a way to make this happen without modifying or advising Magit's code and mode map; there doesn't seem either to be an "ignore untracked files" option, or an option to add arbitrary command arguments to the git status invocation. Have I missed something, or do I have some hacking to do?


texts: Do not open dired for directories when using counsel-find-file

texts: I've recently started using spacemacs with ivy, and what drives me nuts is that I instinctively press RET when a directory is selected to descend into it, which opens dired instead. Is there a way to prevent counsel from doing that and only have RET work on files and not directories?


texts:
I tried running (forward-comment -1) by eval command, when the point is actually in the middle of a comment. Like forward-word (or) forward-line, i expected it move to the beginning of the comment & then to the previous comment etc...

But, the point is not moving at all..

Like, my javascript snippet looks like,

    /*  this is a dummy comment
   this is additional(^) comment
this is more additional  comment*/

My cursor is on the second line denoted by caret symbol and then i run, (forward-comment -1) and i expect the point to move to the comment's beginning. But (point) has not changed at all.

Note: This behavior is noticed in elisp mode as well with semicolon-ed comments.


texts: Is it possible to org-bable-tangle an org file from the command line?

texts: I would like to manage the tangling my org files with a Makefile. Though I can not find any information of how to tangle files from the command line.


texts: The elisp function to run the shell command in specific file path

texts: Personally I need run many shell command in emacs, I find it is not convenient to run a shell engine (eshell) or using it separately (bash), so is there a elisp function (local provide by emacs or any other third-part library) meet my need?


texts: Deleting a file with name that already exists in Trash

texts:
I use delete-by-moving-to-trash to move deleted files and folders into trash instead of deleting them. However, if the file or folder with the same name is already in Trash I get an error file already exists".
On macOS and while I delete file using Finder which name already exists in the Trash it adds current timestamp to the deleted file name to differentiate it. For example foo become foo 20.28.19.
Is there a way achieve the same in Emacs?
That would solve the problem, but I'm also open for other solutions if they exists.


texts: kill the current line and preserving cursor position

texts:
I'm using the slick-cut function (as answered here by itsjeyd) for killing the entire line with minimal keystrokes. It's defined like so :-

(defun slick-cut (beg end)
  (interactive
   (if mark-active
       (list (region-beginning) (region-end))
     (list (line-beginning-position) (line-beginning-position 2)))))

(advice-add 'kill-region :before #'slick-cut)

But, I noticed this behaviour, whenever I kill a line, the cursor will be positioned to the beginning of the next line.

Before killing line 28 :-

After killing line 28 :-

Is there a way one can modify the slick-cut function so that, after killing a line, the cursor column position is also preserved. Like so :-

If unable to preserve cursor position, is it possible to at least move the cursor position to the indentation level ?


texts:
For some reason, some garbage is prepended to my PATH variable in emacs.

Testing from eshell: (M+x eshell):

~/projects/rust/logentries-parser/src $ echo $PATH
bash: cannot set terminal process group (-1): Inappropriate ioctl for devicebash: no job control in this shell:/home/renat/.cargo/bin:/home/renat/lib/google-cloud-sdk/bin: ... other stuff

Testing from shell: (M+x shell):

renat@hp-envy ~/projects/rust/logentries-parser/src $ echo $PATH
:/home/renat/.cargo/bin:/home/renat/lib/google-cloud-sdk/bin: ... other stuff

Testing using the getenv: (getenv RET PATH):

bash: cannot set terminal process group (-1): Inappropriate ioctl for devicebash: no job control in this shell:/home/renat/.cargo/bin:/home/renat/lib/google-cloud-sdk/bin: ... other stuff

Did anybody encounter anything similar?

Thanks

A new update:

When I'm starting emacs with a -nw switch - it works fine and PATH is not polluted.


texts: What is causing this error: "Cannot open load file, no such file or directory, session"?

texts:
From time to time my Emacs doesn't load my init file at startup and gives me the following error message:

File error: Cannot open load file, no such file or directory, session

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the `--debug-init' option to view a complete error backtrace.
File error: Cannot open load file, no such file or directory, session

The Problem turns out to be this code in my customization file:

(custom-set-variables
 ....
 '(session-use-package t nil (session))

It is a variable from the session package which saves my history in Emacs.
I have to delete this line and everything works again. Why is this added to my customization file and how can I avoid this annoying error? How could I investigate myself which event triggers this setting in my customization file?

Edit:
The part of my init which loads the package looks like this:

(use-package session
:ensure t
:init
(add-hook 'after-init-hook 'session-initialize))


texts: Org-mode export: indent first line of each paragraph, "literary" style

texts:
Is there a switch on org-mode I can use on export to ODT (or other format) to format my source file of

  This is a paragraph this is a paragraph this is a paragraph this is a
  paragraph this is a paragraph this is a paragraph this is a paragraph
  this is a paragraph this is a paragraph.

  This is another paragraph this is another paragraph this is another
  paragraph this is another paragraph this is another paragraph this is
  another paragraph this is another paragraph this is another paragraph.

into:

     This is a paragraph this is a paragraph this is a paragraph this is a
paragraph this is a paragraph this is a paragraph this is a paragraph
this is a paragraph this is a paragraph.
     This is another paragraph this is another paragraph this is another
paragraph this is another paragraph this is another paragraph this is
another paragraph this is another paragraph this is another paragraph.


texts: Speedbar opens a normal text buffer, not dired like

texts:
I'm trying to use Speed bar when coding C++. My problem is, when I type M-x speedbar it opens an already opened code file instead.

Here you can see the effect:


texts: How do you set the line height when customizing a font face? (e.g. an org-drawer)

texts:
I specifically want my :NOTES: org drawer (and :end:) to be a smaller font size (say 0.5 relative to normal text). Ideally the drawer contents also (say 0.8).

However, when I set the height property in customize, the line height stays the same, and there doesn't seem to be an option to change that. It's just smaller text, with the same size line! Is there any way to fix this? I know heading lines can be different font sizes, and there is nothing else on the line with the drawer.


texts: Trouble sorting customized priorities in org-mode

texts:
I'm trying to setup priorities other than A, B, C.  (I want to do U, I, O; short for Urgent, Important, Other).  Previously, I had set up custom agenda commands that sorted priority-down.

I configured my priorities like this:

(setq org-highest-priority ?U)
(setq org-default-priority ?I)
(setq org-lowest-priority ?O)

Then when I viewed my agendas I noticed that rather than sorting in priority order, it seems to be using alphabetical order.

What am I doing wrong here?


texts:
I'm not sure how to describe this. In vimdiff I remember that if one of the buffers had added a line, the other buffer showed lines at that same vertical location to show where they were added. I found a picture that shows what I mean:

On the other hand, in ediff the space is not taken up on the left buffer, instead there's a single character highlighted in that buffer as shown below.

Above picture is cropped from this.

Perhaps I'll get used to this way of showing things, but in any case I'm curious if it's possible to configure ediff to show things like vimdiff does.

EDIT: To anyone who's interested, it seems there's a package that emulates this now: https://github.com/justbur/emacs-vdiff


texts: Keeping track of a pdf viewer spawned via AUCTeX?

texts:
When using AUCTeX with pdflatex, one can run C-c C-c (TeX-command-master) or C-c C-v (TeX-view) to spawn a PDF viewer.

I use Evince on Debian Wheezy, in case it's relevant.

This might sound a little absurd, but I find it easy to lose track of where the Evince viewer attached to that particular buffer is. Sometimes it can be buried under other windows or mostly off the screen. I run other instances of Evince too. If it makes any difference, I've got Synctex at least partly working.

So, is there some way of telling emacs/AUCTeX to "find" my Evince viewer, or failing that, is there some convenient way to tell emacs/AUCTeX to kill the viewer and start a new one?


texts: Can I make paredit work with only braces {…} instead of other parens?

texts:
I'm trying to create paredit functionality for TeX modes and I'd really like to avoid actually rewriting paredit.el.  (I've spent a good portion of the day doing this with no significant progress.)

I had figured paredit would simply look at the syntax table for its open/close paren bits, but this appears to not be the case.  Is there a way to alter paredit variables to get the result I need, or is there perhaps another, more minimalistic minor mode I can use?


texts: How to open a file with tramp mode when Helm is active?

texts:
I recently started using Helm with the configuration below

(require 'helm-config)
(helm-mode 1)
(define-key global-map [remap occur] 'helm-occur)
(define-key global-map [remap list-buffers] 'helm-buffers-list)
(define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
(global-set-key (kbd "M-x") 'helm-M-x)
(setq helm-M-x-fuzzy-match t)

Today I figured out that Tramp mode doesn't work anymore. When I try to open a file with C-x C-f and enter /sudo:root@TAB nothing happens. Usually I'd expect that localhost is substituted and tramp asks for a password.

How can I have a still functional tramp mode plus a working Helm?


texts: Why does my latex src code block ignore exports header arguments

texts:
GNU Emacs 25.1.50.2

Org-mode version 8.3.5

At some point in the past I could put down a block like this

#+begin_src latex :exports results :results {latex|html}
\begin{equation}
a = 1 + b
\end{eqation}
#+end_src

For either html or latex and make it export to the corresponding format.
This functionality have for some reason disappeared and now it exports the src block as a code block instead of the results that exports to nice native latex or html math and rendered that way.

I find it convenient to be able to do this, for a number of reasons, so it would be nice if there was a way to make this work again.


texts: Prevent electric-indent-mode from reindenting the current line on RET

texts:
I am using the Spacemacs configuration files.

When I am typing code, electric-indent-mode reindents the current line whenever I press enter. This often causes the indentation to be incorrect when working in languages like Python or Haskell.

Here is an example of the problem

How can I prevent this re-indentation?


texts: Make Helm Projectile to show external sources

texts:
I'm pretty new to emacs (was using Vim), primarily using it for Ruby on Rails projects.

At my free time, I like to write some C code for STM32 micro-controllers.

Unlike RoR project, C project for STM32 contains a lot of external dependencies (includes) outside of project's folder, and there is as good reference documentation, so I have to read source codes a lot.

So, I would like to do C-c p h and find any random file including external dependencies.

I understand, that this task is more complex, than just writing t some variable, but I can't even realize, where can I start the research.

Another problem, that I don't want to hardcode dependencies list into my ~/.emacs.d, it should be project-specific settings.


texts: ANSI colors are incorrectly displayed in Inferior Python mode REPL

texts:
ANSI escape color codes, e.g. "\u001b[31m", are incorrectly printed in the Python REPL, inferior python mode. They are correctly printed in VTerm, where they are displayed the same as when printed in the terminal of my operating system.
I have tried changing ansi-color-names-vector, but whatever changes I make to it, it makes no difference.
I have tried changing the emacs theme, but it makes no difference.
To the left: ANSI colors correctly displayed in vterm.
To the rigth: ANSI colors incorrectly displayed, or missing, in Inferior Python mode.

I suppose that 256-bit color support might a different issue than the colors being displayed incorrectly. Just correcting the colors would help a lot, though 256-bit support would be nice too.


texts:
So, I'm trying out spaceline, I have a few problems I can't figure out.

My segments does not display correctly, there is a weird display conflict that look like small boxes between each segment, is this a bug or can it be fixed?

I don't know what is the "Mod" next to "Git:master". How do I get rid of this? I tried switching off most of the segments, does not seem to have any effect on the "Mod".
I want to force spaceline to always show buffer-position and hud. When I navigate blocks of text, I'll sometimes see the hud and buffer-position, but mostly I see "ALL" or "END".
Is there a way to change the highlight color in the modeline from orange to custom color?

Regards.

Update 01:

The "MOD" at the end of "Git:master" is controlled by the version-control variable, I think it indicates a modification on current branch.

Is there no way to turn that off?


texts:
I have the following Emacs org buffer that I'm editing:

#+BEGIN_SRC R
regimes <- read.spreadsheet(wlda, 3) %>%
    within({
        TurbineID <- paste(Site, Turbine)
        Date.of.Change.of.Risk.Level <- convert.excel.date(Date.of.Change.of.Risk.Level)
        Non.REA <- Non.REA=="Yes"  # Convert to boolean & foo
        X9 <- X10 <- NULL # Trailing columns
    }) %>%
    group_by(Site, Turbine) %>%
    mutate(
        Curtailment.Level.Before = na.locf(Curtailment.Level.Before),
        Curtailment.Level.After  = na.locf(Curtailment.Level.After, fromLast=TRUE)
    )
#+END_SRC

Syntax highlighting (font-lock-mode) is enabled in this buffer.

I hit Meta-x R to start a new R session.

If I then go back to the Org buffer, highlight all the code in the code block, hit Meta-w to grab it, and then move to the R session buffer and yank it (Ctrl-y, which runs ess-yank), Emacs immediately freezes and consumes 100% CPU.  None of Ctrl-g, Ctrl-c, or anything else I've tried will interrupt it, I have to actually kill the Emacs process from a shell.

Note that I have not actually tried to execute the R code at this point, it's just been yanked (pasted) into the ESS console buffer.

Anyone help with some debugging here?

My setup:

Emacs 24.5.1, installed using homebrew
OS X 10.10.5
Org-mode 8.3.2, installed using org-plus-contrib 20151228 from ELPA
ESS 15.09-2, installed from ELPA 20151217.544

This behavior happens whether I'm using the OS X .app or running in a terminal.

Update

I think this has something to do with syntax highlighting.  If I run font-lock-mode to turn off highlighting in my org buffer before I grab the text, the problem disappears.  I simplified the example above to reflect this.

Update 2

I triggered this problem in the way described above, then I hit the process with a SIGUSR2 signal and got the following backtrace:

Debugger entered--beginning evaluation of function call form:
* (byte-code "r^Hq\210\302      !\210)\302\207" [buffer table set-syntax-table] 2)
  font-lock-default-fontify-region(802 1304 nil)
  inferior-ess-fontify-region(802 1304 nil)
  font-lock-fontify-region(802 1304)
  run-hook-with-args(font-lock-fontify-region 802 1304)
  #[0 "\302\303\300\242\301\242#\207" [(802) (1304) run-hook-with-args jit-lock-functions] 4 "\n\n(fn)"]()
  funcall(#[0 "\302\303\300\242\301\242#\207" [(802) (1304) run-hook-with-args jit-lock-functions] 4 "\n\n(fn)"])
  jit-lock-fontify-now(802 1302)
  jit-lock-function(802)
  redisplay_internal\ \(C\ function\)()

I notice that the docs of byte-code say "If the third argument is incorrect, Emacs may crash."  In this case, the third argument (MAXDEPTH) is passed as 2, perhaps that's the problem?


texts: Why does kill-region (C-w) only kill the region marked by the first cursor when using multiple cursors

texts:
Having selected five regions with five cursors using multiple-cursors-mode:

why is it that when I press C-w or M-x kill-region it is only done for the primary cursor?


texts:
The manual's introduction says:

  Magit wraps and in many cases improves upon at least the following Git porcelain commands: add, am, bisect, blame, branch, checkout, cherry, cherry-pick, clean, clone, commit, config, describe, diff, fetch, format-patch, init, log, merge, merge-tree, mv, notes, pull, rebase, reflog, remote, request-pull, reset, revert, rm, show, stash, submodule, and tag.

However, I can't quite figure out how to actually move a file from it. Sure I can just run git mv, but taking that to the logical extreme we might as well just use git instead of Magit :P Considering the manual mentions mv, I wonder if that's a mistake or not.

I only found this old question but it's very old by Magit standards. Perhaps things have changed?


texts: use-package and js2-mode: setting fill-column

texts:
I'm using use-package and I want my fill-column to be set to 100 for files edited with js2-mode.

I tried to do so in the :config part, like:

(use-package js2-mode
  :config
  (setq fill-column 100))

(among other configuration) but it didn't work, fill-column was still 70 after loading a JS file (which activated js2-mode).

The way I made it work was by setting fill-column inside a hook like:

(use-package js2-mode
  :preface
  (defun me/js2-hook ()
    (setq fill-column 100))
  :config
  (add-hook 'js2-mode-hook #'me/js2-hook))

So, my question is, what was wrong with setting fill-column straight into :config?  Why is the hook required?

Thanks!


texts:
I'm "new" with Emacs. I'm making my own set up but I can't do one thing with killing words. You know what M-DEL does by default, but I want to make like Sublime Text or VIM. I'll do an example (this is the original text):

Hi, I'm captainepoch
< first post here!

And this is how I do on vim or Sublime Text:

Hi, I'm captainepoch
< first post here▮

Do M-DEL

Hi, I'm captainepoch
< first post▮

Do M-DEL

Hi, I'm captainepoch
< first▮

Do M-DEL

Hi, I'm captainepoch
<▮

Do M-DEL

Hi, I'm captainepoch
▮

Here, there's nothing at the beginning of the line and doing M-DEL in vim makes the cursor go to the end of the previous line.

Hi, I'm captainepoch▮

Do M-DEL

Hi, I'm▮

Do M-DEL

Hi, I'▮

Do M-DEL

Hi, I▮

Do M-DEL

Hi,▮

Do M-DEL

Hi▮

This final M-DEL will end up deleting the whole text.

▮

A friend of mine did this function:

(defun backward-kill-word (arg)
  (interactive "p")
  (let ((init-pos (point))
        (line-begin (line-beginning-position)))
    (if (/= (point) line-begin)
        (kill-word (- arg)))))

And it does the job until it got the <, which does this:

Hi, I'm captainepoch
<▮

Do M-DEL

Hi, I'm▮


texts: .emacs complains about undefined functions/variables event after byte-compile

texts:
I use use-package and pulled in the treemacs package with the default settings. Then I byte-compiled my .emacsfile. But I still get a warning saying:

the following functions might not be defined at runtime: treemacs--find-python3, treemacs-follow-mode, treemacs-filewatch-mode, treemacs-fringe-indicator-mode, treemacs-git-mode

I also tried to add these modes in the :defines parameter in use-package, but has no effect.

How to get rid of these warnings properly?


texts: setf + alist-get but with "equal" instead of "eq"?

texts:
I got a suggestion to use setf to replace value in an alist: Replace element in a list / add in case of absence, with custom test/key functions
The example was provided, but it doesn't work if key is a string:
(let ((al (list (cons "a" 1) (cons "b" 2))))
  (setf (alist-get "c" al) 3)
  (setf (alist-get "c" al) 4)
  al)

;; evaluates to: (("c" . 4) ("c" . 3) ("a" . 1) ("b" . 2))

The keys of tramp-methods are strings. Is it possible to alter equality predicate of setf in a a declarative way (without tons of elisp)?


texts: How to perform an automatic commit with predefined message using Magit?

texts:
I have a repository of org files which I mostly use for note taking and tracking, and I track it using git. I want to add a shortcut that would quickly commit all current content of the repository (both changed, new and deleted files) as a new commit with a predefined commit message (say "update"). How can I achieve this programmatically with magit?

Thanks in advance!


texts: Folding headers containing source code blocks in an org file?

texts:
I always refer to org mode when I want to document anything, but what I am struggling with right now is how to make folding mechanism work when my headers contain source code blocks under a list element. Consider the MWE below:

* Main Subject
** Fonts
    *** \definefont
        - ~\definefont [TitleFont] [Serif sa 2.4]~
        - ~\definefont [TitleFont] [Serif]~ means ~\definefont [TitleFont] [Serif sa *]~ which in turn expands into the current actual font size, after the application of size corrections for super and subscripts
        - this creates a macro name for a font switch, =\TitleFont= in this example ~{\TitleFont anytext}~
    *** \definedfont
        - ~\definedfont [...]~ inherits from \definefont
    *** \definebodyfont
        - ~\definebodyfont [10pt] [rm] [tf=tir at 10pt]~ This single line actually defines two font switches =\tf= for use after a =\rm= command, and =\rmtf= for direct access
        - End
        - Example-1: of using different font sizes for Computer Modern Roman font
    #+BEGIN_SRC tex
    \definebodyfont [12pt] [rm]
    [tf=cmr12,
    tfa=cmr12 scaled \magstep1,
    tfb=cmr12 scaled \magstep2,
    tfc=cmr12 scaled \magstep3,
    tfd=cmr12 scaled \magstep4,
    bf=cmbx12,
    it=cmti12,
    sl=cmsl12,
    bi=cmbxti10 at 12pt,
    bs=cmbxsl10 at 12pt,
    sc=cmcsc10 at 12pt]
    #+END_SRC
        - Example-2: for Helvetica Type 1 font
    #+BEGIN_SRC tex
    \definebodyfont [12pt] [ss]
    [tf=hv sa 1.000,
    bf=hvb sa 1.000,
    it=hvo sa 1.000,
    sl=hvo sa 1.000,
    tfa=hv sa 1.200,
    tfb=hv sa 1.440,
    tfc=hv sa 1.728,
    tfd=hv sa 2.074,
    sc=hv sa 1.000]
    #+END_SRC

My struggle is to hide the visibility or folding of the header Example-1 and Example-2 in org. What is the best strategy in org-mode to document such code chunks? May be I am using it the wrong way. Please note I want to stick with the way org mode writes code blocks because of its ease and breeze, I just type <s and then TAB and this will extend nicely to a source block template. I would like to continue using this nice feature in org mode, yet with the folding mechanism inherent of Org-mode document structures also in place.

Note

Org mode version 9.1.13


texts:
When I call run-python, I get the buffer with python REPL and the prompt.

I can type stuff, but when I press enter there is no reaction (except the cursor moves in new line).
If I press C-c C-c (comint-interrupt-subjob), I get a new prompt, but I don't see any output of the previous commands.
If I use python-shell-send-region or if I evaluate (comint-send-string "Python" "print 5\n"), I don't see any output in Python buffer, but the elisp function returns without error.
I can end the python process by pressing C-d (comint-delchar-or-maybe-eof).

The same problem occurs both with python and ipython (I tried python-shell-switch-to-shell with both). The Emacs communication also doesn't work when trying to use Mozart programming system, which also uses comint. Some other comint based modes on the other hand (scheme, shell) work without problems.

If I run python inside emacs shell I get the same behavior as above. After C-d, the python ends and the shell works normally again.

I've also tried starting emacs without init files.

Versions:

Python 2.7.8
Emacs 24.3.1 (also saw the problem with 24.4.1)
built-in python.el
Debian Jessie


texts: migrated from emacs 25 to 26.1: cannot force find-file/counsel-projectile-find-file to always open buffer in current window

texts:
Recently I migrated from emacs 25 to 26.1. Before I reached the window behaviour, where I could always open a file at the window at point.

The most simple case to illustrate undesired behaviour: I have two split windows. I am calling find-file (or other alternatives) from the left one, while the new file opens in the right window.

Meanwhile, only ido-find-file works as desired (opens file at the window at point).

I tried find-file/counsel-projectile-find-file/helm-find-file and they all do not open the file in the current window.

I tried to change window-related variables introduced in emacs 26.1; so, relevant emacs config might be here:

(setq pop-up-windows nil
      switch-to-buffer-preserve-window-point nil
      switch-to-visible-buffer nil
      switch-to-buffer-in-dedicated-window t)

Have anybody tackled this issue?

UPDATE (2018-12-04):

In order to achieve the desired behaviour I used el-patch package with the following lines:

(el-patch-defun find-file (filename &optional wildcards)
  (interactive
   (find-file-read-args "Find file: "
                        (confirm-nonexistent-file-or-buffer)))
  (let ((value (find-file-noselect filename nil nil wildcards)))
    (if (listp value)
      (mapcar (el-patch-swap 'pop-to-buffer-same-window 'switch-to-buffer) (nreverse value))
      ((el-patch-swap pop-to-buffer-same-window switch-to-buffer) value))))


texts: How can I open magit-status in a new frame if such a frame does not already exist?

texts:
How can I open magit-status in a new frame? I've tried to write a custom function for this but it has some issues as described below.

  (spacemacs/set-leader-keys "gs"
    (lambda () (interactive)
      (when (not (string-prefix-p "magit:" (substring-no-properties (cdr (assoc 'name (frame-parameters))))))
        (select-frame (make-frame-command))
        )
      (magit-status)
      )
    )

I have the above code, however this opens 'multiple' frames if the above is executed multiple times. Is there a way I can prevent it from opening a new frame if an  existing magit frame already exists?

Is there possibly an alternative? Otherwise I'd imagine I'd need to get a list of all frames, search for the magit frame and select it.


texts: why is this trim-space function so complicated/ugly in emacs lisp?

texts:
I just spent at least 10m writing a trim-space function in Emacs lisp:

(defun trim-space (string)
  (let ((regex "\\`[ \n\t\r]*\\(\\(.\\|\n\\)*?\\)[ \n\t\r]*\\'"))
    (string-match regex string)
    (match-string 1 string)))

This is after several iterations. There are several gotchas that I ran into:

^ matches beginning of line, not beginning of string. Likewise for $. Documentation on this is not easy to find within Emacs.
. (dot) doesn't match newline
[:space:] class doesn't include newline????
I also don't like that I have to mess with match-data, giving this function side effects

Finally:

ELISP> (trim-space "   deb   ian-
mini")
"deb   ian-\nmini"
ELISP>

Meanwhile, using Python:

>>> import re;
>>> re.findall("(?s)^\\s*(.*?)\\s*$", "   deb   ian-\nmini  ")
['deb   ian-\nmini']
>>>

which is much simpler and clean and makes much more sense.

Why shouldn't Emacs lisp look more like Python here?

Note: I know about string-trim in Emacs 24. Emacs regular expression syntax is still unintuitive and ugly and non-standard.


texts: Make emacsclient create a frame only if there isn't one already

texts:
How can I make emacsclient -a '' -n create a new frame only if there isn't one already?

The problem with the -c flag is that it creates a new frame every time. The problem without it is that if there is no frame open it will open in the command line.

If I can check if there is an open Emacs frame from the shell, I can call with or without -c depending on that to get the behavior I want. I tried:

$ emacsclient -a '' --eval '(frames-on-display-list)'
(#<frame F1 0xba2740>)

I always get the same result.

I could use temporary files or pgrep, but those approaches are very error prone.

This is similar to this question, but it is not a duplicate, since the OP there was satisfied with having to have a frame open before calling emacsclient.


texts:
Magit status used to create a buffer with the buffer name magit: repo name.  I recently upgraded Spacemacs and the Magit status buffer started to disappear whenever its window was not visible, and it doesn't show up in my buffer list.
I can keep it by renaming the buffer, but that's pretty annoying.
How can I debug this?


texts: Is it possible to change the menu separator?

texts:
Consider the following menu item:

Notice that the separator is "--" (between *Messages* and Next Buffer). Is there a way to change the separator? I would like to change it to "======" instead.
The separator is apparently set by menu-bar-separator, which is defined in subr.el:
(defconst menu-bar-separator '("--")
  "Separator for menus.")

It appears to be a constant. Does this mean that it is impossible to change the menu bar separator?


texts:
skewer-mode has been a very useful tool for me learning JavaScript. I constantly use skewer-eval-last-expression and skewer-eval-defun for debugging purposes, but I find that most of the time I want to evaluate the entire script file I am working on, rather than a single function or expression. Is there a way for me to evaluate the entire buffer, rather than just a function or expression?

My current hack to get around this, is to just surround all the code I am working on in curly braces. That way when I call skewer-eval-defun, all the code within the braces is evaluated. However, it would be nice if there was a solution that didn't involve extra code that needs to be removed later (the extra braces affect indentation as well).


texts: Quickly open file by full path in clipboard

texts:
There is something that blocks my workflow quite often and I'm quite sure it's easy to solve.

I sometimes copy file paths (e.g. /tmp/bar/foo.gz) from the command line into my host systems clipboard. Then I want to open them inside emacs and edit them. My system clipboard is linked to emacs clipboard so this is no problem.

Currently I use (ido-find-file) bound to C-x C-f which brings up the minibuffer with the path of the current file e.g. /home/cb0/.

Option 1: If I now yank into the minibuffer it will always append to the current selection, resulting in something non-existing /home/cb0//tmp/bar/foo.gz".

Option 2: Pressing M-DEL multiple times will delete the path in the minibuffer, leaving a single / at the beginning. Now yanking will also result in a faulty path ``//tmp/bar/foo.gz`.

Option 3: Pressing C-a (go to line start), C-k (kill rest of line) and yank again also does not work in minibuffer.

These are not applicable for me:

use emacsclient straight from command line to edit this file
use a shell script to tell emacs to open the file whose filepath is in current clipboard.
using find-file or helm-mode-find-file all left me with the same result

What is the easiest way to have a filepath in "system" or "emacs" clipboard, and then head over to emacs and start editing just that file ?


texts: Using ediff to view a Github pull request

texts:
I would like to be able to review Github pull requests as a single ediff
"session" (if that's the right word). However, whenever I use magit-ediff from
Magit, I can only ediff a single file at once, then I have to exit the ediff
session and restart a new ediff session on the next file.

Is there a way I can use ediff to review an entire Github pull request that may
have multiple commits and multiple changed files?


texts: Heading underlined in info files on macOS (railwaycat)

texts:
I recently installed railwaycat's Emacs Mac Port, and found that, unlike Emacs for Mac OS X, the headings in info files are now underlined.
How can I get rid of these superfluous underlines?
The image below illustrates the issue, as it appears in Emacs 26.1 (build 1, x86_64-apple-darwin17.6.0, Carbon Version 158 AppKit 1561.4).

:


texts: Can an org clock table :match on things that aren't tags?

texts:
I have a clock table that matches on tags, and that works fine:
#+BEGIN: clocktable :match "meeting" :scope ("~/org/journal/Journal 2021-04.org")

But I would like to be able to tie my clock tables into org roam by matching on links, so I can avoid having both roam links and tags in the same place; something like:
:match [[some link]]

I was reading about matching tags and properties, and this section is similar to what I want:

Instead of a tag, you may also specify a regular expression enclosed in curly braces. For example, ‘work+{^boss.*}’ matches headlines that contain the tag ‘:work:’ and any tag starting with ‘boss’.

But it explicitly only (?) allows for regular expressions that match on tags. I think I found where the match tags are parsed in org-clock.el, but I'm an elisp novice and it feels dangerous to modify an internal function like org-clock-get-table-data.
Is there a way to accomplish what I'm looking for (matching on links) without modifying org-clock-get-table-data?